# Sanity MCP for AI Agents AI Agent Connect

> Sanity MCP. Manage your Sanity Content Lake via AI. Execute GROQ queries, manage documents, and handle media assets directly from your agent. It turns your AI into a headless CMS power user, letting you perform bulk updates and complex data queries without leaving your chat window.

## Overview
- **Category:** developer-tools
- **Price:** Free
- **Endpoint:** https://edge.vinkius.com/vk_preview_kOcJmNXuW6tXc9VymiA6CmKfU4tOyRvWsv6XMmO3/ai-agent-connect
- **Tags:** groq-queries, structured-content, document-management, schema-modeling, content-lake, api-driven

## Description

Connect your Sanity project to your AI agent to manage your Content Lake through natural conversation. Usually, managing a headless CMS means jumping between tabs, writing raw GROQ queries, and manually checking every document type. This Connector changes that by letting you talk directly to your content. You can pull specific data, update fields across dozens of records at once, or grab a list of your media assets without leaving your chat interface. Instead of hunting for IDs or wrestling with JSON structures in a separate tab, you just describe the change or the query you want. It's like having a headless CMS expert sitting next to you, handling the heavy lifting of data manipulation. When you find it in the Vinkius catalog, you'll see how it bridges the gap between your content and your AI workflow, making it much faster to prototype new content types or perform bulk updates that would normally take hours of clicking. You can quickly audit your schema, verify content counts, or even run raw mutations for complex migrations. It takes the friction out of content management by putting the power of your Sanity project directly into your chat window.

## Tools

### get_document_details
Pull the full details of a specific document using its unique ID. This is perfect for checking all the fields of a single record.

### list_typed_documents
Get a list of all documents for a specific type like post or author. This helps you quickly see what content is already in your project.

### run_raw_mutation
Run raw Sanity mutations to handle complex, multi-document transactions. Use this for heavy lifting like migrating data or bulk updates.

### wipe_cms_document
Permanently delete a document from your CMS when it's no longer needed. This is a quick way to clean up your content lake.

### count_entity_nodes
See exactly how many documents of a specific type exist in your dataset. Use this to get a quick count of your records without opening the Studio.

### list_unique_schema_types
Retrieve a list of every unique document type currently in your project. This is great for auditing your schema to ensure consistency.

### create_cms_document
Create a new document by providing the type and a JSON object of attributes. You can use this to quickly add new content to your project.

### list_media_assets
See all images and file assets currently uploaded to your Sanity project. Use this to find and organize your media without browsing every folder manually.

### patch_cms_document
Update specific fields in an existing document using a JSON object. This allows you to make precise edits to your content without manual clicking.

### run_groq_query
Execute a GROQ query to fetch exactly the data you need from your content lake. This lets you pull custom data sets for your frontend or reports.

## Prompt Examples

**Prompt:** 
```
List all unique schema types in my dataset.
```

**Response:** 
```
I checked your schema types. Your dataset contains the following 5 types:

* `post`
* `author`
* `category`
* `product`
* `siteSettings`

Would you like to know how many documents exist for a specific type?
```

**Prompt:** 
```
Write a GROQ query to find the 3 most recently updated authors.
```

**Response:** 
```
I executed the GROQ query `*[_type == 'author'] | order(_updatedAt desc)[0...3]`.

The most recently updated authors are:
1. **Sarah Chen**
2. **Marcus Rivera**
3. **Alex Nguyen**

Should I retrieve their full biographical details?
```

**Prompt:** 
```
Update the post with ID 'drafts.1234' and set its published state to true.
```

**Response:** 
```
I've successfully patched document `drafts.1234`.

* The field `isPublished` is now set to `true`.
* The change is immediately live in your **Content Lake**.
```

## Capabilities

### Run GROQ queries
Fetch specific data from your Content Lake using Graph-Relational Object Queries.

### Edit documents
Create, update, or delete any document type in your Sanity project.

### Audit schemas
List all unique document types and count how many records exist for each.

### Manage media
Browse and organize your image and file assets directly through your agent.

### Execute bulk mutations
Run raw Sanity mutations to handle complex, multi-document transactions.

## Use Cases

### Bulk Editing
A content editor needs to change the isPublished status for 20 draft posts. They ask the agent to patch those specific IDs using patch_cms_document to save time.

### Data Auditing
A developer wants to know how many author documents exist in the production dataset. They use count_entity_nodes to get the number instantly without opening a browser.

### Content Migration
A manager needs to see all unique types in a new project to map out the content strategy. They use list_unique_schema_types to get a full list of the project types.

### Query Testing
A dev wants to test a complex GROQ query for a new frontend component. They use run_groq_query to see the results in the chat before they write any frontend code.

## Benefits

- Faster Data Retrieval: Use run_groq_query to pull specific content without writing and testing code in a separate environment. This lets you get exactly what you need in seconds.
- Bulk Content Updates: Use patch_cms_document to update multiple fields across your project in a single turn. You can handle dozens of records at once without manual clicking.
- Schema Auditing: Quickly see your project structure with list_unique_schema_types to ensure your data model is consistent. It helps you find every document type in your project.
- Easy Media Management: Use list_media_assets to find and organize your images without digging through the Sanity Studio UI. This saves you from manual folder browsing.
- Rapid Prototyping: Use create_cms_document to spin up new content types and test them instantly during development. You can build out new features much faster.

## How It Works

The bottom line is you get a direct line to your Sanity Content Lake inside your AI chat.

1. Subscribe to the Sanity MCP and open your preferred AI client.
2. Provide your Sanity Project ID, Dataset, API Version, and API Token.
3. Ask your agent to query content, update documents, or list your media assets.

## Frequently Asked Questions

**What can I do with the Sanity MCP?**
You can manage your Sanity Content Lake using natural language. This includes running GROQ queries, creating or updating documents, and managing your media assets directly through your AI client.

**How does the Sanity MCP handle bulk updates?**
It allows you to perform multi-document transactions. You can ask your agent to patch specific fields across multiple records at once, saving you from manual entry in the Studio.

**Can I use the Sanity MCP to query my content?**
Yes. You can execute GROQ queries to fetch specific data. This is great for checking content stats or pulling specific information for your project.

**Does the Sanity MCP work with my existing Sanity project?**
Yes, it connects to your existing Sanity Content Lake. You just need to provide your Project ID, Dataset, and API credentials to get started.

**Can I manage images with the Sanity MCP?**
You can use it to list all image and file assets in your project. This helps you quickly find and organize your media without browsing every folder manually.

**Is the Sanity MCP good for developers?**
It's a great tool for developers who need to audit schema types or run quick data migrations. It lets you prototype queries and manage content types much faster.

**Can my AI agent write complex GROQ queries for me?**
Yes. If you know what data you want but aren't totally familiar with GROQ syntax, you can simply ask your agent: 'Write and execute a GROQ query to find all author documents where the name starts with John and return just their ID and bio.' The agent will draft the query, execute it via the `run_groq_query` tool, and return the filtered JSON.

**How do I perform a bulk update on my documents?**
You can ask your agent to first fetch the documents (e.g., 'List all posts missing a category'), calculate the changes needed, and then use the `run_raw_mutation` tool or `patch_cms_document` iteratively to apply the updates. This acts as a conversational migration script, updating dozens of documents safely and quickly.

**Can the agent check if media assets are missing from my posts?**
Yes. The agent can use the document querying tools combined with `list_media_assets` to analyze your content. For instance, you can ask it to generate a report of all products that do not have an associated image reference, giving you an exact list of items to fix in the Studio.