# mcp-sanity-images [Health: Active]

**Category:** 💻 Developer Tools  
**Repository:** https://github.com/pijusz/mcp-sanity-images  
**GitHub Stars:** 1  
**Views:** 0  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/mcp-sanity-images

## Description
MCP server for uploading local images to Sanity CMS

## Tools
Capabilities this server exposes over MCP:

- **upload_image** — Upload a local image file (png, jpg, jpeg, webp, gif, svg) to Sanity as an image asset. Returns the asset ID, CDN URL, and an image `reference` object ready to set on any image field.
- **upload_and_set** — Upload a local image and set it on a field of an existing Sanity document in one call. Overwrites the current value of that field. Use groq_query first to find the document ID. The document is checked before uploading, so a wrong ID uploads nothing. The given ID is patched exactly as written (use `drafts.<id>` to patch a draft). A bare ID that has only ever existed as a draft patches `drafts.<id>`. If you patch a published document that also has a draft, the response includes a `note` saying so.
- **batch_upload** — Upload every image (png, jpg, jpeg, webp, gif, svg) in a local folder as Sanity assets. Does not patch any documents. Files that fail are reported in `failed` while the rest still upload. Returns asset IDs, URLs and ready-to-use image references.
- **list_images** — List image files (png, jpg, jpeg, webp, gif, svg) in a local directory with their sizes, so you can see what is available to upload. Does not contact Sanity.
- **groq_query** — Run a read-only GROQ query against the Sanity dataset and return the result as JSON. Useful to find document IDs and field names before upload_and_set. Uses the `raw` perspective by default, so drafts are included and every `_id` is the real stored ID (`drafts.`-prefixed for drafts) that upload_and_set can patch. Filter drafts out with `!(_id in path("drafts.**"))` or pass perspective `published`.

## Claude Desktop Quick Installation
Install path detected from listing signals. Uses `npx` (confidence: high):

```json
"mcpServers": {
  "mcp-sanity-images": {
    "command": "npx",
    "args": ["-y","sanity"],
    "env": {
      "SANITY_PROJECT_ID": "",
      "SANITY_DATASET": "",
      "SANITY_TOKEN": ""
    }
  }
}
```

**Requires environment variables:** `SANITY_PROJECT_ID`, `SANITY_DATASET`, `SANITY_TOKEN` — the values above are empty placeholders; fill in real credentials before running (see the repository for what each one is for).

## Documentation

## What mcp-sanity-images does

mcp-sanity-images gives MCP clients tools for moving local image files into Sanity CMS. It supports PNG, JPG/JPEG, WebP, GIF, and SVG files. A single upload returns the Sanity asset identifier, URL, alt text, and an image reference that can be used with a Sanity image field.

The server also combines uploading and document mutation in one operation. Given a local file, document ID, and field path, `upload_and_set` uploads the asset and patches the selected field. It can work with published documents and drafts, including draft-only documents. For larger sets of files, `batch_upload` processes every image in a directory and reports successful and failed files separately.

## How it works

The server communicates with an MCP client over stdio. It uses Sanity project credentials and dataset settings to call the Sanity API, while reading image files from paths available to the local process.

`list_images` provides a directory inventory without uploading anything. This can help an agent choose files before calling an upload tool. `groq_query` executes read-only GROQ queries, which is useful for finding document IDs before attaching assets. Queries use the `raw` perspective by default, showing published documents and drafts side by side with their relevant IDs. The `published` perspective excludes drafts, while `drafts` presents drafts as their published versions and exposes the stored draft ID through `_originalId`.

When `upload_and_set` receives a document ID, it checks published and draft variants before uploading. If neither exists, it avoids uploading and returns a document-not-found result. Mutations use synchronous visibility, allowing a subsequent GROQ query to see the change.

## Setup and configuration

The required environment variable is `SANITY_PROJECT_ID`. Set `SANITY_DATASET` to choose a dataset; it defaults to `production`. Authentication can use `SANITY_TOKEN`, or the server can read credentials from the Sanity CLI configuration after `npx sanity login`.

Install through the npm package with `npx -y mcp-sanity-images@latest`, or use `bunx mcp-sanity-images@latest`. The repository also publishes standalone binaries for macOS Apple Silicon, macOS Intel, Linux x64, and Windows x64. Configure the command and environment in an MCP client such as Claude Code or Claude Desktop, then restart the client if required by its configuration flow.

Every tool accepts `projectId` and `dataset` parameters, which override the corresponding environment values for that call. Development requires Bun and includes commands for installation, tests, linting, and standalone builds.

## Tools and capabilities

- `upload_image`: Upload one local image and return its Sanity asset data and patch-ready reference.
- `upload_and_set`: Upload an image and assign it to a document field, handling published and draft IDs.
- `batch_upload`: Upload all supported images in a directory, optionally including nested directories, while collecting failures.
- `list_images`: Enumerate supported image files in a directory without changing Sanity.
- `groq_query`: Run a read-only GROQ query with an optional `raw`, `published`, or `drafts` perspective.

## Limitations and notes

The server handles image files in the supported PNG, JPG/JPEG, WebP, GIF, and SVG formats. `groq_query` is read-only; document changes are performed through `upload_and_set`. Passing a published document ID when both a published version and a draft exist patches the published document and leaves the draft unchanged. The server pins Sanity API version `v2025-02-19` and explicitly uses `raw` as the default query perspective.

_Full upstream README: https://allmcps.com/mcp/mcp-sanity-images/readme_

