Sanity
Give agents tools to query, create, and update content documents in Sanity through Mastra Connect. Sanity serves these tools from a hosted Model Context Protocol (MCP) server. Your application never stores Sanity credentials.
ConnectDirect link to Connect
Before you start, complete the Connect setup to install @mastra/connect and configure your platform project.
Connect an accountDirect link to Connect an account
Run this command from the directory that contains your .env file:
mastra connect add sanity-mcp
The CLI guides you through Sanity's authorization and waits until the connection is active.
Add tools to an agentDirect link to Add tools to an agent
Pass tools() to the agent and select the sanity-mcp provider:
import { Agent } from '@mastra/core/agent'
import { tools } from '@mastra/connect'
export const sanityMcpAgent = new Agent({
id: 'sanity-mcp-agent',
name: 'Sanity agent',
instructions: 'You help people query, create, and update content documents in Sanity.',
model: 'openai/gpt-6-luna',
tools: tools({ providers: ['sanity-mcp'] }),
})
Mastra discovers Sanity's tools from its MCP server when the agent runs. The available tools depend on the server and the connected account, not on your @mastra/connect version. Tool keys start with sanity-mcp_.
To see which tools Sanity provides, read the Sanity MCP server documentation. To require approval before a call runs, see MCP providers in the tools() reference.