Sanity
Let your AI work with your Sanity content: run GROQ queries, read documents, their revisions and change history, list document types, datasets and projects, and create, change and publish drafts after you confirm. API token with Viewer or Editor rights.
7 日間無料 · クレジットカード不要 · EU ホスト
Sanity に何でも聞ける
AnythingMCP 経由で Sanity に実際のプロンプトを試そう — Claude がツールを呼び出し、回答します。あなたのメッセージで Enter を押すと Cloud にインストールします。
Sanity を Cloud にインストールClaude は AI のため誤ることがあります。回答をご確認ください。
2 分でセットアップ
- 1cloud.anythingmcp.com で無料トライアル開始。
- 2コネクターストアで Sanity をクリック。資格情報を貼り付け。
- 3MCP API キーを発行し、AI クライアントを MCP URL に向ける。
Sanity のガイド
主要 AI クライアント向けのステップバイステップセットアップ。
Sanity のセットアップ
コネクタ定義そのものから:認証情報の入手先、必要な権限、このアダプタが呼び出す API。 コネクタ作者により英語で提供されています。
Sanity
This connector works with the content of a Sanity project (the headless CMS and Content Lake) through the official HTTP API (https://<projectId>.api.sanity.io/v2025-02-19). Its main tool runs GROQ queries against one dataset; others read a document by id, its earlier revisions and change history, list document types, datasets and projects, and create, change and publish drafts after you confirm.
Setup (about 3 minutes)
- Open https://www.sanity.io/manage, pick the project and copy its Project ID (8 characters, e.g.
abc12xyz) intoSANITY_PROJECT_ID. - Under Datasets note the dataset name (usually
production) forSANITY_DATASET. - Under API, Tokens, click Add API token, give it a name and choose the permission:
- Viewer: reads published documents and drafts, history included. Enough for every read tool; writes are refused.
- Editor: reads and writes documents. Needed for
sanity_create_draft,sanity_patch_draftandsanity_publish_draft. Avoid Developer and Administrator tokens: they can also change project settings and datasets.
- Copy the token into
SANITY_API_TOKEN(Sanity shows it once), install and runsanity_list_document_types.
Writes: confirm first, drafts by default. sanity_create_draft and sanity_patch_draft only ever write the draft (drafts.<id>), the version editors see in Sanity Studio; nothing goes live until sanity_publish_draft, which replaces the published document visitors see. Before any of them, show the user the document, the change and whether it will go live, and wait for a clear yes. Pass dry_run: true to check an action without saving. sanity_delete_document is installed switched off.
GROQ in short (sanity_query)
- Filter, then project only the fields you need, then slice:
*[_type == "post" && defined(slug.current)] | order(publishedAt desc) [0...10] {_id, title, "slug": slug.current, publishedAt}. - Always add a slice such as
[0...20]and a projection{...}: a bare*[_type == "post"]returns whole documents and is cut off at about 60 KB. - Pass values as
paramsinstead of pasting them into the query: query*[_type == $type && title match $q], params{"type": "post", "q": "launch*"}. - Count with
count(*[_type == "post"]); follow references withauthor->name; full text withtitle match "word*"; drafts have ids starting withdrafts.. - Field names come from the project's schema: look at a few documents first (
*[_type == "post"][0...3]) when you do not know them.sanity_list_document_typeslists the types. perspective:published(default) ignores drafts,draftsshows content as if all drafts were published,rawreturns published documents and drafts side by side.
How to work
sanity_list_document_types, thensanity_queryto find documents.sanity_get_documentreads documents by id (published ordrafts.<id>).- History:
sanity_list_document_transactionslists who changed a document and when (no content);sanity_get_document_revisionreturns the document as it was at a revision id or a time. - Edit:
sanity_create_draftfor a new document,sanity_patch_draftto change one (it starts the draft from the published version when there is none),sanity_publish_draftto make the draft live. - Setup questions:
sanity_list_datasetsfor this project,sanity_list_projectsfor all projects the token can see.
Rich text fields (Portable Text) are arrays of blocks; to write plain paragraphs use blocks like {"_type": "block", "_key": "a1", "style": "normal", "children": [{"_type": "span", "_key": "a2", "text": "Hello"}]}. Every array item needs a unique _key.
Common errors
- 401 Session not found: the token is wrong or was deleted.
- 403 or "Insufficient permissions": a Viewer token tried to write, or the token belongs to another project.
- 404 Dataset not found: check
SANITY_DATASET; documents that do not exist come back empty from queries and inomittedfromsanity_get_document. - 400 queryParseError: the GROQ query has a syntax error; the message shows where.
Out of scope: assets (image and file uploads), content releases and scheduled publishing, unpublishing, deleting (switched off), dataset and project management, webhooks, CORS and members, and real-time listening.
あなたの AI は Sanity から 2 クリック先。
コネクターをインストール、資格情報を貼り付け、AI に質問。7 日間無料、クレジットカード不要。