🔧 MCP Setup Guide

Complete Sanity + Claude Integration Tutorial
Last Updated: September 26, 2025

1. Overview

This guide documents the complete process for setting up MCP (Model Context Protocol) servers in Claude Desktop, specifically focusing on Sanity CMS integration. Based on real-world troubleshooting experience from September 26, 2025.

This guide will save you 2-3 hours of debugging time by avoiding common pitfalls!

What is MCP?

Model Context Protocol allows Claude to directly interact with external services like:

2. Prerequisites

Before You Start, You Need:

  • Claude Desktop installed (Pro recommended for all MCP features)
  • Node.js installed (v18+ recommended)
  • Sanity project created with Project ID
  • Sanity Studio installed locally
  • Admin access to generate API tokens
Some MCP servers may require Claude Pro subscription. Basic servers work on free tier.

3. Step-by-Step Setup

1Install Sanity MCP Server

Navigate to your Sanity project folder and install the MCP server:

cd C:\Users\yourname\path\to\sanity-project
npm install @sanity/mcp-server

2Generate Sanity Auth Token

  1. Go to https://www.sanity.io/manage
  2. Select your project
  3. Navigate to API → Tokens
  4. Click "Add API token"
  5. Settings:
    • Name: Claude MCP Integration
    • Permissions: Editor (not Viewer!)
  6. Copy the token immediately (you can't view it again!)
Common mistake: Using "Viewer" permissions. This will fail for write operations!

3Locate Claude Config File

The configuration file location depends on your operating system:

Operating System Config File Location
Windows C:\Users\[username]\AppData\Roaming\Claude\claude_desktop_config.json
macOS ~/Library/Application Support/Claude/claude_desktop_config.json
Linux ~/.config/Claude/claude_desktop_config.json

4Edit Configuration File

Add the Sanity configuration to your claude_desktop_config.json:

Working Configuration (What Actually Works!)
{
  "mcpServers": {
    // Keep existing servers intact!
    "desktop-commander": {
      "command": "npx",
      "args": ["-y", "@wonderwhy-er/desktop-commander@latest"]
    },
    "chroma": {
      // Your existing ChromaDB config
    },
    // Add Sanity here:
    "sanity": {
      "command": "node",
      "args": [
        "C:\\Users\\yourname\\path\\to\\project\\node_modules\\@sanity\\mcp-server\\build\\index.js"
      ],
      "env": {
        "SANITY_PROJECT_ID": "your_project_id",
        "SANITY_DATASET": "production",
        "SANITY_AUTH_TOKEN": "your_token_here"
      }
    }
  }
}
Critical: Use build/index.js not dist/index.js. Use node not npx for reliability!

5Restart Claude Desktop

This step is mandatory! Configuration changes don't hot-reload.

  1. Completely close Claude Desktop (not just minimize)
  2. Wait 5 seconds
  3. Reopen Claude Desktop
  4. Start a new chat

6Verify Connection

Check the developer settings:

  1. Press Ctrl+Shift+I (or Cmd+Option+I on Mac)
  2. Look for MCP servers section
  3. Sanity should show "running" status

4. Common Errors & Solutions

Error: "MCP sanity: Server disconnected"

This is the most common error when setting up Sanity MCP.

Causes & Solutions:

Error: "Cannot find module"

The path to the MCP server is incorrect. Verify:

// Check if the file exists:
dir C:\path\to\node_modules\@sanity\mcp-server\build\index.js

Error: "Invalid token"

Token issues can be:

5. Configuration Templates

Complete Multi-Server Configuration

Here's a complete working example with multiple MCP servers:

{
  "mcpServers": {
    "filesystem": {
      "command": "node",
      "args": ["filesystem-server-path"]
    },
    "desktop-commander": {
      "command": "npx",
      "args": [
        "-y",
        "@wonderwhy-er/desktop-commander@latest"
      ]
    },
    "chroma": {
      "command": "C:\\path\\to\\chroma-mcp.exe",
      "args": [
        "--client-type", "http",
        "--host", "localhost",
        "--port", "8000",
        "--ssl", "false"
      ]
    },
    "sanity": {
      "command": "node",
      "args": [
        "C:\\absolute\\path\\to\\node_modules\\@sanity\\mcp-server\\build\\index.js"
      ],
      "env": {
        "SANITY_PROJECT_ID": "nxz8ny4n",
        "SANITY_DATASET": "production",
        "SANITY_AUTH_TOKEN": "sk..."
      }
    }
  }
}

6. Troubleshooting Checklist

When Things Don't Work, Check:

  • Is the MCP server package installed? npm list @sanity/mcp-server
  • Is the path correct and using double backslashes?
  • Is it build/index.js not dist/index.js?
  • Are you using node not npx as the command?
  • Does the token have Editor permissions?
  • Did you fully restart Claude Desktop?
  • Are you on Claude Pro (for advanced MCP features)?
  • Is the Sanity Studio running locally?
  • Is the project ID correct?
  • Is the dataset name correct (usually "production")?

7. Pro Tips & Best Practices

Always backup your config file before editing: claude_desktop_config_backup.json

Path Handling Tips

Token Management

Debugging Process

  1. Check Claude Developer Console (Ctrl+Shift+I)
  2. Look for specific error messages
  3. Test with simpler configuration first
  4. Verify each component independently

Performance Optimization

8. Additional Resources

Official Documentation

Related Guides

Folder Structure Best Practices

MUTUAL-COGNITION-CURRENT/
├── Educational-HTML/          # Guides like this one
│   └── MCP-Setup-Guide-Sanity-Claude.html
├── broadcasting-hub/          # Sanity project
│   └── node_modules/
│       └── @sanity/
│           └── mcp-server/
├── MCP-Configs/              # Backup configs
│   ├── claude_desktop_config_working.json
│   └── troubleshooting-notes.md
└── Scripts/                  # Helper scripts
    └── test-sanity-connection.js
Remember: Configuration is stored in AppData/Roaming, not in your project folder!