Connector guide5-minute read11 MCP tools7 languages

How to Connect Sanity to Claude via MCP

Let your AI work with your Sanity content: run GROQ queries, read documents, their revisions and change history, list document types, datasets and projects, and create, change and publish drafts after you confirm. API token with Viewer or Editor rights.

HCBy HelpCode teamUpdated 5 min read Open-source on GitHub

No credit card · 7-day trial · Self-host alternative available

Sanity

Sanity

Let your AI work with your Sanity content: run GROQ queries, read documents, their revisions and change history, list document types, datasets and projects, and create, change and publish drafts after you confirm. API token with Viewer or Editor rights.

tools

11

Region

INTL

Category

CMS

Authentication

Bearer Token

Required env vars

SANITY_PROJECT_IDSANITY_DATASETSANITY_API_TOKEN
Install in one click on Cloud

7-day free trial · No credit card

  • 7-day free trial
    No credit card required
  • GDPR & SOC 2 ready
    EU data residency, audit logs
  • Open-source on GitHub
    Open source · AGPL-3.0
  • Works with ChatGPT, Claude, Gemini
    Any MCP-compatible client

Skip the install. Get this working in under 2 minutes.

Start a free trial on cloud.anythingmcp.com, add the Sanity in one click, then point your AI client (Claude, ChatGPT, Copilot or Cursor) at the generated MCP endpoint. No Docker, no git clone, zero engineering experience required.

Start free trial

AnythingMCP is listed in Claude's connector directory: add it to Claude in one click (opens in a new tab), then sign in and choose which MCP servers Claude may use.

Summary

Let your AI work with your Sanity content: run GROQ queries, read documents, their revisions and change history, list document types, datasets and projects, and create, change and publish drafts after you confirm. API token with Viewer or Editor rights.

Try asking

Example prompts for Sanity

Click any prompt to copy it. Paste into Claude, ChatGPT, Cursor, Gemini, Copilot or OpenClaw to run it against this connector.

Sanity · live via MCP
Share
Opus 4.7

Claude is AI and can make mistakes. Please double-check responses.

💡 No install? Use cloud.anythingmcp.com directly. Sign in, click Connectors → Sanity, paste your credentials, mint an MCP API key and you're done. No Docker, no git clone, no local server.

Sanity + Claude

Let your AI work with your Sanity content: run GROQ queries, read documents, their revisions and change history, list document types, datasets and projects, and create, change and publish drafts after you confirm. API token with Viewer or Editor rights.

Prerequisites

See the full setup instructions baked into the connector (visible in the in-app store when you select the connector). The required environment variables for this connector are:

SANITY_PROJECT_ID, SANITY_DATASET, SANITY_API_TOKEN

Step 1 — Get credentials

  1. Open https://www.sanity.io/manage, pick the project and copy its Project ID (8 characters, for example abc12xyz) into SANITY_PROJECT_ID.

  2. Under Datasets, note the dataset to work on, usually production, and put it into SANITY_DATASET.

  3. Under API → Tokens, click Add API token, give it a name and choose the permission:

    • Viewer reads published documents and drafts, history included. Enough for every read tool; writes are refused.
    • Editor also writes. Needed to create, change and publish drafts.

    Avoid Developer and Administrator tokens: they can also change project settings and datasets.

  4. Copy the token into SANITY_API_TOKEN (Sanity shows it only once) and install the connector. Check the setup with sanity_list_document_types.

GROQ queries: sanity_query runs GROQ against your dataset, so the AI can answer questions such as "which posts have no SEO description" or "how many products are out of stock" in one call. It asks only for the fields it needs, limits the number of results because answers over about 60 KB are cut off, and passes values as parameters. When it does not know your schema yet, it lists the document types and looks at a few documents first. With the drafts perspective it reads the content as if all drafts were published.

Drafts first, live only after your yes: sanity_create_draft and sanity_patch_draft only ever write the draft, the version editors see in Sanity Studio. Nothing reaches your site until sanity_publish_draft, which replaces the published document. Before each of them the AI shows you the document, the change and whether it will go live, and waits for a clear yes. A dry run checks an action without saving it. sanity_delete_document is installed switched off.

History: sanity_list_document_transactions shows who changed a document and when, and sanity_get_document_revision returns the document as it was at a revision or a point in time, for example to compare two versions or to recover text that was overwritten.

Rich text: Portable Text fields are arrays of blocks, and every block needs a unique _key. The connector tells the AI how to write plain paragraphs.

Common errors: 401 Session not found: the token is wrong or was deleted. 403 Insufficient permissions: a Viewer token tried to write, or the token belongs to another project. 404 Dataset not found: check SANITY_DATASET. 400 queryParseError: the GROQ query has a syntax error, and the message shows where.

