home / mcp / sanity mcp server

Sanity MCP Server

Provides tools to query and mutate Sanity.io content from Claude Desktop via an MCP server.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "jlmelis-sanity-mcp-server": {
      "command": "node",
      "args": [
        "src/sanity-mcp-server.ts"
      ],
      "env": {
        "SANITY_TOKEN": "YOUR_TOKEN",
        "SANITY_DATASET": "YOUR_DATASET",
        "SANITY_PROJECT_ID": "YOUR_PROJECT_ID"
      }
    }
  }
}

This MCP server lets you interact with Sanity.io content directly from Claude Desktop. It runs locally and exposes tools to create, edit, list, or inspect schemas for Sanity documents, enabling you to manage your content workflow without leaving your editing environment.

How to use

To use this MCP server, first install and run it locally, then connect Claude Desktop to it as an MCP server. You will provide Sanity credentials so the server can access your content. Once connected, you can create new documents, update existing ones, list documents by type, and fetch schema templates to guide your edits.

How to install

Prerequisites: you need Node.js and npm installed on your system. Ensure you have access to your Sanity project credentials.

npm install

Create a .env file in your project root with your Sanity credentials so the MCP server can authenticate to Sanity.

SANITY_PROJECT_ID=your_project_id
SANITY_DATASET=your_dataset
SANITY_TOKEN=your_token

Run the MCP server locally by starting the script that serves the MCP API. You will connect Claude Desktop to this local server using the settings shown in the next section.

node src/sanity-mcp-server.ts

Additional notes

Configure Claude Desktop to connect to the local MCP server. In Claude Desktop, open Settings > MCP Servers and add a new server with the exact settings below to enable communication between Claude Desktop and this MCP server.

Add server configuration (exact values shown):

{
  "command": "node",
  "args": ["src/sanity-mcp-server.ts"],
  "env": {
    "SANITY_PROJECT_ID": "your_project_id",
    "SANITY_DATASET": "your_dataset", 
    "SANITY_TOKEN": "your_token"
  }
}

Examples of common actions

These actions are available through the MCP server once you are connected: create a document, edit a document, list documents of a specific type, and get a schema template for a type.

Available tools

create-document

Creates a new document in Sanity with a specified type and content.

edit-document

Edits an existing Sanity document identified by its ID with updated content.

list-documents

Lists documents of a given type, with an optional limit on the number of results.

get-schema

Retrieves a schema template based on an existing document type to guide content structure.