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 + Microsoft Copilot
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 Microsoft Copilot
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.
Microsoft Copilot uses MCP servers through agents built in Copilot Studio: you add AnythingMCP to an agent as a tool, then publish the agent to Microsoft 365 Copilot and Teams. Copilot Studio connects from Microsoft's cloud over Streamable HTTP, which AnythingMCP supports.
- In Copilot Studio, open your agent (or create one), go to Tools and choose Add a tool → New tool → Model Context Protocol.
- Enter a Server name (for example
AnythingMCP), a Server description that says what the connector does, and the Server URLhttps://cloud.anythingmcp.com/mcp/YOUR_SERVER_ID. Copilot Studio uses the description to decide when to call the server. - Under authentication, choose API key, set Type to Header and the header name to
X-API-Key, then select Create. - In Add tool, choose Create a new connection, paste an MCP API key from AnythingMCP (MCP Servers → your server → API keys) and select Add to agent.
- Try it in the agent's Test pane: ask for something that needs the
Sanitytools. - Select Publish, then Channels → Microsoft 365 and Microsoft Teams, keep Make agent available in Microsoft Copilot selected and choose Add channel. See agent in Teams installs it for you; in Microsoft 365 Copilot, type @ and pick the agent.
Prefer per-user sign-in? Choose OAuth 2.0 → Dynamic discovery instead of an API key: each user then signs in to AnythingMCP the first time the agent calls it.
Self-hosting? Use your instance's public HTTPS address instead of https://cloud.anythingmcp.com. Copilot Studio connects from Microsoft's cloud, so localhost does not work.
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
Which Copilot is this for? Microsoft 365 Copilot at work, through agents built in Copilot Studio. The Microsoft Copilot app for personal accounts has no option to add your own MCP server.
What do I need? A work account with access to Copilot Studio (a license or a trial) to build the agent. People who use it in Microsoft 365 Copilot or Teams need access to the agent: share it with them, or ask an admin to publish it to the organization. If your organization applies data policies to Power Platform connectors, they cover MCP servers too.
The agent doesn't call the tools. Check that the header name is exactly X-API-Key and that the key belongs to the same MCP server as the URL, and make the server description specific: Copilot Studio uses it to decide when to call the server. Publish the agent again after each change; in an open chat, type "start over" to get the new version.
Next steps
- Connector landing page
- Connect to Claude
- Connect to ChatGPT
- Connect to Cursor
- Connect to Gemini
- Connect to Meta Muse
Was this guide helpful?