Transform your content operations with AI-powered tools for Sanity. Create, manage, and explore your content through natural language conversations in your favorite AI-enabled editor.
Sanity MCP Server implements the Model Context Protocol to connect your Sanity projects with AI tools like Claude, Cursor, and VS Code. It enables AI models to understand your content structure and perform operations through natural language instructions.
Before you can use the MCP server, you need to:
Deploy your Sanity Studio with schema manifest
The MCP server needs access to your content structure to work effectively. Deploy your schema manifest using one of these approaches:
# Option A: Force latest CLI version (recommended)
cd /path/to/studio
SANITY_CLI_SCHEMA_STORE_ENABLED=true npx --ignore-existing sanity@latest schema deploy
# Option B: If you have the CLI installed globally
npm install -g sanity
cd /path/to/studio
SANITY_CLI_SCHEMA_STORE_ENABLED=true sanity schema deploy
# Option C: Update your Studio first
cd /path/to/studio
npm update sanity
SANITY_CLI_SCHEMA_STORE_ENABLED=true npx sanity schema deploy
[!NOTE] Schema deployment requires both the latest CLI version and the SANITY_CLI_SCHEMA_STORE_ENABLED flag. This feature will be enabled by default in a future release.
Get your API credentials
This MCP server can be used with any application that supports the Model Context Protocol. Here are some popular examples:
To use the Sanity MCP server, add the following configuration to your application's MCP settings:
{
"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"
}
}
}
}
The exact location of this configuration will depend on your application:
Application | Configuration Location |
---|---|
Claude Desktop | Claude Desktop configuration file |
Cursor | Workspace or global settings |
VS Code | Workspace or user settings (depends on extension) |
Custom Apps | Refer to your app's MCP integration docs |
You don't get it to work? See the section on Node.js configuration.
The server takes the following environment variables:
Variable | Description | Required |
---|---|---|
SANITY_API_TOKEN | Your Sanity API token | ✅ |
SANITY_PROJECT_ID | Your Sanity project ID | ✅ |
SANITY_DATASET | The dataset to use | ✅ |
SANITY_API_HOST | API host (defaults to https://api.sanity.io) | ❌ |
MCP_USER_ROLE | Determines tool access level (developer or editor) | ❌ |
[!WARNING]
Using AI with Production Datasets
When configuring the MCP server with a token that has write access to a production dataset, please be aware that the AI can perform destructive actions like creating, updating, or deleting content. This is not a concern if you're using a read-only token. While we are actively developing guardrails, you should exercise caution and consider using a development/staging dataset for testing AI operations that require write access.
The MCP server requires appropriate API tokens and permissions to function correctly. Here's what you need to know:
Generate a Robot Token:
Required Permissions:
viewer
role is sufficienteditor
or developer
role recommendedadministrator
role may be neededDataset Access:
Security Best Practices:
The server supports two user roles:
Important for Node Version Manager Users: If you use
nvm
,mise
,fnm
,nvm-windows
or similar tools, you'll need to follow the setup steps below to ensure MCP servers can access Node.js. This is a one-time setup that will save you troubleshooting time later. This is an ongoing issue with MCP servers.
First, activate your preferred Node.js version:
# Using nvm
nvm use 20 # or your preferred version
# Using mise
mise use node@20
# Using fnm
fnm use 20
Then, create the necessary symlinks (choose your OS):
On macOS/Linux:
sudo ln -sf "$(which node)" /usr/local/bin/node && sudo ln -sf "$(which npx)" /usr/local/bin/npx
[!NOTE] While using
sudo
generally requires caution, it's safe in this context because:
- We're only creating symlinks to your existing Node.js binaries
- The target directory (
/usr/local/bin
) is a standard system location for user-installed programs- The symlinks only point to binaries you've already installed and trust
- You can easily remove these symlinks later with
sudo rm
On Windows (PowerShell as Administrator):
New-Item -ItemType SymbolicLink -Path "C:\Program Files\nodejs\node.exe" -Target (Get-Command node).Source -Force
New-Item -ItemType SymbolicLink -Path "C:\Program Files\nodejs\npx.cmd" -Target (Get-Command npx).Source -Force
Verify the setup:
# Should show your chosen Node version
/usr/local/bin/node --version # macOS/Linux
"C:\Program Files\nodejs\node.exe" --version # Windows
MCP servers are launched by calling node
and npx
binaries directly. When using Node version managers, these binaries are managed in isolated environments that aren't automatically accessible to system applications. The symlinks above create a bridge between your version manager and the system paths that MCP servers use.
If you switch Node versions often:
# Example alias for your .bashrc or .zshrc
alias update-node-symlinks='sudo ln -sf "$(which node)" /usr/local/bin/node && sudo ln -sf "$(which npx)" /usr/local/bin/npx'
To remove the symlinks later:
# macOS/Linux
sudo rm /usr/local/bin/node /usr/local/bin/npx
# Windows (PowerShell as Admin)
Remove-Item "C:\Program Files\nodejs\node.exe", "C:\Program Files\nodejs\npx.cmd"
Install dependencies:
pnpm install
Build and run in development mode:
pnpm run dev
Build the server:
pnpm run build
Run the built server:
pnpm start
For debugging, you can use the MCP inspector:
npx @modelcontextprotocol/inspector -e SANITY_API_TOKEN=<token> -e SANITY_PROJECT_ID=<project_id> -e SANITY_DATASET=<ds> -e MCP_USER_ROLE=developer node path/to/build/index.js
This will provide a web interface for inspecting and testing the available tools.
Seamless access to top MCP servers powering the future of AI integration.