The Sanity MCP Server connects Sanity projects with AI tools to manage and explore content using natural language instructions.
Key capabilities:
Content Intelligence: AI can explore and understand your content library
Document Management: Create, update, patch, transform, translate, publish, unpublish, and delete documents with schema-aware AI operations
Content Operations: Automate tasks through natural language commands
Release Management: Plan, schedule, organize, and execute content releases
Search Capabilities: Execute GROQ queries and perform semantic search using embeddings
Schema Awareness: AI respects your content structure and validation rules
Dataset Management: Create, update, and manage datasets
Version Control: Manage document versions within releases
Configuration Access: Retrieve server/project information and list available projects and studios
Runs as a Node.js application, requiring proper Node.js environment setup to function correctly with MCP-compatible applications.
Provides special configuration instructions for users of Node Version Manager to ensure the MCP server can access Node.js properly.
Enables AI-powered tools for content operations in Sanity CMS, allowing users to create, update, and manage documents, handle release management, perform semantic searches, and access schema information through natural language instructions.
Sanity MCP Server
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.
✨ Key Features
- 🤖 Content Intelligence: Let AI explore and understand your content library
- 🔄 Content Operations: Automate tasks through natural language instructions
- 📊 Schema-Aware: AI respects your content structure and validation rules
- 🚀 Release Management: Plan and organize content releases effortlessly
- 🔍 Semantic Search: Find content based on meaning, not just keywords
Table of Contents
🔌 Quickstart
Remote server (preferred)
This README details how to run the MCP server locally. For a more production-ready setup, we recommend using the hosted remote server.
See Sanity MCP Server in the documentation for install instructions in Claude Code, Cursor and more.
Local server prerequisites
Before you can use the MCP server, you need to:
- Deploy your Sanity Studio with schema manifestThe MCP server needs access to your content structure to work effectively. Deploy your schema manifest using one of these approaches:When running in CI environments without Sanity login, you'll need to provide an auth token:
Note
Schema deployment requires Sanity CLI version 3.88.1 or newer.
- Get your API credentials
- Project ID
- Dataset name
- API token with appropriate permissions
This MCP server can be used with any application that supports the Model Context Protocol. Here are some popular examples:
- Claude Desktop
- Cursor IDE
- Visual Studio Code
- Custom MCP-compatible applications
Add configuration for the Sanity MCP server
To use the Sanity MCP server, add the following configuration to your application's MCP settings:
For a complete list of all required and optional environment variables, see the Configuration section.
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.
🛠️ Available Tools
Context & Setup
- get_initial_context – IMPORTANT: Must be called before using any other tools to initialize context and get usage instructions.
- get_sanity_config – Retrieves current Sanity configuration (projectId, dataset, apiVersion, etc.)
Document Operations
- create_document – Create a new document with AI-generated content based on instructions
- update_document – Update an existing document with AI-generated content based on instructions
- patch_document - Apply direct patch operations to modify specific parts of a document without using AI generation
- transform_document – Transform document content while preserving formatting and structure, ideal for text replacements and style corrections
- translate_document – Translate document content to another language while preserving formatting and structure
- query_documents – Execute GROQ queries to search for and retrieve content
- publish_document – Publish a draft document to make it live
- unpublish_document – Unpublish a published document (moves it back to drafts)
- version_replace_document – Replace the contents of a document version with contents from another document
- version_discard_document –Discard a document version from a release (removes it from the release)
- version_unpublish_document – Mark a document to be unpublished when the release is run
- delete_document – Permanently delete a document and all its drafts
Release Management
- list_releases – List content releases, optionally filtered by state
- create_release – Create a new content release
- edit_release – Update metadata for an existing release
- schedule_release – Schedule a release to publish at a specific time
- publish_release – Publish a release immediately
- archive_release – Archive a release that is no longer active
- unarchive_release – Restore an archived release
- unschedule_release – Remove a previously set schedule from a release
- delete_release – Delete a release
Version Management
- create_version – Create a version of a document for a specific release
- discard_version – Delete a specific version document from a release
- mark_for_unpublish – Mark a document to be unpublished when a specific release is published
Dataset Management
- list_datasets – List all datasets in the project
- create_dataset – Create a new dataset
- update_dataset – Modify dataset settings
Schema Information
- get_schema – Get schema details, either full schema or for a specific type
- list_workspace_schemas – Get a list of all available workspace schema names
GROQ Support
- get_groq_specification – Get the GROQ language specification summary
Embeddings & Semantic Search
- list_embeddings_indices – List all available embeddings indices
- semantic_search – Perform semantic search on an embeddings index
Project Information
- list_projects – List all Sanity projects associated with your account
- get_project_studios – Get studio applications linked to a specific project
⚙️ 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 | ✅ |
MCP_USER_ROLE | Determines tool access level (developer or editor) | ✅ |
SANITY_API_HOST | API host (defaults to https://api.sanity.io) | ❌ |
MAX_TOOL_TOKEN_OUTPUT | Maximum token output for tool responses (defaults to 50000). Adjust based on your model's context limits. Higher limits may pollute the conversation context with excessive data | ❌ |
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.
🔑 API Tokens and Permissions
The MCP server requires appropriate API tokens and permissions to function correctly. Here's what you need to know:
Generate API Tokens
From the terminal:
Or from Manage:
- Run
npx sanity manage
from your Studio root - In your project's management console: Settings > API > Tokens
- Click "Add new token"
- Create a dedicated token for your MCP server usage (e.g.
mcp-server
) - Store the token securely - it's only shown once!
Required Permissions
The token needs appropriate permissions based on your usage
- For read operations:
viewer
role is sufficient - For mutations:
editor
ordeveloper
role recommended - For project changes (like managing datasets):
administrator
role may be needed
Dataset Access
- Public datasets: Content is readable by unauthenticated users
- Private datasets: Require proper token authentication
- Draft and versioned content: Only accessible to authenticated users with appropriate permissions
Security Best Practices
- Use separate tokens for different environments (development, staging, production)
- Never commit tokens to version control
- Consider using environment variables for token management
- Regularly rotate tokens for security
👥 User Roles
The server supports two user roles:
- developer: Access to all tools
- editor: Content-focused tools without project administration
📦 Node.js Environment Setup
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.
🛠 Quick Setup for Node Version Manager Users
- First, activate your preferred Node.js version:
- Then, create the necessary symlinks (choose your OS):On macOS/Linux:On Windows (PowerShell as Administrator):
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
- Verify the setup:
🤔 Why is this needed?
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.
🔍 Troubleshooting
If you switch Node versions often:
- Remember to update your symlinks when changing Node versions
- You can create a shell alias or script to automate this:
To remove the symlinks later:
💻 Development
Install dependencies:
Build and run in development mode:
Build the server:
Run the built server:
Debugging
For debugging, you can use the MCP inspector:
This will provide a web interface for inspecting and testing the available tools.
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.
- ✨ Key Features <!-- omit in toc -->
- Table of Contents <!-- omit in toc -->
- 🔌 Quickstart
- 🛠️ Available Tools
- Context & Setup <!-- omit in toc -->
- Document Operations <!-- omit in toc -->
- Release Management <!-- omit in toc -->
- Version Management <!-- omit in toc -->
- Dataset Management <!-- omit in toc -->
- Schema Information <!-- omit in toc -->
- GROQ Support <!-- omit in toc -->
- Embeddings & Semantic Search <!-- omit in toc -->
- Project Information <!-- omit in toc -->
- ⚙️ Configuration
- 📦 Node.js Environment Setup
- 💻 Development
Related MCP Servers
- -securityFlicense-qualityA comprehensive suite of Model Context Protocol servers designed to extend AI agent Claude's capabilities with integrations for knowledge management, reasoning, advanced search, news access, and workspace tools.Last updated -5
- -securityFlicense-qualityAn MCP server that enables Claude Desktop to interact with Sanity.io content, providing tools to create, edit, list documents and get schema templates.Last updated -1
- AsecurityAlicenseAqualityEnables AI agents and assistants like Goose or Claude to interact with VS Code through the Model Context Protocol.Last updated -76672Apache 2.0
- -securityAlicense-qualityA Model Context Protocol server that enables Claude to interact directly with Contentful CMS, allowing the AI to fetch content types and entries from a Contentful space.Last updated -2MIT License