home / mcp / sanity mcp server
Connect your Sanity content to AI agents. Create, update, and explore structured content using Claude, Cursor, and VS Code via the Model Context Protocol. Transform content operations from complex queries to simple conversations—giving your team superpowers without sacrificing structure.
Configuration
View docs{
"mcpServers": {
"sanity-io-sanity-mcp-server": {
"url": "https://mcp.sanity.io",
"headers": {
"MCP_USER_ROLE": "developer",
"SANITY_DATASET": "production",
"SANITY_API_HOST": "https://apihost.example.com",
"SANITY_API_TOKEN": "<token>",
"SANITY_PROJECT_ID": "<project-id>",
"MAX_TOOL_TOKEN_OUTPUT": "50000"
}
}
}
}You can connect Sanity projects to AI tools through the Sanity MCP Server to understand content structure, automate operations, and manage releases with natural language commands. It supports both remote hosting for easy access and local self-hosting when you need to run everything in your environment. This guide walks you through using the MCP server with a client, installing and configuring it, and understanding security considerations.
You interact with the MCP server through an MCP client in your preferred environment (for example Claude, Cursor, or VS Code). Start by connecting to a remote server for the simplest setup and then use the available tools to explore, transform, and manage your Sanity content. You can initialize context, inspect your schema, query content, create and update documents, manage releases, and perform semantic searches. When you give natural language instructions, the MCP server translates them into schema-aware operations while preserving your content structure and validation rules.
Prerequisites: you need Node.js and npm available if you plan to run a local MCP server. If you plan to use the remote hosted MCP server, you do not need to install Node.js locally.
Remote server (preferred) is hosted at mcp.sanity.io. Add this to your MCP client configuration to connect:
{
"mcpServers": {
"Sanity": {
"url": "https://mcp.sanity.io",
"type": "http"
}
}
}If you want to run a local MCP server yourself, follow these steps to set up the self-hosted server. The local setup requires deploying your Sanity Studio with a schema manifest and obtaining API credentials.
Deploy your Sanity Studio with a schema manifest to give the MCP server access to your content structure. This typically involves deploying your schema and ensuring the Studio can authenticate.
Add the Sanity MCP server configuration to your app to run the local server through npx. The configuration example below shows how to start the MCP server using npx with the required environment variables.
{
"mcpServers": {
"sanity": {
"command": "npx",
"args": ["-y", "@sanity/mcp-server@latest"],
"env": {
"SANITY_PROJECT_ID": "your-project-id",
"SANITY_DATASET": "production",
"SANITY_API_TOKEN": "your-sanity-api-token",
"MCP_USER_ROLE": "developer"
}
}
}
}Must be called before using any other tools to initialize context and get usage instructions.
Retrieves current Sanity configuration (projectId, dataset, apiVersion, etc.).
Create a new document with AI-generated content based on instructions.
Update an existing document with AI-generated content based on instructions.
Apply direct patch operations to modify specific parts of a document without using AI generation.
Transform document content while preserving formatting and structure, ideal for text replacements and style corrections.
Translate document content to another language while preserving formatting and structure.
Execute GROQ queries to search for and retrieve content.
Publish a draft document to make it live.
Unpublish a published document (moves it back to drafts).
Replace the contents of a document version with contents from another document.
Discard a document version from a release (removes it from the release).
Mark a document to be unpublished when the release is run.
Permanently delete a document and all its drafts.
List content releases, optionally filtered by state.
Create a new content release.
Update metadata for an existing release.
Schedule a release to publish at a specific time.
Publish a release immediately.
Archive a release that is no longer active.
Restore an archived release.
Remove a previously set schedule from a release.
Delete a release.
Create a version of a document for a specific release.
Delete a specific version document from a release.
Mark a document to be unpublished when a specific release is published.
List all datasets in the project.
Create a new dataset.
Modify dataset settings.
Get schema details, either full schema or for a specific type.
Get a list of all available workspace schema names.
Get the GROQ language specification summary.
List all available embeddings indices.
Perform semantic search on an embeddings index.
List all Sanity projects associated with your account.
Get studio applications linked to a specific project.