Loading...
Loading...
Compare original and translation side by side
| Credential | Where to get it |
|---|---|
| Sanity Project ID | Your |
| Dataset name | Usually |
| Sanity API read token | Create at sanity.io/manage → Project → API → Tokens. See HTTP Auth docs |
| LLM API key | From your LLM provider (Anthropic, OpenAI, etc.) — any provider works |
| 凭证名称 | 获取方式 |
|---|---|
| Sanity项目ID | 可在 |
| 数据集名称 | 通常为 |
| Sanity API只读令牌 | 在sanity.io/manage → 项目 → API → 令牌页面创建。详情请查看HTTP认证文档 |
| LLM API密钥 | 从你的LLM供应商获取(Anthropic、OpenAI等)——支持任意供应商 |
https://api.sanity.io/:apiVersion/agent-context/:projectId/:datasethttps://api.sanity.io/:apiVersion/agent-context/:projectId/:dataset/:slughttps://api.sanity.io/:apiVersion/agent-context/:projectId/:datasethttps://api.sanity.io/:apiVersion/agent-context/:projectId/:dataset/:slug| Tool | Purpose |
|---|---|
| Get compressed schema overview (types, fields, document counts) |
| Execute GROQ queries with optional semantic search |
| Get detailed schema for a specific document type |
| 工具名称 | 用途 |
|---|---|
| 获取压缩后的schema概览(内容类型、字段、文档数量) |
| 执行GROQ查询,可搭配语义搜索功能 |
| 获取特定文档类型的详细schema |
| Component | What it is | Examples |
|---|---|---|
| 1. Studio Setup | Configure the context plugin and create agent context documents | Sanity Studio (separate repo or embedded) |
| 2. Agent Implementation | Code that connects to Context MCP and handles LLM interactions | Next.js API route, Express server, Python service, or any MCP-compatible client |
| 3. Frontend (Optional) | UI for users to interact with the agent | Chat widget, search interface, CLI—or none for backend services |
| 组件名称 | 说明 | 示例 |
|---|---|---|
| 1. Sanity Studio配置 | 配置Context插件并创建Agent上下文文档 | Sanity Studio(独立仓库或嵌入式) |
| 2. Agent实现 | 连接到Context MCP并处理LLM交互的代码 | Next.js API路由、Express服务器、Python服务或任何兼容MCP的客户端 |
| 3. 前端(可选) | 供用户与Agent交互的UI | 聊天组件、搜索界面、CLI——后端服务可无需前端 |
curl -X POST https://api.sanity.io/YOUR_API_VERSION/agent-context/YOUR_PROJECT_ID/YOUR_DATASET \
-H "Authorization: Bearer $SANITY_API_READ_TOKEN" \
-H "Content-Type: application/json" \
-d '{"jsonrpc": "2.0", "method": "tools/list", "id": 1}'curl -X POST https://api.sanity.io/YOUR_API_VERSION/agent-context/YOUR_PROJECT_ID/YOUR_DATASET \
-H "Authorization: Bearer $SANITY_API_READ_TOKEN" \
-H "Content-Type: application/json" \
-d '{"jsonrpc": "2.0", "method": "tools/list", "id": 1}'text::embedding()*[_type == "article" && category == "guides"]
| score(text::embedding("getting started tutorial"))
| order(_score desc)
{ _id, title, summary }[0...10]order(_score desc)score()text::embedding()*[_type == "article" && category == "guides"]
| score(text::embedding("getting started tutorial"))
| order(_score desc)
{ _id, title, summary }[0...10]score()order(_score desc)_idpackage.jsonnpm info <package> version_idpackage.jsonnpm info <package> versiondeploy_schemanpx sanity@latest mcp configuredeploy_schemaRecommended approach: If you have a local Sanity Studio, deploying via the Studio is preferred:
- Local schema files (in
) are the source of truthschemaTypes/- Using
directly can create drift between your code and the deployed schemadeploy_schema- Edit your local schema files and run
insteadnpx sanity schema deployUse this escape hatch when local deployment isn't an option or isn't working.
deploy_schemanpx sanity@latest mcp configuredeploy_schema推荐方式:如果你有本地Sanity Studio,建议通过Studio部署schema:
- 本地schema文件(位于
)是唯一可信源schemaTypes/- 直接使用
可能导致代码与已部署schema不一致deploy_schema- 请编辑本地schema文件,然后运行
命令npx sanity schema deploy仅当本地部署不可用或失败时,再使用此应急方案。