S

Sanity MCP文档管理服务器

@jlmelis/sanity-mcp-server
0 Stars 215 次浏览 jlmelis 更新于 2026-08-23

一个MCP服务器, enables Claude Desktop与Sanity.io内容进行交互,提供创建、编辑、列出文档和获取模式模板的工具。 (注:原文中“enables Claude Desktop”部分语法略有不完整,翻译时进行了适当调整以符合中文表达习惯。)

该服务暂未提供标准配置,请参考 README 手动接入

服务介绍

Sanity MCP 服务器

此MCP服务器提供了从Claude Desktop与Sanity.io内容交互的工具。

安装

  1. 克隆此仓库
  2. 安装依赖项:
npm install
  1. 使用您的Sanity凭据创建一个.env文件:
SANITY_PROJECT_ID=your_project_id
SANITY_DATASET=your_dataset
SANITY_TOKEN=your_token

与Claude Desktop一起使用

  1. 在Claude Desktop中,转到设置 > MCP 服务器
  2. 添加一个新的服务器,并使用以下设置:
{
  "command": "node",
  "args": ["src/sanity-mcp-server.ts"],
  "env": {
    "SANITY_PROJECT_ID": "your_project_id",
    "SANITY_DATASET": "your_dataset", 
    "SANITY_TOKEN": "your_token"
  }
}

可用工具

创建文档

在Sanity中创建新文档

参数:

  • type: 文档类型
  • content: 文档内容

示例:

{
  "type": "post",
  "content": {
    "title": "My Post",
    "body": [
      {
        "_type": "block",
        "children": [
          {
            "_type": "span",
            "text": "Hello world!"
          }
        ]
      }
    ]
  }
}

编辑文档

编辑现有文档

参数:

  • id: 文档ID
  • content: 更新后的内容

列出文档

列出特定类型的文档

参数:

  • type: 文档类型
  • limit: 返回的最大文档数量(默认值:10)

获取模式

基于现有文档获取模式模板

注意: 为了获得最佳结果,在使用此工具之前,请手动至少创建每种类型的一个文档。

参数:

  • type: 文档类型

示例用法

  1. 创建一篇新的博客文章:
{
  "tool": "create-document",
  "arguments": {
    "type": "post",
    "content": {
      "title": "My First Post",
      "slug": "my-first-post",
      "body": [
        {
          "_type": "block",
          "children": [
            {
              "_type": "span",
              "text": "This is my first post!"
            }
          ]
        }
      ]
    }
  }
}
  1. 编辑现有文章:
{
  "tool": "edit-document",
  "arguments": {
    "id": "post-id-123",
    "content": {
      "title": "Updated Title"
    }
  }
}
  1. 列出最近的文章:
{
  "tool": "list-documents",
  "arguments": {
    "type": "post",
    "limit": 5
  }
}
  1. 获取文章的模式:
{
  "tool": "get-schema",
  "arguments": {
    "type": "post"
  }
}

相关 MCP 服务