Not covered: image and file uploads, content releases and scheduled publishing, unpublishing, dataset and project management, webhooks, CORS, members and real-time listening.

Step 2 — Install the adapter

curl -fsSL https://raw.githubusercontent.com/HelpCode-ai/anythingmcp/main/docker-compose.quickstart.yml -o docker-compose.yml
printf 'JWT_SECRET=%s\nENCRYPTION_KEY=%s\n' "$(openssl rand -hex 32)" "$(openssl rand -hex 32)" > .env
docker compose up -d

Step 3 — Add the connector in Claude

Your server URL: in AnythingMCP, open MCP Servers → the server this connector is on, and copy its URL (https://cloud.anythingmcp.com/mcp/…). Use it wherever this guide shows YOUR_SERVER_ID.

Recommended path: works on claude.ai web without editing any config file.

  1. In Claude, open Customize → Connectors.
  2. Click +, then Add custom connector.
  3. Enter a name, e.g. Sanity, and the remote MCP server URL https://cloud.anythingmcp.com/mcp/YOUR_SERVER_ID, then click Add.
  4. Click Connect and sign in to AnythingMCP (OAuth) to allow access.

All tools below appear in your chat: start typing prompts.

Available tools

ToolWhat it does
sanity_queryRun a GROQ query against the dataset and return its result
sanity_list_document_typesList the document types that exist in the dataset (from _type), drafts included, e.g. post, author, sanity.imageAsset
sanity_get_documentRead documents by id, published (post-123) or draft (drafts.post-123), with all their fields; several ids separated by commas
sanity_get_document_revisionRead a document as it was in the past: at a revision id (_rev, from sanity_list_document_transactions), at a point in time, or its last…
sanity_list_document_transactionsList the changes (transactions) of a document: transaction id, time, author id and the kind of change (create, patch, publish, delete)…
sanity_create_draftCreate a new document as a draft (not published). document must contain _type and _id = "drafts." + document_id, plus its fields
sanity_patch_draftChange fields of a document's draft with a patch, e.g. {"set": {"title": "New"}}, {"unset": ["subtitle"]}, {"setIfMissing": {"tags": []}}…
sanity_publish_draftPublish a document's draft: the draft replaces the published version and goes live on every site that reads this dataset, and the draft is…
sanity_delete_documentDelete a published document and the drafts you list
sanity_list_datasetsList the datasets of the project: name and whether each is public or private
sanity_list_projectsList the Sanity projects the token can see: id, name, studio host and creation date

Example prompts

  • "Which blog posts were published in the last 30 days? Show title, author and slug."
  • "Find every product whose description is empty or shorter than 50 characters."
  • "Who changed the pricing page last, and what did it say before that change?"
  • "Fix the typo 'recieve' in the title of the post about our spring launch. Save it as a draft and show me the change before you save it."
  • "Publish the draft of the post 'Release notes October'. Tell me exactly what goes live first."

FAQ

Does it work with Claude Code as well as Claude Desktop? Yes, point both at https://cloud.anythingmcp.com/mcp/YOUR_SERVER_ID.

Next steps

Was this guide helpful?

Your Sanity agent is one click away.

Install the connector, paste the key, prompt Claude. Free for 7 days, no credit card.

Related guides

Connectors

How to Connect Sanity to ChatGPT via MCP

Let your AI work with your Sanity content: run GROQ queries, read documents, their revisions and change history, list document types, datasets and projects, and create, change and publish drafts after you confirm. API token with Viewer or Editor rights.

Connectors

How to Connect Sanity to Cursor via MCP

Let your AI work with your Sanity content: run GROQ queries, read documents, their revisions and change history, list document types, datasets and projects, and create, change and publish drafts after you confirm. API token with Viewer or Editor rights.

Connectors

How to Connect Sanity to Gemini via MCP

Let your AI work with your Sanity content: run GROQ queries, read documents, their revisions and change history, list document types, datasets and projects, and create, change and publish drafts after you confirm. API token with Viewer or Editor rights.

Connectors

How to Connect Sanity to Meta Muse via MCP

Let your AI work with your Sanity content: run GROQ queries, read documents, their revisions and change history, list document types, datasets and projects, and create, change and publish drafts after you confirm. API token with Viewer or Editor rights.

Connectors

Sanity to MCP: GROQ Queries and Draft Editing for any AI Agent

Let your AI work with your Sanity content: run GROQ queries, read documents, their revisions and change history, list document types, datasets and projects, and create, change and publish drafts after you confirm. API token with Viewer or Editor rights.

Connectors

How to Connect Avito to Claude via MCP

Let your AI work with your Avito business account: list your ads and change their prices, read views, contacts and calls statistics, check autoload uploads and their errors, the feed format and your wallet, and read Avito Messenger chats. Sending messages and changing autoload settings are optional and off by default.