Compute and AI

Sanity MCP server

Enable AI assistants to interact with your Sanity workspace through the Model Context Protocol (MCP).

The Sanity Model Context Protocol (MCP) server provides AI assistants like Claude Code and Cursor with direct, authenticated access to your Sanity projects. Instead of manually writing API calls or copying documentation, AI assistants can discover and use Sanity tools automatically through a standardized protocol.

Experimental feature

Prerequisites:

Remote server

The Sanity MCP server is hosted on Sanity's infrastructure, follows Anthropic's official MCP specification, and should work with any MCP clients. Follow the documentation for your client for how to add MCP servers. Typically, you add a section like the following to the relevant configuration file:

{
  "mcpServers": {
    "Sanity": {
      "url": "https://mcp.sanity.io",
      "type": "http"
    }
  }
}

Claude Code

Use Claude's HTTP transport method to add Sanity.

claude mcp add sanity -t http https://mcp.sanity.io

Cursor

Cursor MCP server list interface

Use the following link to directly install the MCP server in Cursor. Once installed, you'll be prompted to authorize access. You can confirm tool availability using the command palette and choosing "Open MCP settings".

Add to Cursor →

Alternatively, you can update your mcp.json configuration with the following:

Other clients

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

Authorization

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 config. When configured with the header, the server will not use OAuth and tool calls will use the API token in accordance with its role and scoped to its permissions.

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 will share your role and permissions, as well as link you to any changes in the revision history.

Run commands (or tools)

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 such as creating and managing resources like datasets and api keys, and providing migration assistance. These tools allow your AI assistant to interact with your Sanity data directly.

Available tools

The following is a list of available tools and their uses:

  • get_groq_specification

    Get the GROQ language specification summary

  • get_context

    Get project-specific context for a Sanity project and dataset, including available schemas, releases, and embeddings.

  • get_schema

    Get the full schema of the current Sanity workspace

  • list_workspace_schemas

    Get a list of all available workspace schema names

  • create_document_from_json

    Create a new document by directly providing its JSON content

  • create_document_from_markdown

    Create a new document from Markdown content

  • create_version

    Create a version of an existing document for a specific release, with optional AI-generated modifications

  • patch_document

    Apply precise, direct modifications to document fields. Use for exact value changes, adding/removing specific items, or when you know exactly what needs to be changed.

  • query_documents

    Query documents from Sanity using GROQ query language

  • generate_image

    Generate a new image in a document using AI.

  • transform_image

    Transform an existing image in a document using AI.

  • 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_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_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

  • list_datasets

    Lists all datasets in your Sanity project

  • create_dataset

    Creates a new dataset with specified name and access settings

  • update_dataset

    Modifies a dataset's name or access control settings

  • list_releases

    List content releases in Sanity, optionally filtered by state (active, scheduled, etc)

  • create_release

    Create a new content release in Sanity with an automatically generated ID

  • edit_release

    Update metadata for an existing content release

  • schedule_release

    Schedule a content release to be published 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

  • list_embeddings_indices

    List all available embeddings indices for a dataset

  • semantic_search

    Perform a semantic search on an embeddings index

  • migration_guide

    Get comprehensive guidance for migrating existing projects to Sanity. Supports general migration guides, analyzing existing content structures + designing Sanity schemas, and migrating content from various CMS platforms (like Contentful, WordPress, Strapi). Use this tool when users want to migrate their existing CMS or content system to Sanity.

  • search_docs

    Search Sanity docs

  • read_docs

    Read a specific Sanity documentation article

Troubleshooting

Authentication issues: Ensure you have valid Sanity credentials and necessary permissions. Sessions expire after 7 days. Your client should automatically refresh tokens when needed. If it doesn't, check the MCP list in your client.

For vscode you can solve some authentication issues by running

Authentication: Remove Dynamic Authentication Providers from the command palette, resetting the relevant authentication provider, and starting the server again. In Cursor this command is called Cursor: Clear All MCP Tokens.

Tool availability: Verify project permissions and dataset access for the operation you're attempting. The set of tools available will vary over time as we add new or update existing tools.

Support

Join us in the Sanity community to ask questions and discuss our MCP server with other developers.

Was this page helpful?