Setup
Build a Knowledge Base, create an MCP endpoint and set the three environment variables.
- 1
Enable Knowledge Bases
An organisation admin turns them on from the Labs page in Sanity Manage.
- 2
Build a Knowledge Base
Create one from your docs dataset and give it a refresh schedule.
- 3
Create an MCP endpoint
Point it at the Knowledge Base and copy its URL.
- 4
Set the environment variables
apps/web/.envAI_GATEWAY_API_KEY=your-gateway-key SANITY_CONTEXT_MCP_URL=https://api.sanity.io/v1/context/organizations/<orgId>/mcp/<name> SANITY_ORGANIZATION_TOKEN=your-org-token