Sanity MCP server
26 operations1 webhook
Sanity's Content Lake from an agent. Query documents with GROQ, create and edit drafts, publish, upload images and files, read history, run Sanity's AI Agent Actions, manage datasets and webhooks, and receive signed document webhooks.
Try Sanity with your agent
Connect Sanity, then paste this into Claude, ChatGPT or Cursor. For ideas from other apps, see the use cases.
Using Corsair, show me what you can do in Sanity on my account, then run one read-only example and show me the result.
Sanity tools and triggers
Tools are what your agent can do in Sanity through Corsair's MCP server. Triggers are the Sanity events a routine can start from.
Documents
- CreateWrite
Create a document as a draft (default) or, with publish: true, publish it at once. Returns its id and draft id.
documents.create
- DeleteDestructive
Delete up to 100 documents, published and draft together. Documents that reference them must drop the references first. With purge, they also leave the history.
documents.delete
- Discard DraftDestructive
Throw away a document's unpublished changes (its draft). The published version stays. With purge, the draft also leaves the history.
documents.discardDraft
- EditWrite
Change a document the way the Studio does: the patch goes to its draft, made from the published version if needed, and nothing goes live until documents.publish (or publish: true).
documents.edit
- GetRead-only
Fetch up to 100 documents by exact id (drafts.<id> for a draft). Ids that are missing or unreadable come back in omitted.
documents.get
- HistoryRead-only
A document as it stood at a revision or a point in time. How far back depends on the plan's history retention.
documents.history
- MutateDestructive
Apply raw Sanity mutations (create, createOrReplace, createIfNotExists, patch, delete, by id or by query) in one transaction. For anything documents.create, edit, patch and delete can't express.
documents.mutate
- PatchWrite
Patch one exact document id directly and get it back. A published id changes the live document at once; use documents.edit to go through a draft. ifRevisionId guards against overwriting someone else's change.
documents.patch
- PublishWrite
Publish a document's draft: the draft replaces the published version and goes away. Fails when there is no draft.
documents.publish
- QueryRead-only
Run a GROQ query against a dataset and get its result. Reads published documents unless perspective says otherwise. Pass user input as params.
documents.query
- TransactionsRead-only
The transactions that changed some documents: when, by whom and which revisions, optionally with each mutation.
documents.transactions
- UnpublishWrite
Take a published document off the published perspective; its content stays as a draft.
documents.unpublish
Webhooks
- AttemptsRead-only
Recent delivery attempts of a webhook with the status your endpoint answered, to debug failing deliveries.
webhooks.attempts
- CreateWrite
Create a webhook that POSTs to a URL when documents matching a GROQ filter are created, updated or deleted. Set a secret so deliveries can be verified.
webhooks.create
- DeleteDestructive
Delete a webhook; deliveries stop at once.
webhooks.delete
- ListRead-only
The project's GROQ-powered webhooks: url, dataset, filter, projection and whether each is signed (never the secret).
webhooks.list
- UpdateWrite
Change a webhook's url, filter, projection, events or secret, or pause and resume it with disabled.
webhooks.update
Agent Actions
- GenerateWrite
Have Sanity's AI write content into a document's fields from an instruction, following the schema. Writes to the draft unless forcePublishedWrite; noWrite returns it without saving. Costs one Sanity AI credit.
agentActions.generate
- PromptRead-only
Ask Sanity's AI a question, optionally about documents passed as params, and get text or JSON back. Writes nothing. Costs one Sanity AI credit.
agentActions.prompt
- TransformWrite
Have Sanity's AI rewrite a document's existing content by an instruction (tone, length, style), in place or into another document. Costs one Sanity AI credit.
agentActions.transform
- TranslateWrite
Have Sanity's AI translate a document into another language, usually into a new document. Costs one Sanity AI credit.
agentActions.translate
Datasets
- CreateWrite
Create an empty dataset in the project. Needs an administrator token.
datasets.create
- DeleteDestructive
Delete a dataset with every document and asset in it, for good. Needs the name twice and an administrator token.
datasets.delete
- ListRead-only
The project's datasets and whether each is public.
datasets.list
Assets
- UploadWrite
Upload an image or file (base64, up to 25 MB) as a Sanity asset and get its asset document and CDN URL, ready to reference from a document.
assets.upload
Schemas
- ListRead-only
The schemas deployed to a dataset: their ids (the schemaId Agent Actions take) and each type's fields. Pass type for one type's full definition. Read this before writing documents of a type you don't know.
schemas.list
Connect Sanity to Claude, ChatGPT or Cursor
- 1
Connect Sanity in Corsair
Add your Sanity API key once in Corsair. Corsair stores the credential encrypted and makes the Sanity API calls for your agent, so it never goes into a prompt or a config file. Connect Sanity
If your link lets the agent add apps, you can skip this: it gives you a sign-in link the first time it needs Sanity. On a ChatGPT personal plan, connect Sanity here first.
- 2
Add Corsair's MCP server to your agent
Every client uses the same address:
https://mcp.corsair.dev/mcpOpen Customize → Connectors → Add custom connector, paste the address, then select Connect.Add a custom MCP server with the address and choose OAuth. Personal plans get read tools only.Add to CursorOr add this to~/.cursor/mcp.json. Cursor opens Corsair to sign in the first time it connects.{ "mcpServers": { "corsair": { "url": "https://mcp.corsair.dev/mcp" } } }Run this, then run/mcpin Claude Code to sign in.claude mcp add --transport http corsair https://mcp.corsair.dev/mcpCodex, Gemini CLI, VS Code, Zed and other clients with OAuth sign-in work the same way. Clients without it, such as GitHub Copilot's coding agent, use a link's own address and an API key. Setup for every client
- 3
Sign in and choose what needs your approval
Your client opens Corsair to sign in. Pick a link: the apps your agent can use and a mode that decides what it may do without asking. In the default Cautious mode, Sanity's read and write operations run right away and its 5 destructive operations wait for your approval. Strict mode asks before every write and refuses destructive operations, and Read mode allows reads only.
FAQ
Install corsair and @corsair-dev/sanity, add the Sanity plugin, and connect with an API key. Then call methods like corsair.sanity.api.agentActions.generate() from your app. Corsair verifies webhooks, and keeps each tenant isolated.
Yes. Sanity requires an API key from your Sanity account or developer dashboard. Create credentials with access that matches what you automate, then paste them into Corsair or connect through managed auth in Hub.
Yes. One Corsair client can hit Sanity, GitHub, Notion, Stripe, and the rest. Trigger Sanity from a webhook, push updates to Slack, or chain actions across plugins. Same tenant context across integrations, plain TypeScript.
Teams use Corsair for sanity's Content Lake from an agent. Query documents with GROQ, create and edit drafts, publish, upload images and files, read history, run Sanity's AI Agent Actions, manage datasets and webhooks, and receive signed document webhooks. Common builds include sync jobs, admin tooling, and agents that call Sanity APIs from your backend. Webhook handlers react to Sanity events and fan out to Slack, email, or other plugins in the same tenant.
The SDK is open source. Self-host and you pay Corsair nothing for the integration layer. Hub bills for hosted auth and execution, not per Sanity API call. Hub has a generous free tier. For hobby projects you can probably run the whole thing on free. Paid plans start to matter with more tenants or heavier traffic.
We maintain @corsair-dev/sanity in the open repo. When Sanity ships API changes, upgrade the package. Your call sites stay typed. You should not need to rewrite the integration layer each time.
No. Corsair does not read your Sanity data or hold individual access credentials. Credentials stay in your database. API calls run on your instance. We do not store Sanity data on your behalf.
Yes. Add https://mcp.corsair.dev/mcp as a custom connector or MCP server in Claude, ChatGPT, Cursor, VS Code, Claude Code, Codex or any client that supports remote MCP servers with OAuth sign-in, then sign in to Corsair. On ChatGPT personal plans, custom servers currently get read tools only.
Yes. Put Sanity on a link in Strict mode and every write waits for your approval, while destructive actions are refused. The default Cautious mode asks only before the 5 destructive Sanity operations. You can change a link's mode at hub.corsair.dev/me.