Skip to content
Scalekit Docs
Talk to an Engineer Dashboard

Connect AI agents to the Sanity MCP server

Vendor MCP
Open markdown

The Sanity MCP connector routes your AI agent's tool calls to Sanity's own MCP server through Scalekit. Each user signs in to Sanity once, and Scalekit stores and refreshes their tokens, so your agent never handles credentials. It comes with 61 tools.

Tools
61
What they doRead · write · destructive
18 · 37 · 618 read37 write6 destructive
Users sign in with
OAuth app
Scalekit's or your own

What you can do

  • Query content: run GROQ queries and semantic searches to find documents in a dataset
  • Create and edit documents: create drafts from structured content, JSON, or Markdown, patch documents, and generate images with AI
  • Publish content: publish, unpublish, and discard drafts, and group changes into content releases
  • Manage schemas and datasets: read and deploy schemas, and create, list, and update datasets
  • Work with projects and Studios: list organizations and projects, create projects, and deploy Sanity Studio
  • Search Sanity docs: search and read Sanity documentation and migration guides

Setup

  1. Install the SDK

    Terminal window
    npm install @scalekit-sdk/node dotenv
  2. Set your credentials

    Add your Scalekit credentials to your .env file. Find values in app.scalekit.com > Developers > API Credentials.

    .env
    SCALEKIT_ENVIRONMENT_URL=<your-environment-url>
    SCALEKIT_CLIENT_ID=<your-client-id>
    SCALEKIT_CLIENT_SECRET=<your-client-secret>
  3. Create the Sanity MCP connection

    In AgentKit > Connections, create a Sanity MCP connection. The name you give it is the connection_name your code passes. See Configure connections.

    Scalekit credentials are available for Sanity MCP server, so you don't need to register an OAuth app.

  4. Authorize a user and make your first call

    quickstart.mts
    import { ScalekitClient } from '@scalekit-sdk/node'
    import 'dotenv/config'
    import { createInterface } from 'node:readline/promises'
    const scalekit = new ScalekitClient(
    process.env.SCALEKIT_ENVIRONMENT_URL,
    process.env.SCALEKIT_CLIENT_ID,
    process.env.SCALEKIT_CLIENT_SECRET,
    )
    const actions = scalekit.actions
    const connector = 'sanitymcp'
    const identifier = 'user_123'
    // Generate an authorization link for the user
    const { link } = await actions.getAuthorizationLink({ connectionName: connector, identifier })
    console.log('Authorize Sanity MCP:', link)
    const rl = createInterface({ input: process.stdin, output: process.stdout })
    await rl.question('Press Enter after authorizing...')
    rl.close()
    // Make your first call
    const result = await actions.executeTool({
    connector,
    identifier,
    toolName: 'sanitymcp_whoami',
    toolInput: {},
    })
    console.log(result)
    Terminal window
    npx tsx quickstart.mts

    Each user signs in once. See Authorize a user for the full flow and statuses.

Tools

