Skip to content
Scalekit Docs
Talk to an Engineer Dashboard

Sanity MCP connector

OAuth 2.1/DCRDeveloper ToolsFiles & DocumentsProductivity

Connect to Sanity. Manage structured content, documents, datasets, schemas, releases, and media assets for headless CMS workflows.

Sanity MCP connector

  1. Terminal window
    npm install @scalekit-sdk/node

    Full SDK reference: Node.js | Python

  2. 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. quickstart.ts
    import { ScalekitClient } from '@scalekit-sdk/node'
    import 'dotenv/config'
    const scalekit = new ScalekitClient(
    process.env.SCALEKIT_ENV_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)
    process.stdout.write('Press Enter after authorizing...')
    await new Promise(r => process.stdin.once('data', r))
    // Make your first call
    const result = await actions.executeTool({
    connector,
    identifier,
    toolName: 'sanitymcp_list_organizations',
    toolInput: {},
    })
    console.log(result)

Connect this agent connector to let your agent:

  • Whoami records — Get the currently authenticated Sanity user profile
  • Document version unpublish, version replace — Unpublish a versioned document from a release
  • Discard version — Discard document versions associated with a release
  • Update dataset — Update the access control mode or description of an existing Sanity dataset
  • Documents unpublish, publish — Unpublish one or more documents to revert them to draft state
  • Image transform, generate — Apply an AI transformation to an image field in a Sanity document

Use the exact tool names from the Tool list below when you call execute_tool. If you’re not sure which name to use, list the tools available for the current user first.

sanitymcp__get_ui_context#Get the current UI context including the active document and workspace in Sanity Studio.5 params

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

NameTypeRequiredDescription
resourceobjectrequiredNo description.
documentIdstringoptionalSanity document ID (e.g. drafts.abc123 for drafts, or bare ID for published).
documentTypestringoptionalSchema type name of the document.
maxRefDepthintegeroptionalMaximum reference depth to follow when resolving document references.
workspaceNamestringoptionalSanity workspace name. Defaults to the default workspace.
sanitymcp_add_cors_origin#Add a CORS origin to allow browser-based API access for a Sanity project.4 params

Add a CORS origin to allow browser-based API access for a Sanity project.

