home / mcp / sanity mcp server

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.

Installation
Add the following to your MCP client configuration file.

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.

How to use

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.

How to install

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"
    }
  }
}

Additional setup steps for local hosting

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"
      }
    }
  }
}

Available tools

get_initial_context

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.).

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.

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.

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.

list_datasets

List all datasets in the project.

create_dataset

Create a new dataset.

update_dataset

Modify dataset settings.

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.

get_groq_specification

Get the GROQ language specification summary.

list_embeddings_indices

List all available embeddings indices.

semantic_search

Perform semantic search on an embeddings index.

list_projects

List all Sanity projects associated with your account.

get_project_studios

Get studio applications linked to a specific project.