Sanity MCP Server
Provides tools for full CRUD operations, GROQ queries, document management, reference tracking, diff, history, bulk operations, and draft status on Sanity content platform.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Sanity MCP Servershow me the last 10 published posts with their categories"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
๐ฎ Sanity MCP Server
The self-hosted Sanity MCP that Sanity deprecated. Full CRUD, atomic transactions, reference tracking, and tools the official server doesn't have.
Why This Exists
Sanity's official MCP server (@sanity/mcp-server) is archived. They want you to use their hosted solution at mcp.sanity.io with OAuth.
That's fine if you want:
OAuth flows for every AI tool
Dependency on Sanity's infrastructure
No offline or air-gapped usage
Whatever tools they decide to expose
This MCP gives you:
๐ Simple token auth โ one env var, done
๐ Self-hosted โ runs anywhere, no external dependencies
๐ ๏ธ More tools โ reference tracking, diff, history, bulk ops
โก Works offline โ no OAuth dance, no hosted service required
Related MCP server: Agentic CMS
Quick Start
npx @purple-horizons/sanity-mcpOr install globally:
npm install -g @purple-horizons/sanity-mcpMCP Configuration
Add to your Claude Desktop, Cursor, or VS Code config:
{
"mcpServers": {
"sanity": {
"command": "npx",
"args": ["@purple-horizons/sanity-mcp"],
"env": {
"SANITY_PROJECT_ID": "your-project-id",
"SANITY_DATASET": "production",
"SANITY_TOKEN": "sk-your-token"
}
}
}
}Tools
๐ Read Operations
Tool | Description |
| Execute any GROQ query |
| Fetch a single document by ID |
| List documents by type with pagination |
| Full-text search across content |
| Discover all document types |
| Get schema info for a type |
| Count documents matching a filter |
โ๏ธ Write Operations
Tool | Description |
| Create a new document |
| Replace an entire document |
| Partially update specific fields |
| Delete a document |
| Publish a draft |
| Move published to draft |
๐ Unique Tools (Not in Sanity's Official MCP)
Tool | Description |
| Find all documents referencing a given doc โ essential before deleting |
| Compare two documents โ draft vs published, or any two docs |
| Get revision history โ see who changed what |
| Atomic batch operations โ all succeed or all fail |
| Check publish state โ draft, published, or both |
What Makes This Better
1. Reference Tracking
Before you delete that image asset, you probably want to know what's using it:
sanity_references id="image-abc123"
โ Shows all 47 blog posts using that imageSanity's official MCP doesn't have this. You'd find out the hard way.
2. Document Diffing
Content editor made changes. What changed?
sanity_diff idA="drafts.post-xyz" idB="post-xyz"
โ Shows exactly which fields differSee the diff before you publish. Or compare any two documents.
3. Atomic Bulk Operations
Update 50 documents and they all need to succeed together? One transaction:
sanity_bulk operations=[
{ "patch": { "id": "post-1", "set": { "featured": true }}},
{ "patch": { "id": "post-2", "set": { "featured": false }}},
...
]
โ All or nothing. No partial states.With dryRun: true, validate before executing.
4. Draft Status at a Glance
Is there a draft? Is it published? Both?
sanity_draft_status id="post-abc123"
โ { status: "both", hasUnpublishedChanges: true }No more manually checking drafts.{id} vs {id}.
Environment Variables
Variable | Required | Default | Description |
| โ | โ | Your Sanity project ID |
| โ |
| Dataset name |
| โ | โ | API token (required for writes) |
| โ |
| API version |
Getting Your Token
Go to sanity.io/manage
Select your project โ API โ Tokens
Add new token with Editor or higher permissions
Copy and set as
SANITY_TOKEN
GROQ Examples
// All posts, newest first
*[_type == "post"] | order(_createdAt desc)
// Specific post by slug
*[_type == "post" && slug.current == "hello-world"][0]
// Posts with expanded author
*[_type == "post"]{
title,
slug,
"author": author->name,
"category": category->title
}
// Count by category
{
"total": count(*[_type == "post"]),
"published": count(*[_type == "post" && !(_id in path("drafts.**"))])
}
// Full-text search
*[_type == "post" && title match "AI*"]Development
# Clone
git clone https://github.com/Purple-Horizons/sanity-mcp.git
cd sanity-mcp
# Install
npm install
# Build
npm run build
# Test
npm test
# Run locally
npm run devComparison
Feature | This MCP | Sanity Official |
Self-hosted | โ | โ (archived) |
Simple token auth | โ | OAuth only |
Works offline | โ | โ |
Reference tracking | โ | โ |
Document diff | โ | โ |
Bulk transactions | โ | โ |
Draft status | โ | โ |
Revision history | โ | โ |
Schema discovery | โ | โ |
Full CRUD | โ | โ |
GROQ queries | โ | โ |
Release management | โ | โ |
Semantic search | โ | โ |
tl;dr: We're better for self-hosting, developer tooling, and content operations. They're better if you need releases and semantic search with embeddings.
License
MIT ยฉ Purple Horizons
Links
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
AlicenseAqualityAmaintenanceLocal-first MCP server for AI content governance. 13 tools for model/content management, validation, normalization, and i18n across any framework.214MIT- Alicense-qualityBmaintenanceOpen-source MCP server that turns any CMS backend into an AI-agent-ready content management system. It provides tools for content CRUD, idea management, and publication tracking, with safety features requiring human approval for publishing.MIT
- Alicense-qualityCmaintenanceMCP server for uploading local images to Sanity CMS. Enables AI assistants to upload files from your filesystem directly into Sanity as image assets.441MIT
- Alicense-qualityCmaintenanceProvides a sovereign, MIT-licensed MCP server for professional-service workflows, running entirely on your infrastructure with Ed25519 cryptographic signing for every action.MIT
Related MCP Connectors
MCP server for InsForge BaaS โ database, storage, edge functions, and deployments
A MCP server built for developers enabling Git based project management with project and personalโฆ
Butterbase MCP server โ manage your backend: schemas, auth, functions, storage, RAG, deploys.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/Purple-Horizons/sanity-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server