mcp-sanity-images
Uploads local images to Sanity CMS as assets, and allows patching them onto documents, running GROQ queries, and managing image assets.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Quick Start
1. Get your Sanity token
Either set the SANITY_TOKEN env var, or just log in with the Sanity CLI:
npx sanity loginThe server reads the token from the Sanity CLI config automatically (~/.config/sanity/config.json on all platforms).
2. Add to Claude Code
claude mcp add sanity-images --scope user --transport stdio \
-e SANITY_PROJECT_ID=your-project-id \
-- npx -y mcp-sanity-images@latestThat's it. Restart Claude Code and the tools are available. Every session runs the latest version automatically.
Also works with
bunx mcp-sanity-images@latestif you have Bun.
Download a pre-built binary from Releases:
Platform | File |
macOS (Apple Silicon) |
|
macOS (Intel) |
|
Linux |
|
Windows |
|
macOS / Linux:
curl -Lo mcp-sanity-images https://github.com/pijusz/mcp-sanity-images/releases/latest/download/mcp-sanity-images-darwin-arm64
chmod +x mcp-sanity-images
sudo mv mcp-sanity-images /usr/local/bin/
claude mcp add sanity-images --scope user --transport stdio \
-e SANITY_PROJECT_ID=your-project-id \
-- /usr/local/bin/mcp-sanity-imagesWindows (PowerShell):
Invoke-WebRequest -Uri "https://github.com/pijusz/mcp-sanity-images/releases/latest/download/mcp-sanity-images-windows-x64.exe" -OutFile "$env:LOCALAPPDATA\mcp-sanity-images.exe"
claude mcp add sanity-images --scope user --transport stdio -e SANITY_PROJECT_ID=your-project-id -- "%LOCALAPPDATA%\mcp-sanity-images.exe"Claude Desktop
Add to your claude_desktop_config.json:
{
"mcpServers": {
"sanity-images": {
"command": "npx",
"args": ["-y", "mcp-sanity-images@latest"],
"env": {
"SANITY_PROJECT_ID": "your-project-id"
}
}
}
}{
"mcpServers": {
"sanity-images": {
"command": "/usr/local/bin/mcp-sanity-images",
"env": {
"SANITY_PROJECT_ID": "your-project-id"
}
}
}
}{
"mcpServers": {
"sanity-images": {
"command": "%LOCALAPPDATA%\\mcp-sanity-images.exe",
"env": {
"SANITY_PROJECT_ID": "your-project-id"
}
}
}
}Related MCP server: mcp-local-image-reader
Tools
Tool | Description |
| Upload a single local image to Sanity as an asset |
| Upload an image and patch it onto a document field |
| Upload all images from a folder as assets |
| List image files in a directory |
| Run a GROQ query (find documents before attaching); optional |
Supported formats: PNG, JPG/JPEG, WebP, GIF, SVG.
Configuration
Env var | Required | Default | Description |
| Yes | — | Your Sanity project ID |
| No |
| Dataset name |
| No* | — | API token (*falls back to CLI auth) |
All tools also accept projectId and dataset as parameters, overriding the env vars per-call.
Tool Details
upload_image
Upload a single file and get back the asset reference.
filePath: "/path/to/hero.png"
alt: "Hero banner" (optional — derived from filename)Returns { assetId, url, alt, reference } — the reference is ready to patch onto any Sanity image field.
upload_and_set
Upload + patch in one call.
filePath: "/path/to/hero.png"
documentId: "product-123" # or "drafts.product-123" to patch the draft
fieldPath: "hero.image"Before uploading, the tool checks which of <id> and drafts.<id> exist, so a wrong ID uploads nothing:
You pass | Exists | Patched |
| published only |
|
| published + draft |
|
| draft only (never published) |
|
| draft |
|
anything | neither | nothing; returns "Document not found" |
The response's documentId is the document actually patched. Mutations are sent with returnIds=true&visibility=sync, so a follow-up groq_query sees the change.
batch_upload
Upload all images from a directory.
directory: "/path/to/images"
recursive: trueReturns { uploaded, assets }. If some files fail, the rest still upload and the failures are listed in failed (with failedCount).
list_images
List image files without uploading — useful for the AI to see what's available.
directory: "/path/to/images"
recursive: truegroq_query
Run any GROQ query (read-only). Long queries are sent via POST automatically. Useful to find document IDs before using upload_and_set.
query: "*[_type == 'product']{_id, title, slug}"
perspective: "raw" # optional: raw (default) | published | draftsPerspective | What the query sees |
| Published documents and drafts side by side, with their real IDs ( |
| Published documents only; drafts are invisible. |
| Every draft applied as if published. |
The server pins Sanity API version v2025-02-19. That version made published the API's default perspective. This tool sends raw unless you ask otherwise, so results match what earlier releases (API v2021-10-21, default raw) returned.
Updates
Using npx @latest (recommended): You always get the latest version — no manual updates needed.
Using a binary: The server checks for new releases on startup and logs to stderr if outdated:
[mcp-sanity-images] WARN v0.5.0 available (current: v0.4.1). Download: https://github.com/pijusz/mcp-sanity-images/releases/latestCheck your installed version:
mcp-sanity-images --versionTo update, download the new binary and replace the old one.
Development
Requires Bun.
git clone https://github.com/pijusz/mcp-sanity-images.git
cd mcp-sanity-images
bun install
bun test
bun run lint # biome check
bun run build # compile standalone binaryLicense
MIT
This server cannot be deployed
Maintenance
Related MCP Connectors
MCP server exposing the YourImageShare upload API (upload/list/delete) as tools for AI agents.
Focused MCP server for OpenAI image/audio generation (v2.0.0). Wraps endpoints via HAPI CLI.
Remote MCP server for supportsheep: run AI interviews and manage support content for your blog.
MCP server for Qwen Image 3 AI image generation
Related MCP Servers
- AlicenseAqualityCmaintenanceMCP server for uploading images to ImgBB from Claude-compatible clients.3MIT
- AlicenseAqualityDmaintenanceA simple MCP server that reads local images and returns them as ImageContent for LLM vision analysis.1MIT
- AlicenseAqualityDmaintenanceMCP server for managing personal assets (images, files) in Vercel Blob storage, enabling upload, list, metadata, delete, and copy operations.54 npmMIT
- FlicenseBqualityDmaintenanceOpenAI-compatible MCP server for running image analysis tools against your own vision model endpoint.710 npm-