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.
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.
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 + ChatGPT
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
-
Open
https://www.sanity.io/manage, pick the project and copy its Project ID (8 characters, for exampleabc12xyz) intoSANITY_PROJECT_ID. -
Under Datasets, note the dataset to work on, usually
production, and put it intoSANITY_DATASET. -
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.
-
Copy the token into
SANITY_API_TOKEN(Sanity shows it only once) and install the connector. Check the setup withsanity_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 ChatGPT
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 showsYOUR_SERVER_ID.
ChatGPT adds MCP servers as plugins on its Plugins page, on the web and on paid plans. Developer mode is no longer needed. In a Business workspace only admins and owners can add one; in Enterprise and Edu an admin can grant the Create plugins with MCPs permission.
- Go to chatgpt.com/plugins, click +, then Add custom MCP server.
- Enter a name, e.g. Name:
Sanity. - Under Connection, enter the Server URL
https://cloud.anythingmcp.com/mcp/YOUR_SERVER_IDand keep Authentication on OAuth. - Select I understand and want to continue, then Create as a plugin. When ChatGPT asks, sign in to AnythingMCP and allow access.
- Install the new plugin from your personal plugins, then type @ in a chat and pick it.
Available tools
| Tool | What it does |
|---|---|
sanity_query | Run a GROQ query against the dataset and return its result |
sanity_list_document_types | List the document types that exist in the dataset (from _type), drafts included, e.g. post, author, sanity.imageAsset |
sanity_get_document | Read documents by id, published (post-123) or draft (drafts.post-123), with all their fields; several ids separated by commas |
sanity_get_document_revision | Read 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_transactions | List the changes (transactions) of a document: transaction id, time, author id and the kind of change (create, patch, publish, delete)… |
sanity_create_draft | Create a new document as a draft (not published). document must contain _type and _id = "drafts." + document_id, plus its fields |
sanity_patch_draft | Change fields of a document's draft with a patch, e.g. {"set": {"title": "New"}}, {"unset": ["subtitle"]}, {"setIfMissing": {"tags": []}}… |
sanity_publish_draft | Publish 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_document | Delete a published document and the drafts you list |
sanity_list_datasets | List the datasets of the project: name and whether each is public or private |
sanity_list_projects | List 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 the free ChatGPT plan work with custom MCP servers? OpenAI documents custom MCP servers for paid plans only; the Free plan is not on its list.
Next steps
Was this guide helpful?