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 45 tools.

Tools
45
What they doRead · write · destructive
20 · 18 · 720 read18 write7 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

    resourceobjectrequired
    No description.
    documentIdstring
    Sanity document ID (e.g. drafts.abc123 for drafts, or bare ID for published).
    documentTypestring
    Schema type name of the document.
    maxRefDepthinteger
    Maximum reference depth to follow when resolving document references.
    workspaceNamestring
    Sanity workspace name. Defaults to the default workspace.default 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

    resourceobjectrequired
    Resource information indicating which project ID to target
    intentstring
    Brief description of what you are trying to accomplish.
  • sanitymcp_dataset_assets_uploadProvide local Sanity CLI guidance for uploading an image or file asset to a Content Lake dataset.Read-only

    Prepare Dataset Asset Upload

    Provide local Sanity CLI guidance for uploading an image or file asset to a Content Lake dataset. This tool does not read or upload the file.

    Inputs

    intentstring
    Brief description of what you are trying to accomplish.
  • sanitymcp_get_documentRetrieve a single Sanity document by its ID.Read-only

    Get Document

    Retrieve a single Sanity document by its ID.

    Inputs

    documentIdstringrequired
    Sanity document ID (e.g. drafts.abc123 for drafts, or bare ID for published).
    resourceobjectrequired
    Resource information indicating which project ID and dataset to target
    intentstring
    Brief description of what you are trying to accomplish.
  • 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

    resourceobjectrequired
    No description.
    intentstring
    Brief description of what you are trying to accomplish.
  • 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

    resourceobjectrequired
    Resource information indicating which project ID and dataset to target
    intentstring
    Brief description of what you are trying to accomplish.
    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
    Document schema type name.
    workspaceNamestring
    Sanity workspace name. Defaults to the default workspace.default default
  • sanitymcp_list_datasetsList all datasets in a Sanity project.Read-only

    List Datasets

    List all datasets in a Sanity project.

    Inputs

    resourceobjectrequired
    No description.
    intentstring
    Brief description of what you are trying to accomplish.