Mcp Sanity Images

io.github.pijusz由 GitHub 帳號 pijusz 發布v0.3.7更新於 Nov 3, 2026

MCP server for uploading local images to Sanity CMS

已驗證STDIO僅桌面檔案與儲存媒體與設計

概覽

AI 產生的概覽

本機 MCP 伺服器,讓助理把本機圖片上傳到 Sanity CMS 成為資源,並掛到文件欄位上。

可以做什麼
  • 上傳單張本機圖片到 Sanity,取回資源參照
  • 一次呼叫完成上傳並把圖片寫入文件欄位
  • 批次上傳某個資料夾中的所有圖片,並另外列出失敗項目
  • 列出目錄中的圖片檔案而不上傳
  • 執行唯讀 GROQ 查詢,在掛圖前找出文件 ID
適用情境
適合圖片存放在本機、希望由助理推送到 Sanity 資料集並寫入內容欄位的情境,例如不開 Sanity Studio 就為產品或文章補圖。
執行需求
透過 npx、bunx 或預先編譯的執行檔(macOS、Linux、Windows)以 stdio 在本機執行。需要 SANITY_PROJECT_ID,SANITY_DATASET 預設為 production。API 權杖從 SANITY_TOKEN 或 Sanity CLI 登入設定讀取。需要連線到 Sanity 的網路。
安裝前請注意
該權杖具備 Sanity 專案的寫入權限,應視為機密。上傳與文件修補會改動線上內容;upload_and_set 可能修改已發布文件,並可能讓草稿不同步。批次上傳會把所選資料夾中的所有圖片送到 Sanity。使用 npx @latest 會一律拉取最新版本。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Mcp Sanity Images,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

[MCPi sanity-images]

MCP server for uploading local images to Sanity CMS.
Lets AI assistants upload files from your filesystem directly into Sanity as image assets.


Quick Start

1. Get your Sanity token

Either set the SANITY_TOKEN env var, or just log in with the Sanity CLI:

bash
npx sanity login

The server reads the token from the Sanity CLI config automatically (~/.config/sanity/config.json on all platforms).

2. Add to Claude Code

bash
claude mcp add sanity-images --scope user --transport stdio \  -e SANITY_PROJECT_ID=your-project-id \  -- npx -y mcp-sanity-images@latest

That's it. Restart Claude Code and the tools are available. Every session runs the latest version automatically.

Also works with bunx mcp-sanity-images@latest if you have Bun.

Alternative: standalone binary

Download a pre-built binary from Releases:

PlatformFile
macOS (Apple Silicon)mcp-sanity-images-darwin-arm64
macOS (Intel)mcp-sanity-images-darwin-x64
Linuxmcp-sanity-images-linux-x64
Windowsmcp-sanity-images-windows-x64.exe

macOS / Linux:

bash
curl -Lo mcp-sanity-images https://github.com/pijusz/mcp-sanity-images/releases/latest/download/mcp-sanity-images-darwin-arm64chmod +x mcp-sanity-imagessudo 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-images

Windows (PowerShell):

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:

Using npx (auto-updates)
json
{  "mcpServers": {    "sanity-images": {      "command": "npx",      "args": ["-y", "mcp-sanity-images@latest"],      "env": {        "SANITY_PROJECT_ID": "your-project-id"      }    }  }}
Using binary (macOS / Linux)
json
{  "mcpServers": {    "sanity-images": {      "command": "/usr/local/bin/mcp-sanity-images",      "env": {        "SANITY_PROJECT_ID": "your-project-id"      }    }  }}
Using binary (Windows)
json
{  "mcpServers": {    "sanity-images": {      "command": "%LOCALAPPDATA%\\mcp-sanity-images.exe",      "env": {        "SANITY_PROJECT_ID": "your-project-id"      }    }  }}

Tools

ToolDescription
upload_imageUpload a single local image to Sanity as an asset
upload_and_setUpload an image and patch it onto a document field
batch_uploadUpload all images from a folder as assets
list_imagesList image files in a directory
groq_queryRun a GROQ query (find documents before attaching); optional perspective (raw default, published, drafts)

Supported formats: PNG, JPG/JPEG, WebP, GIF, SVG.

Configuration

Env varRequiredDefaultDescription
SANITY_PROJECT_IDYes—Your Sanity project ID
SANITY_DATASETNoproductionDataset name
SANITY_TOKENNo*—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 draftfieldPath: "hero.image"

Before uploading, the tool checks which of <id> and drafts.<id> exist, so a wrong ID uploads nothing:

You passExistsPatched
product-123published onlyproduct-123
product-123published + draftproduct-123, with a note that the draft was left alone (Studio shows the draft, and publishing it overwrites the field)
product-123draft only (never published)drafts.product-123, with a note and requestedDocumentId
drafts.product-123draftdrafts.product-123
anythingneithernothing; 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: true

Returns { 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: true

groq_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 | drafts
PerspectiveWhat the query sees
raw (default)Published documents and drafts side by side, with their real IDs (drafts.-prefixed for drafts). Pass these IDs straight to upload_and_set.
publishedPublished documents only; drafts are invisible.
draftsEvery draft applied as if published. _id is always the published ID (even for never-published drafts); the stored ID is in _originalId.

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/latest

Check your installed version:

bash
mcp-sanity-images --version

To update, download the new binary and replace the old one.

Development

Requires Bun.

bash
git clone https://github.com/pijusz/mcp-sanity-images.gitcd mcp-sanity-imagesbun installbun testbun run lint      # biome checkbun run build     # compile standalone binary

License

MIT

來源:README.md,提交 835c357

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v0.3.7最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分