# Sanity MCP for AI Agents AI Agent Connect

> Sanity lets you manage your headless CMS content through an AI agent. It handles everything from running complex GROQ queries to creating and deleting documents or managing your team's access permissions. Instead of clicking through the Sanity Studio, you just tell your agent what to do.

## Overview
- **Category:** developer-tools
- **Price:** Free
- **Endpoint:** https://edge.vinkius.com/vk_preview_ACkKs6jzV4svPUkN2nvh7GZdikEWKwiWbOMvDihL/ai-agent-connect
- **Tags:** structured-content, groq, content-api, data-modeling, real-time-sync

## Description

This Connector connects your Sanity project to your AI client so you can manage content using plain English. If you're tired of navigating the Studio to find a specific document or struggling to remember the exact syntax for a GROQ query, this tool handles the heavy lifting. You can ask your agent to find all published blog posts from last month or create a new product page with specific fields. It also handles the boring stuff like creating new datasets for development, listing your image assets, and auditing project members. It's a practical way to turn your content operations into a conversation. You can find this and other high-quality connections in the Vinkius catalog to help get your data moving. You don't need to be a power user to get things done. Your agent handles the technical details of the API while you focus on the actual content.

## Tools

### list_image_assets
View your media library including filenames and dimensions. This makes managing your assets much faster.

### list_users
Get a list of everyone who has access to your project. This is perfect for quick security audits.

### search_documents
Find matching documents based on keywords and types. This is the fastest way to locate specific content.

### update_document
Change specific fields on an existing Sanity document. It only modifies the fields you tell it to change.

### create_dataset
Create a new Sanity dataset for staging or development. This helps keep your production data clean.

### create_document
Add a new document to your Sanity project with specific content. It handles the JSON structure for you.

### delete_document
Remove a specific document from your project by its ID. Use this to clear out old drafts quickly.

### get_document
Fetch the full details of a single document using its ID. It's great for inspecting content details.

### list_datasets
See all the different datasets currently in your project. This helps you stay organized across environments.

### list_documents
Browse all documents of a specific type in your dataset. Use this to see what content already exists.

### query_documents
Run a GROQ query to get specific data from your content. You don't have to worry about the exact syntax.

## Prompt Examples

**Prompt:** 
```
List all published blog posts in my Sanity project.
```

**Response:** 
```
I found 15 documents of type 'post'. The most recent include:

* **Getting Started with Sanity** (published 2 days ago)
* **GROQ Query Tips** (published last week)
* **Content Modeling Best Practices** (published 2 weeks ago)

Would you like to see the details for any of these?
```

**Prompt:** 
```
Create a new draft post titled 'API Integration Guide' with status 'draft'.
```

**Response:** 
```
Done! I've created a new document of type 'post' with the following details:

* **Title:** API Integration Guide
* **Status:** draft
* **ID:** drafts.abc123def456

It's ready for you to review in the Sanity Studio.
```

**Prompt:** 
```
Run a GROQ query to find all products with price greater than 100.
```

**Response:** 
```
I found 8 products with a price greater than $100. Here are the top results:

| Product Name | Price | Slug |
| :--- | :--- | :--- |
| **Enterprise Plan** | $499/month | enterprise-plan |
| **Pro Plan** | $199/month | pro-plan |

Let me know if you want to see the rest of the list.
```

## Capabilities

### Run GROQ queries
Execute complex data lookups using natural language.

### Create documents
Add new content items to your project with full schema support.

### Update content
Modify existing document fields instantly.

### Manage datasets
Create and list isolated content environments for different stages.

### Browse assets
Search through your media library and image files easily.

### Audit users
Check project members and their access levels in one go.

## Use Cases

### Bulk updating product statuses
A content manager asks the agent to find all products with 'out of stock' tags and update their status to 'archived' using update_document.

### Quick content audits
A developer uses query_documents to find all blog posts published in the last 48 hours to verify they have the correct metadata.

### Rapid draft creation
An editor asks the agent to create a new draft post for a holiday sale using create_document, skipping the manual Studio entry.

### Media library cleanup
A designer uses list_image_assets to see which images are currently in the library before deciding which ones to remove.

## Benefits

- Stop hunting for documents by using search_documents to find exactly what you need in seconds.
- Run complex GROQ queries using query_documents without having to write a single line of code.
- Keep your environments clean by creating new datasets with create_dataset for staging and dev.
- Update content across your site instantly using update_document to change titles, statuses, or bodies.
- Audit your project security quickly by listing all members and permissions with list_users.
- Manage your media library more efficiently by browsing image assets with list_image_assets.

## How It Works

The bottom line is you get a conversational interface for your entire Sanity content library.

1. Subscribe to the Connector and enter your Sanity Project ID, Dataset name, and API Token.
2. Connect your preferred AI client like Claude or Cursor to the Connector.
3. Ask your agent to perform tasks like fetching documents or updating content.

## Frequently Asked Questions

**How do I use the Sanity MCP with my AI agent?**
You just need to connect the Connector to your AI client using your Sanity Project ID, Dataset name, and API Token. Once connected, you can ask your agent to perform any content task in plain English.

**Can the Sanity MCP update my blog posts automatically?**
Yes, it can. You can tell your agent to update specific fields like the title, body, or status of any existing post, and it will handle the update for you.

**Can I run GROQ queries through the Sanity MCP?**
Absolutely. You can describe the data you want to see, and the Connector will execute the necessary GROQ query to pull that information for you.

**How does the Sanity MCP help with my media library?**
It allows your agent to browse and list your image assets. You can ask it to find specific files or see the dimensions of your media library content.

**Can I use the Sanity MCP to manage team permissions?**
Yes, it can list your project members. This makes it easy to audit who has access to your content and manage your team's permissions via your agent.

**Does the Sanity MCP work with Cursor or Claude?**
It works with any MCP-compatible client, including Claude, Cursor, and Windsurf. You just need to link it in your client's settings.

**How do I get a Sanity API token?**
Log in to [**manage.sanity.io**](https://manage.sanity.io), select your project, go to **API** tab, and click **Generate API token**. Choose read/write permissions and copy the token immediately.

**What is GROQ?**
GROQ (Graph-Relational Object Queries) is Sanity's query language for fetching and transforming content. It's similar to GraphQL but designed specifically for document-based content. Use the `query_documents` tool to run custom GROQ queries.

**Can I create new content types?**
Yes! Use `create_document` with any _type value (e.g. "post", "product", "author"). The document will be created with that type. Schema validation is handled by your Sanity Studio configuration, not the API.

**Can I search for documents by keyword?**
Yes! Use `search_documents` with a search term. It will search across all document fields. Optionally filter by specific document types and set a result limit. For more complex searches, use `query_documents` with custom GROQ.