Official Sanity headless CMS MCP server
## Sanity CMS MCP Server: Real-Time Content Platform The **Sanity CMS MCP Server** integrates Sanity.io into Google Antigravity, enabling real-time content collaboration with GROQ queries, portable text, and live preview directly from your development environment. ### Why Sanity CMS MCP? - **Real-Time Collaboration**: Multiple editors working simultaneously - **GROQ Queries**: Powerful query language for content - **Portable Text**: Rich text that works everywhere - **CDN Delivery**: Global content delivery with asset pipeline - **Custom Studio**: Fully customizable editing experience ### Key Features #### 1. GROQ Queries ```python # Query documents result = await mcp.query(""" *[_type == "post" && status == "published"] | order(publishedAt desc) [0...10] { _id, title, slug, excerpt, "authorName": author->name, "categoryTitle": category->title, mainImage { asset-> { url } } } """) for post in result: print(f"Post: {post['title']}") ``` #### 2. Document Management ```python # Create document doc = await mcp.create( _type="post", title="New Post", slug={"current": "new-post"}, body=[ {"_type": "block", "children": [{"_type": "span", "text": "Content..."}]} ] ) # Update document await mcp.patch( id=doc["_id"], set={"title": "Updated Title"} ) # Delete document await mcp.delete(id="doc_123") ``` #### 3. Asset Management ```python # Upload image image = await mcp.upload_image( file_path="./images/cover.jpg" ) # Use in document await mcp.patch( id="post_123", set={ "mainImage": { "_type": "image", "asset": {"_ref": image["_id"]} } } ) ``` #### 4. Real-Time Listening ```python # Listen for changes async for event in mcp.listen( query="*[_type == 'post']", include_result=True ): print(f"Change: {event['transition']} - {event['result']['title']}") ``` ### Configuration ```json { "mcpServers": { "sanity": { "command": "npx", "args": ["-y", "@anthropic/mcp-sanity"], "env": { "SANITY_PROJECT_ID": "your-project-id", "SANITY_DATASET": "production", "SANITY_API_TOKEN": "your-api-token" } } } } ``` ### Use Cases **Collaborative Editing**: Enable teams to edit content simultaneously. **Headless Commerce**: Build e-commerce with rich product content. **Media Sites**: Manage complex media relationships and assets. **Multi-Platform Apps**: Power apps with consistent content across platforms. The Sanity CMS MCP enables real-time content management within your development environment.
{
"mcpServers": {
"sanity": {
"mcpServers": {
"sanity": {
"url": "https://mcp.sanity.io",
"type": "streamable-http"
}
}
}
}
}