Title: Sanity MCP server
URL Source: https://www.sanity.io/docs/ai/mcp-server
Published Time: 2025-05-14T20:43:08Z
Markdown Content:
For AI agents: append .md to this page's URL for a markdown version. The complete documentation index is available at https://www.sanity.io/docs/llms.txt.
Getting started
* [Overview](https://www.sanity.io/docs/getting-started)
* [Platform introduction](https://www.sanity.io/docs/getting-started/the-sanity-content-operating-system-an-introduction)
* [AI coding agents](https://www.sanity.io/docs/getting-started/ai-coding-agents)
* [AI app builders](https://www.sanity.io/docs/getting-started/ai-app-builder-quickstart)
* [Next.js quickstart](https://www.sanity.io/docs/next-js-quickstart)
* [Nuxt.js quickstart](https://www.sanity.io/docs/nuxt-js-quickstart)
* [Astro quickstart](https://www.sanity.io/docs/astro-quickstart)
* [React Router quickstart](https://www.sanity.io/docs/react-router-quickstart)
* [Studio quickstart](https://www.sanity.io/docs/sanity-studio-quickstart)
*
Platform
* [Content Lake](https://www.sanity.io/docs/content-lake)
* [Functions](https://www.sanity.io/docs/functions)
* [APIs and SDKs](https://www.sanity.io/docs/apis-and-sdks)
* [Blueprints](https://www.sanity.io/docs/blueprints)
* [Platform management](https://www.sanity.io/docs/platform-management)
* [Build with AI](https://www.sanity.io/docs/ai)
* [Agent Actions](https://www.sanity.io/docs/agent-actions)
* [Visual Editing](https://www.sanity.io/docs/visual-editing)
* [Workflows](https://www.sanity.io/docs/workflows)
*
Apps
* [Dashboard](https://www.sanity.io/docs/dashboard)
* [Studio](https://www.sanity.io/docs/studio)
* [Canvas](https://www.sanity.io/docs/canvas)
* [Media Library](https://www.sanity.io/docs/media-library)
* [App SDK](https://www.sanity.io/docs/app-sdk)
* [Content Agent](https://www.sanity.io/docs/content-agent)
*
Integrations
* [Next.js](https://www.sanity.io/docs/nextjs)
* [Astro](https://www.sanity.io/docs/astro)
* [APIs and SDKs](https://www.sanity.io/docs/apis-and-sdks)
*
Reference
* [HTTP API](https://www.sanity.io/docs/http-reference)
* [CLI](https://www.sanity.io/docs/cli-reference)
* [Libraries](https://www.sanity.io/docs/libraries)
* [Specifications](https://www.sanity.io/docs/specifications)
*
Resources
* [User guides](https://www.sanity.io/docs/user-guides)
* [Developer guides](https://www.sanity.io/docs/developer-guides)
* [Courses and certifications](https://www.sanity.io/learn)
* [Changelog](https://www.sanity.io/docs/changelog)
* [Join the community](https://snty.link/community)
* [Templates](https://www.sanity.io/templates)
Log inGet started
Ask agent
Documentation
Getting started Platform Apps Integrations Reference Resources Ask agent
Sanity docs
Platform
Content LakeFunctionsAPIs and SDKsBlueprintsPlatform managementBuild with AIAgent ActionsVisual EditingWorkflows
Sanity docs
Apps
DashboardStudioCanvasMedia LibraryApp SDKContent Agent
Sanity docs
Integrations
Next.jsAstroAPIs and SDKs
Sanity docs
Reference
HTTP APICLILibrariesSpecifications
Sanity docs
Resources
User guidesDeveloper guidesCourses and certificationsChangelogJoin the communityTemplates
Search CTRL K
Get 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 Connect Sanity Context with LangChain Content access and security Configure an MCP Context MCP reference Context MCP tools
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 November 4, 2026
Sanity MCP server
Ask about this page Copy article
Copy article As Markdown, optimized for LLMs Open in ChatGPT Get help with this article Open in Claude Get help with this article Copy MCP install command npx sanity@latest mcp configureConnect to Cursor Add Sanity MCP server to CursorConnect to VS Code Add Sanity MCP server to VS Code
Enable AI agents to interact with your Sanity workspace through the Model Context Protocol (MCP).
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.
Claude Code Cursor VS Code OpenCode v0 Lovable Replit Other clients
To add the Sanity MCP server, run the following command in your terminal. The next time you run Claude Code, it has access to the MCP server and you can authenticate with OAuth.
Terminal
claude mcp add Sanity -t http https://mcp.sanity.io --scope user
To install the Sanity MCP server in Cursor directly, click the Cursor button. Once it's installed, you're prompted to authorize access.
Cursor
You can confirm the server is running by opening the Command Palette (Command+Shift+P / Control+Shift+P) and running View: Open MCP Settings.
Alternatively, you can manually update your configuration:
- Open the Command Palette and run View: Open MCP Settings.
- Select + New MCP Server in the settings pane. This opens your
mcp.json file.
- Add the following configuration:
mcp.json
{
"mcpServers": {
"Sanity": {
"type": "http",
"url": "https://mcp.sanity.io"
}
}
}
Once you save the file, Cursor detects the new server and prompts you to authenticate with OAuth to complete the connection.
- Open Visual Studio Code.
- In the Command Palette (Command+Shift+P / Control+Shift+P), run: MCP: Open User Configuration.
- Update the
mcp.json file with the following configuration and save the file:
mcp.json
{
"servers": {
"Sanity": {
"type": "http",
"url": "https://mcp.sanity.io"
}
}
}
Once you save the file, VS Code detects the new server and prompts you to authenticate with OAuth to complete the connection.
You can add Sanity as a remote MCP server in your OpenCode configuration.
- Open your OpenCode config file.
- Add the following configuration to the
mcp section:
opencode.json
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"sanity": {
"type": "remote",
"url": "https://mcp.sanity.io",
"oauth": {}
}
}
}
Save the file and authenticate with Sanity by running: opencode mcp auth sanity
Once authenticated, you can use Sanity tools in your prompts by mentioning sanity. For more details, see the OpenCode MCP documentation.
v0 is an AI agent from Vercel that helps anyone create real code and full-stack apps. Ship features, refine designs, update copy, and create live prototypes, all with a prompt. To add the Sanity MCP server to v0, follow these steps:
- In the v0 prompt input field, click Prompt Tools (bottom left).
- Select MCPs, then click Add New.
- Select Sanity.
- Click Authorize.
- Follow the prompt to authenticate with your Sanity account using OAuth.
You can add Sanity as a "Personal connector" in Lovable.
- In Lovable, go to Settings>Connectors>Personal connectors.
- Click New MCP server.
- Enter
Sanity as the name and https://mcp.sanity.io as the Server URL.
- Click Add & authorize.
- Follow the prompt to authenticate with your Sanity account using OAuth.
For more details on managing connectors, see the Lovable MCP documentation.
You can add Sanity as a custom MCP server in Replit Agent.
- Go to the Integrations Page, then scroll down to MCP Servers for Replit Agent.
- Click Add MCP server.
- Enter
Sanity as the name and https://mcp.sanity.io as the Server URL.
- Click Test & Save.
- Follow the prompt to authenticate with your Sanity account using OAuth.
Once saved, you can ask Replit Agent to use Sanity by mentioning it in your chat. For more details, see the Replit MCP documentation.
If your client does not support remote MCP servers, you may be able to use a proxy such as mcp-remote.
{
"mcpServers": {
"Sanity": {
"command": "npx",
"args": [
"mcp-remote",
"https://mcp.sanity.io",
"--transport",
"http-only"
]
}
}
}
The Sanity MCP server uses OAuth by default to perform operations on your behalf. You may instead provide an API token by setting the Authorization header in your MCP configuration. When the header is set, the server doesn't use OAuth. Tool calls use the API token and are limited to its role and permissions.
mcp.json
{
"mcpServers": {
"Sanity": {
"url": "https://mcp.sanity.io",
"headers": {
"Authorization": "Bearer YOUR_SANITY_API_TOKEN"
}
}
}
}
Replace YOUR_SANITY_API_TOKEN with your token. You can create API tokens from sanity.io/manage or with the sanity CLI's tokens command. You can also provide a personal token, which shares your role and permissions and links you to any changes in the revision history.
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 datasets and CORS origins, and migration assistance. These tools allow your AI assistant to interact with your Sanity data directly.
When a deployed schema is available, the Sanity MCP server validates documents before applying changes from patch_documents, create_documents, and publish_documents. Your agent can check if your project is compatible with document validation by using the documents_validate tool. Validation works best when there is a single schema deployed to the target project and dataset.
Creating and patching documents uses a looser set of rules that prevent structural problems such as unknown fields or incorrect types. Publishing documents runs stricter checks, ensuring documents include all the required fields to go live. If a change is rejected for invalid document contents, the tool response includes exactly which fields should be updated.
Custom validation rules are currently skipped when run via MCP. When validation is skipped or only partially run, the response from server tools will indicate which rules were skipped.
The following is a list of available tools and their uses:
-
dataset_assets_upload_from_web_chatgpt Upload a ChatGPT web attachment or generated file to a Content Lake dataset. Pass the file through ChatGPT web file input; ChatGPT web supplies a temporary download URL that Sanity fetches. Works when the ChatGPT web sandbox cannot make HTTP requests. Choose image or file as assetType. Returns an operationId; use assets_upload_status to retrieve the asset and document field reference. Attach the reference with patch_documents, preserving existing field values. If the download URL expires, pass the file again for a fresh URL and a new requestKey. Check the destination before repeating an upload whose outcome is unknown. Source size and fetch time limits apply; processing may take several minutes.
-
dataset_assets_upload_from_url Start an image or file upload from a public HTTPS URL to a Content Lake dataset. Returns an operationId immediately; use assets_upload_status to retrieve the asset and document field reference. Attach the returned reference with patch_documents, preserving existing field values. Submit uploads individually and check their operation IDs together with assets_upload_status. Honor HTTP Retry-After when rate limited. If a request is interrupted before an operationId is returned, check the destination before repeating the upload. Source size and fetch time limits apply; processing may take several minutes. For a local or private file, use dataset_assets_upload_from_file. For files in ChatGPT web, use dataset_assets_upload_from_web_chatgpt.
-
media_library_upload_from_url Start an image, video, or file upload from a public HTTPS URL to a Media Library. Optionally add a version to an existing asset. Returns an operationId immediately; use assets_upload_status to retrieve the asset, assetInstance, and uploadSession. Submit uploads individually and check their operation IDs together with assets_upload_status. Honor HTTP Retry-After when rate limited. If a request is interrupted before an operationId is returned, check the destination before repeating the upload. Source size and fetch time limits apply; processing may take several minutes. If a duplicate conflict returns error.existingAssetId, follow the error message to inspect the existing asset before retrying. For a local or private file, use media_library_upload_from_file.
-
media_assets_upload_from_url Deprecated. Use media_library_upload_from_url with the same arguments. This tool does not start an upload.
-
assets_upload_status Check one to 20 asset uploads using operationIds. Wait at least pollAfterMs between checks and group running uploads in one call. Honor HTTP Retry-After when rate limited. A status lookup error does not mean the upload failed. Results include asset IDs, URLs, and references; set includeMetadata for full metadata. Results are available for up to 24 hours. If an upload outcome is unknown, check the destination before repeating it.
-
media_library_upload_from_file Prepare a one-use URL to upload a local or private image, video, or file up to 50 MiB to a Media Library, or add a version to an existing asset. Requires access to the file bytes and the ability to make an HTTP POST. Follow the returned upload instructions.
-
dataset_assets_upload_from_file Prepare a one-use URL for uploading an image or file up to 50 MiB to a Content Lake dataset. Works with browser-selected files, readable chat attachments, generated files, and local files. The client needs access to the bytes and HTTP POST capability; no shell or CLI is required. Prepare after the file is available. POST the raw bytes to uploadUrl before uploadExpiresAt. The HTTP response returns the document reference and an asset summary with its ID, type, URL, filename, MIME type, size, title, description, and image dimensions. Set includeMetadata to return the full asset document with all extracted metadata. If the upload response is lost, prepare a new upload URL and resend the same file bytes and upload parameters. For files in ChatGPT web, use dataset_assets_upload_from_web_chatgpt.
-
get_schema Fetch the deployed schema for a project and dataset. Deprecated workspaceName and schemaId selectors remain temporarily available for legacy multi-schema datasets.
-
list_workspace_schemas Deprecation notice: list_workspace_schemas is deprecated. Use get_schema to inspect the authoritative schema for a dataset. This tool temporarily remains available to 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.
-
undeploy_schema Remove a legacy MCP-managed schema from an explicitly named workspace. Inspect list_workspace_schemas first and provide an explicit workspaceName. Removes the legacy schema document and MCP ownership record. Datasets with an active Schema API binding cannot be undeployed with this tool yet. Documents and hosted Studios are preserved; a hosted Studio can still contain its own schema snapshot. If a Studio deployed outside MCP shares the workspace name, removes only the MCP ownership record and leaves that Studio schema untouched. Refuses schemas managed outside MCP and provides instructions for their source. Use schema_types_delete to remove individual types instead.
-
schema_type_get Read one type from the current MCP-managed or Studio-deployed schema before calling a granular schema edit tool. Returns the current schemaVersion required for concurrency control and a reconstructed editable definition. Legacy-only and Blueprint-managed schemas cannot be edited with these tools.
-
schema_types_delete Remove one or more types from the dataset schema. Read the type with schema_type_get first and pass its current schemaVersion. Types referenced by surviving types cannot be removed. Requires an MCP-managed or Studio-deployed schema descriptor; use deploy_schema to create an MCP-managed schema first. Legacy-only schemas must be migrated before using these tools. Upstream read failures stop the edit and must be retried after recovery. Use a dry run to preview the change before writing. If local Studio files exist, edit those files unless the user explicitly requests remote takeover. Studio takeovers require explicit user confirmation. Blueprint-managed bindings must be updated from their Blueprint source because they do not identify the legacy workspace that MCP must also mirror.
-
schema_fields_patch Add, replace, or remove top-level fields on one document or object type. Read the type with schema_type_get first and pass its current schemaVersion. Each fieldDeclaration is one JavaScript object literal using deploy_schema syntax. Requires an MCP-managed or Studio-deployed schema descriptor; use deploy_schema to create an MCP-managed schema first. Legacy-only schemas must be migrated before using these tools. Upstream read failures stop the edit and must be retried after recovery. Use a dry run to preview the change before writing. If local Studio files exist, edit those files unless the user explicitly requests remote takeover. Studio takeovers require explicit user confirmation. Blueprint-managed bindings must be updated from their Blueprint source because they do not identify the legacy workspace that MCP must also mirror.
-
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 documents by directly providing structured content. Creates drafts (drafts.* prefix), published documents for types with liveEdit enabled, or release versions when releaseId is specified.
-
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. When adding a document to a release with content changes, call create_version before patch_documents, then patch the returned version ID with the same releaseId. Do not patch the published or draft ID first because that creates an unrelated draft.
-
patch_documents Update existing documents with @sanity/client patch() operations. Set documents to an object keyed by document ID, such as {"article-1":{"patches":[{"set":{"title":"New title"}}]}}.
Each document’s patches are applied as one transaction. Send at most 25 documents per call; split larger updates into more calls. Edits are saved to the draft or release version, never directly to published content.
For release edits, create the version first, then patch its versions.{releaseId}.* ID with the same releaseId. Do not patch the published ID before creating the release version.
-
query_documents Query documents from Sanity using GROQ. Pass only the GROQ string in query. Do not include JavaScript imports, template wrappers, or defineQuery(). When using variables, set params to a JSON object such as {"type":"post"}.
Results are not truncated. A result larger than 64 KiB is rejected with an error instead. Use field projections and GROQ slices to request only what you need, and fetch large result sets in batches, for example by slicing ordered by _id and filtering with _id > $after.
For unfamiliar GROQ syntax, functions, or query patterns, fetch get_sanity_rules({rules: ["groq"]}) before proceeding.
-
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.
-
documents_validate Validate documents against the deployed schema without modifying them. This tool is in beta. Results may be incorrect or incomplete; review them before making changes.
-
publish_documents Publish one or more drafts. Set ids to an array such as [{"id":"article-1"}]. Use the exact IDs returned by create_documents, query_documents, or get_document.
-
unpublish_documents Unpublish one or more published documents (moves them back to drafts)
-
discard_drafts Discard one or more draft documents (deletes drafts while keeping published documents intact)
-
version_discard Discard one or more document versions from a release
-
list_organizations Lists all organizations the user has access to in Sanity
-
list_projects Lists all Sanity projects associated with your account
-
get_project_studios Retrieves all studio applications linked to a specific Sanity project
-
create_project Creates a new Sanity project and initializes it with a dataset and API tokens
-
cors_origins_list Lists all CORS origins configured for a Sanity project
-
add_cors_origin Adds CORS origin(s) to allow client-side requests to a Sanity project
-
cors_origins_delete Deletes a CORS origin from a Sanity project
-
whoami Returns the currently authenticated Sanity account. Use it first for access or account troubleshooting and report the returned name, email, provider, and MCP authentication method so the user can verify which identity is active.
-
list_datasets Lists all datasets in your Sanity project
-
create_dataset Creates a new dataset with specified name and access settings
-
update_dataset Update an existing dataset's visibility (public or private) and description. Public datasets allow unauthenticated reads. Pass null to clear the description. The dataset name identifies the target and cannot be changed by this tool.
-
create_release Create a new release for grouping content changes. Optionally provide releaseId; if omitted, one is generated. Does not schedule the release: releaseType and intendedPublishAt are recorded as metadata only. Scheduling, publishing, archiving and deleting a release are not available here and must be done in Sanity Studio or via the HTTP Actions API.
-
list_releases List releases in a dataset. By default returns active and scheduled releases. Use the state filter to find published or archived releases.
-
list_embeddings_indices List all available embeddings indices for a dataset
-
semantic_search Perform a semantic search on an embeddings index
-
media_library_list Lists the Sanity Media Libraries in an organization. Call list_organizations first to get an organization ID. Returns library IDs to pass as mediaLibraryId to the other media_library_* tools.
-
media_library_get_schema Get the document types of a Media Library, or the full field definitions for one type. Call this before querying or editing: the library schema is fixed (assets, collections, folders, aspects), and the organization's own asset aspects are merged onto sanity.asset under aspects.
-
media_library_query_documents Query a Media Library using GROQ. Assets, collections, folders, and aspect definitions are all queryable. The result count reflects the query result set, not the library total; use a count() query for totals.
-
media_library_get_document Fetch a single Media Library document by its exact ID. This is a direct ID lookup only - it does not search, filter, or query.
-
media_library_create_documents Create documents in a Media Library. Only sanity.asset.collection can be created — assets themselves come from uploading a binary, which is not supported here. Documents are created directly, not as drafts.
-
media_library_patch_documents Edit Media Library documents. Edits are limited to the safe subset: an asset's title and aspects.*, its cdnAccessPolicy, and collection metadata/membership. Asset title/aspects.* edits are saved to a draft — publish them with media_library_publish_documents. cdnAccessPolicy is published-only and takes effect immediately: address it by the published id (a drafts. id is refused, since it cannot be staged) and patch it separately from title/aspects. Collections are edited directly. Folder placement, the version graph, and other system fields are rejected and must be managed in the Media Library app; custom metadata belongs in aspects. Every value an edit writes must be valid against the library's schema afterwards, on a draft or a published document alike; the edit is refused with the reasons otherwise. Problems the document already had elsewhere are reported as warnings, not enforced, and will stop publish until fixed. Array items without a _key are keyed by Content Lake on write, so re-read before addressing them by key.
-
media_library_publish_documents Publish asset drafts to make unpublished metadata edits (title, aspects.*) live, preserving published-only and system-managed fields. The draft is validated against the current aspect definitions first, as the Media Library app does: any error in title or aspects refuses the publish, an aspect whose definition has since been deleted is kept as it stands, and root fields outside the schema are preserved and listed. Only assets have a draft/publish flow. Fails for an asset that has no draft.
-
media_library_discard_drafts Discard asset drafts, throwing away unpublished metadata edits and leaving the published asset intact.
-
media_library_list_asset_references Lists documents (across project datasets) that reference a Media Library asset. Use this before replacing an asset to see what depends on it.
-
media_library_link_assets Make one or more Media Library assets usable in project documents. For image/file assets this creates a local deliverable copy and returns a field value referencing it, plus a weak media global document reference back to the library; for video assets it returns a sanity.video value with global document references only (no local copy). Returns per-asset ready-to-use field values to apply with patch_documents against the target dataset. Each field type must match its asset type. Pairs with media_library_list_asset_references.
-
usage_snapshot_get Get metered usage totals, such as API requests, CDN requests, documents and assets, for a project, organization or media library over one billing period. For trends over time, use usage_history_get.
-
usage_history_get Get metered usage for a project, organization or media library as a series of daily, monthly or yearly data points. For the current period total, use usage_snapshot_get.
-
run_sanity_cli Run a limited subset of Sanity CLI commands and return their output. Prefer dedicated Sanity MCP tools when possible, use CLI as a fallback for special cases. Use --help to list available commands or <command> --help for command details. Commands run without a shell and cannot access the filesystem, prompt for input, run in the background, or change authentication.
-
-
read_docs Fetch a specific documentation article.
-
list_sanity_rules List available best-practice development rules.
-
get_sanity_rules Load specific best-practice development rules.
-
give_sanity_feedback Submit feedback about Sanity when you encounter issues while working with a Sanity codebase or project.
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. If the feedback concerns a
Media Library, include its mediaLibraryId (and organizationId if known).
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
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 (for example, 401 Unauthorized), the solution depends on how you installed the server:
Configured by the CLI with an API token
If the Sanity CLI configured your editor with an API token, the token may have expired or been revoked. Logging out of the CLI also revokes it. To fix this, run the configuration command again. Editors with an expired token are labeled (auth expired) and selected by default. Press Enter to confirm:
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
The CLI then writes a valid token to your editor's configuration file.
Configured with OAuth
If you configured the server manually, or the CLI configured it for Claude Code, Codex CLI, Cursor, OpenCode, or VS Code, you're 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.
Was this page helpful?
Report issue
Send
Feedback submitted, thanks for helping us improve the docs. Have you tried these alternatives?
Ask agentVisit the community
Previous ### Get startedNext ### Agent skills
Placeholder · Project ID
Show your own project ID here. Personalize this page once and every code sample on the docs uses your values.
Log in →Pick a project →
←
Personalize · Step 1 of 2
Pick a project
×
Stored locally · only you see thisManage projects ↗
Project name public project-id
Log into see your projects.Pick a different project
On this page
On this page
sanity.ioAll Systems Operational© Sanity 2026 Cookie preferences Change site theme Light mode System theme Dark mode
Projects
⌫Esc
No results for ""
Can't find what you're looking for?
Ask in our community
Search suggestions
Content previewLocalizationImage CDN
Docs
Parent page Article title Section > Article title New
Ask agent
Loading the agent…
Ask me anything about the docs.
Answers come from Sanity's docs and can link straight to the section you need.
- How do I model a page with reusable sections?
- Show me a GROQ query with a reference join
- How do webhooks and the Content Lake work together?
This response paused while you navigated.Continue response
Something went wrong.Try again
You've reached the turn limit for this conversation.Start a new chat
Asking about this page
Ask the agent
Enter to send, Shift+Enter for a new line
Thinking…
Thanks for the feedback
Sources