Pass the exact name to execute_tool
Try in PlaygroundRequest a tool
  • sanitymcp__get_ui_contextGet the current UI context including the active document and workspace in Sanity Studio.Read-only

    Get Ui Context

    Get the current UI context including the active document and workspace in Sanity Studio.

    Inputs

    datasetstringrequired
    The name of the dataset in the project
    projectIdstringrequired
    The Sanity project ID
    documentIdstring
    The document ID to fetch context for. When omitted, returns project-level context only (studio URL).
    documentTypestring
    The document _type. When provided, the tool skips fetching the document to infer its type.
    maxRefDepthinteger
    Maximum depth for collecting reference IDs from the document (default 2)
    workspaceNamestring
    Workspace name as returned by `list_workspace_schemas`. Not a document type. Omit to use the sole active schema; otherwise the tool looks for "default".
  • sanitymcp_cors_origins_listLists all CORS origins configured for a Sanity project.Read-only

    List CORS Origins

    Lists all CORS origins configured for a Sanity project.

    Inputs

    projectIdstringrequired
    The Sanity project ID
    intentstring
    Briefly explain why you are making this tool call — the high-level goal, not the specific operation. For example: "migrating content from legacy CMS", "building a product catalog for launch", "cleaning up orphaned references after schema change". Make sure to not include any secrets, API keys, or information that can be considered sensitive. This helps us understand usage patterns and improve the tools.
  • sanitymcp_get_documentRetrieve a single Sanity document by its ID.Read-only

    Get Document

    Retrieve a single Sanity document by its ID.

    Inputs

    datasetstringrequired
    The name of the dataset in the project
    documentIdstringrequired
    The exact document ID to fetch. Must be a complete, known document ID (e.g., "movie-123" or "drafts.article-456"). This is a direct ID lookup only - it does not search, filter, or query.
    projectIdstringrequired
    The Sanity project ID
    intentstring
    Briefly explain why you are making this tool call — the high-level goal, not the specific operation. For example: "migrating content from legacy CMS", "building a product catalog for launch", "cleaning up orphaned references after schema change". Make sure to not include any secrets, API keys, or information that can be considered sensitive. This helps us understand usage patterns and improve the tools.
  • sanitymcp_get_project_studiosList all Sanity Studios deployed for a project.Read-only

    Get Project Studios

    List all Sanity Studios deployed for a project.

    Inputs

    projectIdstringrequired
    The Sanity project ID
    intentstring
    Briefly explain why you are making this tool call — the high-level goal, not the specific operation. For example: "migrating content from legacy CMS", "building a product catalog for launch", "cleaning up orphaned references after schema change". Make sure to not include any secrets, API keys, or information that can be considered sensitive. This helps us understand usage patterns and improve the tools.
  • sanitymcp_get_sanity_rulesLoad one or more Sanity content rules by name.Read-only

    Get Sanity Rules

    Load one or more Sanity content rules by name.

    Inputs

    rulesarrayrequired
    One or more rule names to load. Use list_sanity_rules to see available rules.
    intentstring
    Brief description of what you are trying to accomplish.
  • sanitymcp_get_schemaRetrieve the schema for a specific document type in a workspace.Read-only

    Get Schema

    Retrieve the schema for a specific document type in a workspace.

    Inputs

    datasetstringrequired
    The name of the dataset in the project
    projectIdstringrequired
    The Sanity project ID
    intentstring
    Briefly explain why you are making this tool call — the high-level goal, not the specific operation. For example: "migrating content from legacy CMS", "building a product catalog for launch", "cleaning up orphaned references after schema change". Make sure to not include any secrets, API keys, or information that can be considered sensitive. This helps us understand usage patterns and improve the tools.
    schemaIdstring
    Optional exact schema ID returned by list_workspace_schemas. Use this to inspect a specific source when multiple deployments share a workspace name.
    typestring
    Optional: Specific type name to fetch. If not provided, returns the full schema without detailed field definitions. Full field definitions are only available when requesting a specific type.
    workspaceNamestring
    Deprecation notice: workspaceName for schema selection is deprecated, Sanity is moving to one authoritative schema per dataset. Consolidate competing schemas and resolve conflicts explicitly before migrating. During the deprecation period, workspaceName is still supported. Omit workspaceName for the sole active or default schema, or provide it when selecting another workspace. Exact workspace name. Omit to use the sole deployed schema source, or default when there are multiple or none. If there are several sources without default, use list_workspace_schemas and pass an exact schemaId.
  • sanitymcp_list_datasetsList all datasets in a Sanity project.Read-only

    List Datasets

    List all datasets in a Sanity project.

    Inputs

    projectIdstringrequired
    The Sanity project ID
    intentstring
    Briefly explain why you are making this tool call — the high-level goal, not the specific operation. For example: "migrating content from legacy CMS", "building a product catalog for launch", "cleaning up orphaned references after schema change". Make sure to not include any secrets, API keys, or information that can be considered sensitive. This helps us understand usage patterns and improve the tools.
  • sanitymcp_list_embeddings_indicesList all embeddings indices available in a Sanity project.Read-only

    List Embeddings Indices

    List all embeddings indices available in a Sanity project.

    Inputs

    datasetstringrequired
    The name of the dataset in the project
    projectIdstringrequired
    The Sanity project ID
    intentstring
    Briefly explain why you are making this tool call — the high-level goal, not the specific operation. For example: "migrating content from legacy CMS", "building a product catalog for launch", "cleaning up orphaned references after schema change". Make sure to not include any secrets, API keys, or information that can be considered sensitive. This helps us understand usage patterns and improve the tools.