Title: Sanity MCP server
URL Source: https://www.sanity.io/docs/ai/mcp-server
Published Time: 2025-05-14T20:43:08Z
Markdown Content:
Opens in a new window Opens an external website Opens an external website in a new window
This website utilizes technologies such as cookies to enable essential site functionality, as well as for analytics, personalization, and targeted advertising. To learn more, view the following link: Privacy Policy
Preferences
Storage Preferences
Opens in a new window Opens an external website Opens an external website in a new window
This website utilizes technologies such as cookies to enable essential site functionality, as well as for analytics, personalization, and targeted advertising. To learn more, view the following link: Privacy Policy
Preferences
Storage Preferences
For AI agents: append .md to this page's URL for a markdown version. The complete documentation index is available athttps://www.sanity.io/docs/llms.txt.
The Sanity engineering blog is live. Deep dives, post-mortems, and hard-won lessons.
Search or Ask AI...CTRL K
LoginGet started
Search or Ask AI...CTRL K
LoginGet started
Build with AI
Overview
MCP setup and introduction Agent Skills
Get to know Sanity Context Quick start Retrieval modes Inline initial context Knowledge Bases Knowledge Base source types Create a Knowledge Base Keep a Knowledge Base current Resolve Knowledge Base issues Add insights to Sanity Context Sanity Context patterns and best practices Connect Sanity Context with OpenAI Agents SDK Connect Sanity Context with Vercel AI SDK
Chat with your contentContent Agent
- Generate content from your apps
Content Agent APIAPIs and SDKs Generate and translate with AI APIsAgent Actions Add AI Assist to Sanity StudioStudio
Agent Toolkit Agentic localization starter AI shopping assistant starter
Build with AI Last updated August 18, 2026
Sanity MCP server
Copy article Copy article
Enable AI agents to interact with your Sanity workspace through the Model Context Protocol (MCP).
Copy article Copy article
The Sanity Model Context Protocol (MCP) server enables AI assistants like Claude Code and Cursor to interact directly with your Sanity projects.
With the MCP server, agents can go beyond code generation and perform advanced content management operations in your Sanity projects. Agents can execute GROQ queries, manage releases, and patch documents with full awareness of your schema, eliminating the need to manually supply context.
Once configured and started, authenticate with your Sanity credentials if prompted. You can then use natural language to work with Sanity development tasks, such as:
- Help me migrate this project to Sanity.
- Run a GROQ query for all articles written by Mark.
- Add localization to my article document type.
- Help me migrate existing content to a new schema shape.
- List all releases in this dataset.
mcp.sanity.io provides both editorial and development-focused tools for content operations, schema exploration, GROQ query execution, project management tasks such as creating and managing resources like datasets and API keys, and migration assistance. These tools allow your AI assistant to interact with your Sanity data directly.
The following is a list of available tools and their uses:
-
dataset_assets_upload Provide local Sanity CLI guidance for uploading an image or file asset to a Content Lake dataset. This tool does not read or upload the file.
-
get_schema Fetch a deployed schema. By default, resolves by workspace name using the existing precedence: MCP-managed, then Studio-deployed, then legacy system.schema. Use list_workspace_schemas first when a workspace name has multiple source records, then pass the advertised schemaId to inspect that exact schema.
-
list_workspace_schemas List every deployed schema for a project and dataset, grouped by source (MCP-managed, Studio-deployed, or legacy). Duplicate workspace names and multiple Studio applications are expected; each entry includes a schemaId for exact reads with get_schema.
-
deploy_schema Directly deploy schema types to the cloud.
-
deploy_studio Deploy a managed Sanity Studio bound to an MCP-managed schema. Creates a hosted Studio whose URL follows the current environment — sanity.studio on production, studio.sanity.work on staging — and returns the concrete studioUrl in the response.
Requires an existing MCP-managed schema at the same (projectId, dataset, workspaceName) address — call deploy_schema first if none exists. Re-run after subsequent deploy_schema calls so the deployed Studio picks up the latest schema.
-
create_documents Create one or more draft documents by directly providing structured content. Creates drafts (drafts.* prefix) unless releaseId is specified for version creation.
-
create_version Create a version document (versions.{releaseId}.* prefix) for a specific release. Versions are separate from drafts and published documents, and are used for scheduled release workflows.
-
patch_documents Update or edit one or more existing documents by applying precise modifications using @sanity/client patch() operations. Patches for each document are applied as a single transaction (all succeed or all fail). Edits are saved to the draft or release version; published content is never modified directly.
-
query_documents Query documents from Sanity using GROQ query language
-
generate_image Trigger async AI image generation for a document field.
-
transform_image Trigger async AI transformation of an existing image.
-
get_document Fetch a single document by its exact ID. This is a direct ID lookup only - it does not search, filter, or query. Use when you have a specific document ID and need its full content.
-
publish_documents Publish one or more draft documents to make them live
Use this when:
-
A Sanity MCP tool returned an unexpected error or confusing result
-
You needed a Sanity capability that doesn't exist or is hard to use
-
Sanity docs, MCP tool descriptions, or examples were unclear or incorrect
-
Common Sanity surfaces such as @sanity/client, the HTTP API, schemas, Studio, or deployment were confusing or blocked progress
-
You had to use a workaround for something in Sanity that should be simpler
Provide a specific, detailed message about what you were trying to do,
what happened, and what you expected instead.
Most MCP tools are standard API calls and don't consume AI credits. The following tools invoke Sanity's AI inference endpoints and consume AI credits:
generate_image
transform_image
create_version – only when the instruction parameter is provided
You can disable these tools in your MCP client if you want to avoid credit usage.
Learn more about pricing and quotas in How AI credits work.
If you encounter authentication errors (e.g., 401 Unauthorized), the solution depends on how you installed the server:
Installed via CLI (using token auth)
If you installed the MCP via the Sanity CLI, your authentication relies on a generated token that may have expired or been revoked. To fix this, simply run the configuration command again and re-select your code editor with space:
npm pnpm yarn bun
npx sanity@latest mcp configure
pnpm dlx sanity@latest mcp configure
yarn dlx sanity@latest mcp configure
bunx sanity@latest mcp configure
This will generate a fresh auth token and update your editor's configuration file automatically.
Manually configured (using OAuth)
If you configured the server manually, you are likely using OAuth. Sessions typically expire after 7 days. Your client should prompt you to re-authenticate, but if it gets stuck:
- VS Code: Run
Authentication: Remove Dynamic Authentication Providers from the Command Palette, select the Sanity provider, and restart the server.
- Cursor: Run
Cursor: Clear All MCP Tokens from the Command Palette to reset your session.
If specific tools (like query_documents) are missing or failing, verify that your account has the correct permissions for the project and dataset you are trying to access. The set of available tools may also vary as we release updates to the MCP server.
Join us in the Sanity community to ask questions and discuss our MCP server with other developers in the #mcp-server channel.
Previous ### Get startedNext ### Agent Skills
Was this page helpful?
Report issue
On this page
sanity.ioAll Systems Operational© Sanity 2026 Cookie preferences Change Site Theme
Light mode
System theme
Dark mode