sanity mcp server
An MCP server that enables Claude Desktop to interact with Sanity.io content, providing tools to create, edit, list documents and get schema templates.
An MCP server that enables Claude Desktop to interact with Sanity.io content, providing tools to create, edit, list documents and get schema templates.
This MCP server provides tools for interacting with Sanity.io content from Claude Desktop.
Install dependencies:
npm install
Create a .env
file with your Sanity credentials:
SANITY_PROJECT_ID=your_project_id
SANITY_DATASET=your_dataset
SANITY_TOKEN=your_token
{
"command": "node",
"args": ["src/sanity-mcp-server.ts"],
"env": {
"SANITY_PROJECT_ID": "your_project_id",
"SANITY_DATASET": "your_dataset",
"SANITY_TOKEN": "your_token"
}
}
Creates a new document in Sanity
Parameters:
- type
: Document type
- content
: Document content
Example:
{
"type": "post",
"content": {
"title": "My Post",
"body": [
{
"_type": "block",
"children": [
{
"_type": "span",
"text": "Hello world!"
}
]
}
]
}
}
Edits an existing document
Parameters:
- id
: Document ID
- content
: Updated content
Lists documents of a specific type
Parameters:
- type
: Document type
- limit
: Maximum number of documents to return (default: 10)
Gets a schema template based on an existing document
Note: For best results, manually create at least one document of each type before using this tool.
Parameters:
- type
: Document type
Create a new blog post:
{
"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!"
}
]
}
]
}
}
}
Edit an existing post:
{
"tool": "edit-document",
"arguments": {
"id": "post-id-123",
"content": {
"title": "Updated Title"
}
}
}
List recent posts:
{
"tool": "list-documents",
"arguments": {
"type": "post",
"limit": 5
}
}
Get schema for posts: ```json { "tool": "get-schema", "arguments": { "type": "post" } }