NameTypeRequiredDescription
originstringrequiredCORS origin URL to allow (e.g. https://myapp.com).
resourceobjectrequiredNo description.
allowCredentialsbooleanoptionalWhether to allow credentials (cookies) from this CORS origin.
intentstringoptionalBrief description of what you are trying to accomplish.
sanitymcp_create_dataset#Create a new dataset in a Sanity project with the specified access control mode.5 params

Create a new dataset in a Sanity project with the specified access control mode.

NameTypeRequiredDescription
datasetNamestringrequiredName of the Sanity dataset.
resourceobjectrequiredNo description.
aclModestringoptionalDataset access control mode: public or private.
descriptionstringoptionalHuman-readable description.
intentstringoptionalBrief description of what you are trying to accomplish.
sanitymcp_create_documents_from_json#Create one or more Sanity documents from a JSON array of document objects.5 params

Create one or more Sanity documents from a JSON array of document objects.

NameTypeRequiredDescription
documentsarrayrequiredArray of documents to create. Each document must have a type and content.
resourceobjectrequiredResource information indicating which project ID and dataset to target
intentstringoptionalBrief description of what you are trying to accomplish.
releaseIdstringoptionalID of the release to target.
workspaceNamestringoptionalSanity workspace name. Defaults to the default workspace.
sanitymcp_create_documents_from_markdown#Create one or more Sanity documents from Markdown content.5 params

Create one or more Sanity documents from Markdown content.

NameTypeRequiredDescription
documentsarrayrequiredArray of documents to create. Each document must have a type and Markdown content.
resourceobjectrequiredResource information indicating which project ID and dataset to target
intentstringoptionalBrief description of what you are trying to accomplish.
releaseIdstringoptionalID of the release to target.
workspaceNamestringoptionalSanity workspace name. Defaults to the default workspace.
sanitymcp_create_project#Create a new Sanity project with optional CORS origin and organization.5 params

Create a new Sanity project with optional CORS origin and organization.

NameTypeRequiredDescription
displayNamestringrequiredDisplay name for the Sanity project.
organizationIdstringrequiredSanity organization ID to create the project under.
allowCredentialsbooleanoptionalWhether to allow credentials (cookies) from this CORS origin.
corsOriginstringoptionalCORS origin URL for the new project.
intentstringoptionalBrief description of what you are trying to accomplish.
sanitymcp_create_release#Create a new content release for scheduling or grouping document publications.6 params

Create a new content release for scheduling or grouping document publications.

NameTypeRequiredDescription
resourceobjectrequiredResource information indicating which project ID and dataset to target
titlestringrequiredTitle of the release.
descriptionstringoptionalHuman-readable description.
intendedPublishAtstringoptionalISO 8601 datetime when the release is scheduled to publish.
intentstringoptionalBrief description of what you are trying to accomplish.
releaseTypestringoptionalType of release: scheduled, immediate, or undecided.
sanitymcp_create_version#Create versioned copies of documents and associate them with a release.4 params

Create versioned copies of documents and associate them with a release.

NameTypeRequiredDescription
documentIdsarrayrequiredArray of document IDs to create versions for (min 1, max 10)
releaseIdstringrequiredID of the release to target.
resourceobjectrequiredResource information indicating which project ID and dataset to target
intentstringoptionalBrief description of what you are trying to accomplish.
sanitymcp_deploy_schema#Deploy a schema declaration to a Sanity project workspace.4 params

Deploy a schema declaration to a Sanity project workspace.

NameTypeRequiredDescription
resourceobjectrequiredResource information indicating which project ID and dataset to target
schemaDeclarationstringrequiredSanity schema configuration declaration string.
intentstringoptionalBrief description of what you are trying to accomplish.
workspaceNamestringoptionalSanity workspace name. Defaults to the default workspace.
sanitymcp_deploy_studio#Deploy a Sanity Studio to a hosted app subdomain.5 params

Deploy a Sanity Studio to a hosted app subdomain.

NameTypeRequiredDescription
appHoststringrequiredSubdomain hostname for the deployed Sanity Studio.
resourceobjectrequiredResource information indicating which project ID and dataset to target
intentstringoptionalBrief description of what you are trying to accomplish.
titlestringoptionalTitle of the release.
workspaceNamestringoptionalSanity workspace name. Defaults to the default workspace.
sanitymcp_discard_drafts#Discard draft versions of one or more documents.3 params

Discard draft versions of one or more documents.

NameTypeRequiredDescription
idsarrayrequiredDocument IDs to discard drafts for
resourceobjectrequiredResource information indicating which project ID and dataset to target
intentstringoptionalBrief description of what you are trying to accomplish.
sanitymcp_generate_image#Generate an image for a document field using an AI instruction.6 params

Generate an image for a document field using an AI instruction.

NameTypeRequiredDescription
documentIdstringrequiredSanity document ID (e.g. drafts.abc123 for drafts, or bare ID for published).
imagePathstringrequiredPath to the image field within the document.
instructionstringrequiredNatural language instruction for the image transformation.
resourceobjectrequiredResource information indicating which project ID and dataset to target
intentstringoptionalBrief description of what you are trying to accomplish.
workspaceNamestringoptionalSanity workspace name. Defaults to the default workspace.
sanitymcp_get_document#Retrieve a single Sanity document by its ID.3 params

Retrieve a single Sanity document by its ID.

NameTypeRequiredDescription
documentIdstringrequiredSanity document ID (e.g. drafts.abc123 for drafts, or bare ID for published).
resourceobjectrequiredResource information indicating which project ID and dataset to target
intentstringoptionalBrief description of what you are trying to accomplish.
sanitymcp_get_project_studios#List all Sanity Studios deployed for a project.2 params

List all Sanity Studios deployed for a project.

NameTypeRequiredDescription
resourceobjectrequiredNo description.
intentstringoptionalBrief description of what you are trying to accomplish.
sanitymcp_get_sanity_rules#Load one or more Sanity content rules by name.2 params

Load one or more Sanity content rules by name.

NameTypeRequiredDescription
rulesarrayrequiredOne or more rule names to load. Use list_sanity_rules to see available rules.
intentstringoptionalBrief description of what you are trying to accomplish.
sanitymcp_get_schema#Retrieve the schema for a specific document type in a workspace.4 params

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

NameTypeRequiredDescription
resourceobjectrequiredResource information indicating which project ID and dataset to target
intentstringoptionalBrief description of what you are trying to accomplish.
typestringoptionalDocument schema type name.
workspaceNamestringoptionalSanity workspace name. Defaults to the default workspace.
sanitymcp_list_datasets#List all datasets in a Sanity project.2 params

List all datasets in a Sanity project.

NameTypeRequiredDescription
resourceobjectrequiredNo description.
intentstringoptionalBrief description of what you are trying to accomplish.
sanitymcp_list_embeddings_indices#List all embeddings indices available in a Sanity project.2 params

List all embeddings indices available in a Sanity project.

NameTypeRequiredDescription
resourceobjectrequiredResource information indicating which project ID and dataset to target
intentstringoptionalBrief description of what you are trying to accomplish.
sanitymcp_list_organizations#List all Sanity organizations the authenticated user belongs to.1 param

List all Sanity organizations the authenticated user belongs to.

NameTypeRequiredDescription
intentstringoptionalBrief description of what you are trying to accomplish.
sanitymcp_list_projects#List all Sanity projects the authenticated user has access to.1 param

List all Sanity projects the authenticated user has access to.

NameTypeRequiredDescription
intentstringoptionalBrief description of what you are trying to accomplish.
sanitymcp_list_releases#List content releases for a project with optional state filtering and pagination.5 params

List content releases for a project with optional state filtering and pagination.

NameTypeRequiredDescription
resourceobjectrequiredResource information indicating which project ID and dataset to target
intentstringoptionalBrief description of what you are trying to accomplish.
limitintegeroptionalMaximum number of items to return.
offsetintegeroptionalNumber of items to skip for pagination.
statestringoptionalFilter releases by state: active, archived, or published.
sanitymcp_list_sanity_rules#List all available Sanity content rule names.1 param

List all available Sanity content rule names.

NameTypeRequiredDescription
intentstringoptionalBrief description of what you are trying to accomplish.
sanitymcp_list_workspace_schemas#List all schema types defined in a Sanity workspace.2 params

List all schema types defined in a Sanity workspace.

NameTypeRequiredDescription
resourceobjectrequiredResource information indicating which project ID and dataset to target
intentstringoptionalBrief description of what you are trying to accomplish.
sanitymcp_migration_guide#Retrieve a Sanity migration guide by name.2 params

Retrieve a Sanity migration guide by name.

NameTypeRequiredDescription
guidestringrequiredName of the migration guide to retrieve.
intentstringoptionalBrief description of what you are trying to accomplish.
sanitymcp_patch_document_from_json#Apply set, unset, or append patch operations to a document using JSON.8 params

Apply set, unset, or append patch operations to a document using JSON.

NameTypeRequiredDescription
documentIdstringrequiredSanity document ID (e.g. drafts.abc123 for drafts, or bare ID for published).
resourceobjectrequiredResource information indicating which project ID and dataset to target
appendarrayoptionalAppend patch operations: adds items to the end of existing array fields.
intentstringoptionalBrief description of what you are trying to accomplish.
releaseIdstringoptionalID of the release to target.
setarrayoptionalSet patch operations: replaces field values at the specified document paths.
unsetarrayoptionalUnset patch operations: removes fields or array items at the specified paths.
workspaceNamestringoptionalSanity workspace name. Defaults to the default workspace.
sanitymcp_patch_document_from_markdown#Patch a document field with Markdown content converted to Sanity portable text.7 params

Patch a document field with Markdown content converted to Sanity portable text.

NameTypeRequiredDescription
documentIdstringrequiredSanity document ID (e.g. drafts.abc123 for drafts, or bare ID for published).
markdownstringrequiredMarkdown content to patch into the document.
pathstringrequiredDocument field path to target.
resourceobjectrequiredResource information indicating which project ID and dataset to target
intentstringoptionalBrief description of what you are trying to accomplish.
releaseIdstringoptionalID of the release to target.
workspaceNamestringoptionalSanity workspace name. Defaults to the default workspace.
sanitymcp_publish_documents#Publish one or more draft documents to make them publicly visible.3 params

Publish one or more draft documents to make them publicly visible.

NameTypeRequiredDescription
idsarrayrequiredIDs of the documents to publish
resourceobjectrequiredResource information indicating which project ID and dataset to target
intentstringoptionalBrief description of what you are trying to accomplish.
sanitymcp_query_documents#Execute a GROQ query against the Sanity dataset and return matching documents.7 params

Execute a GROQ query against the Sanity dataset and return matching documents.

NameTypeRequiredDescription
querystringrequiredGROQ query string to execute.
resourceobjectrequiredResource information indicating which project ID and dataset to target
intentstringoptionalBrief description of what you are trying to accomplish.
limitintegeroptionalMaximum number of items to return.
paramsobjectoptionalOptional parameters for the GROQ query
perspectivestringoptionalQuery perspective: published, previewDrafts, or raw.
singlebooleanoptionalReturn a single result instead of an array.
sanitymcp_read_docs#Read a Sanity documentation page by URL or path.3 params

Read a Sanity documentation page by URL or path.

NameTypeRequiredDescription
intentstringoptionalBrief description of what you are trying to accomplish.
pathstringoptionalDocument field path to target.
urlstringoptionalURL of the Sanity documentation page to read.
sanitymcp_search_docs#Search Sanity documentation by keyword query.3 params

Search Sanity documentation by keyword query.

NameTypeRequiredDescription
querystringrequiredGROQ query string to execute.
intentstringoptionalBrief description of what you are trying to accomplish.
limitintegeroptionalMaximum number of items to return.
sanitymcp_transform_image#Apply an AI transformation to an image field in a Sanity document.6 params

Apply an AI transformation to an image field in a Sanity document.

NameTypeRequiredDescription
documentIdstringrequiredSanity document ID (e.g. drafts.abc123 for drafts, or bare ID for published).
imagePathstringrequiredPath to the image field within the document.
instructionstringrequiredNatural language instruction for the image transformation.
resourceobjectrequiredResource information indicating which project ID and dataset to target
intentstringoptionalBrief description of what you are trying to accomplish.
workspaceNamestringoptionalSanity workspace name. Defaults to the default workspace.
sanitymcp_unpublish_documents#Unpublish one or more documents to revert them to draft state.3 params

Unpublish one or more documents to revert them to draft state.

NameTypeRequiredDescription
idsarrayrequiredIDs of the documents to unpublish (published document IDs only)
resourceobjectrequiredResource information indicating which project ID and dataset to target
intentstringoptionalBrief description of what you are trying to accomplish.
sanitymcp_update_dataset#Update the access control mode or description of an existing Sanity dataset.4 params

Update the access control mode or description of an existing Sanity dataset.

NameTypeRequiredDescription
resourceobjectrequiredResource information indicating which project ID and dataset to target
aclModestringoptionalDataset access control mode: public or private.
descriptionstringoptionalHuman-readable description.
intentstringoptionalBrief description of what you are trying to accomplish.
sanitymcp_version_discard#Discard document versions associated with a release.4 params

Discard document versions associated with a release.

NameTypeRequiredDescription
idsarrayrequiredDocument IDs to discard from the release
releaseIdstringrequiredID of the release to target.
resourceobjectrequiredResource information indicating which project ID and dataset to target
intentstringoptionalBrief description of what you are trying to accomplish.
sanitymcp_version_replace_document#Replace a versioned document with the content of a source document.6 params

Replace a versioned document with the content of a source document.

NameTypeRequiredDescription
idstringrequiredSanity document ID.
releaseIdstringrequiredID of the release to target.
resourceobjectrequiredResource information indicating which project ID and dataset to target
sourceDocumentIdstringrequiredID of the source document to replace from.
typestringrequiredMust be version.replace for this operation.
intentstringoptionalBrief description of what you are trying to accomplish.
sanitymcp_version_unpublish_document#Unpublish a versioned document from a release.4 params

Unpublish a versioned document from a release.

NameTypeRequiredDescription
idstringrequiredSanity document ID.
releaseIdstringrequiredID of the release to target.
resourceobjectrequiredResource information indicating which project ID and dataset to target
intentstringoptionalBrief description of what you are trying to accomplish.
sanitymcp_whoami#Get the currently authenticated Sanity user profile.1 param

Get the currently authenticated Sanity user profile.

NameTypeRequiredDescription
intentstringoptionalBrief description of what you are trying to accomplish.