MCP連携ガイド
このページは、Crate MCP を安全かつ確実に使い始めるための公開ガイドです。
2026年3月5日時点の Crate 提供仕様に合わせて記載しています。
このページで分かること
- Crate MCP の最小接続設定
- 認証方式とスコープの使い分け
- AGENTS.md/skillなしでも使える運用ガイド取得
- 利用可能な tool と必須引数
- よくあるエラーと対処
- 本番運用時のセキュリティ注意点
1. クイックスタート
{
"mcpServers": {
"crate": {
"type": "http",
"url": "https://crateio.com/api/mcp?project_id=<project_id>",
"headers": {
"x-crate-ingest-token": "<project_token>"
}
}
}
}
ポイント:
- エンドポイント:
https://crateio.com/api/mcp - 推奨認証:
x-crate-ingest-token: <project_token> - 代替認証:
Authorization: Bearer <token> project_idは URL クエリまたは tool 引数のどちらでも指定可能ingest_token/tokenのクエリ認証は廃止済み(400)
2. 認証とスコープ
スコープ一覧
| スコープ | 説明 |
|---|---|
snapshot:write | snapshot / context / continuity / reindex |
issues:read | issue 一覧の参照 |
issues:write | issue の作成・更新・削除(issues:read を内包) |
認証評価の順序
x-crate-ingest-tokenがあれば優先して認可- なければ
Authorization: Bearer ...を評価 - Bearer は「ユーザーセッショントークン」または「project token」を利用可能
3. Tool仕様
Snapshot / Continuity(snapshot:write)
| Tool | 必須引数 | 主な用途 |
|---|---|---|
create_snapshot | session_id, occurred_at, conversation_slice, client_event_id, correlation_id | 履歴を非同期保存 |
create_context | query | 履歴検索(Top3) |
get_crate_agent_guide | なし | Crate運用ガイドを取得(intent + audience で用途を切替) |
resolve_session_id | session_id(または mcp-session-id ヘッダー) | canonical codex:thread:* session_id を解決 |
resolve_repo_binding | repository または github_repo_full_name | project と GitHub repository の一致確認(複数MCP接続時の判定補助) |
get_session_log_details | session_id | project_id + session_id の共有用 session log details を read-only 取得 |
get_session_continuity | session_id | project_id + session_id の session log details と継続状態を read-only 取得 |
upsert_session_continuity | session_id, occurred_at, client_event_id, correlation_id, continuity_state または state | 継続状態の作成/更新(expected_version 対応) |
reindex_snapshots | なし | triage/evidence の再計算(保守用) |
create_snapshot の scope は since_last_snap(既定)または recent を指定できます。
create_snapshot / upsert_session_continuity / create_project_issue / delete_project_issue / complete_work_unit では Event Contract v3 のメタデータとして session_id / occurred_at / client_event_id / correlation_id が必須です。update_project_issue は session_id / occurred_at / correlation_id が必須で、client_event_id は通常必須(status=closed のみ context_label を代替根拠として許容)です。context_label / actor_context / source_context も指定できます。
get_crate_agent_guide は次を返します。
guide_version/updated_at: ガイドの版情報sections: 原則フロー/例外条件/禁止事項の構造化データrecommended_execution_order: skillなし運用時の推奨手順compact_contract: compaction耐性を高めた実行契約(format=compactで優先取得可能)session_id_canonical_form:codex:thread:<sha256_40hex>idempotency_keys:client_event_id/source_event_id/correlation_idinput_contract: MCP送信の共通必須項目・ツール別必須項目・禁止入力timeline_payload_requirements: セッションログ詳細を再構成するためのイベント種別ごとの必須payload
resolve_repo_binding は次を返します。
decision:match/mismatch/project_unboundmatches:true/false/nullcan_write_snapshot:matchのときだけtrue
resolve_session_id は次を返します。
session_id: canonicalcodex:thread:<sha256_40hex>source:mcp_session_idまたはrequested
Issues
| Tool | 必要スコープ | 必須引数 | 主な用途 |
|---|---|---|---|
list_project_issues | issues:read | なし | issue 一覧取得(status / limit で絞り込み可) |
create_project_issue | issues:write | title, session_id, occurred_at, client_event_id, correlation_id | issue 作成(初期状態は open) |
complete_work_unit | issues:write + snapshot:write | issue_id, session_id, deliverable.note, deliverable.context_label, deliverable.conversation_slice, client_event_id, correlation_id | issue 完了フローを単一操作で実行(snapshot -> checkpoint -> continuity -> close) |
update_project_issue | issues:write | issue_id, session_id, occurred_at, correlation_id(client_event_id は通常必須、status=closed 時のみ context_label 代替可) | issue 更新(status=closed は checkpoint根拠(client_event_id 優先 / context_label 代替)必須。checkpoint pending はサーバー側で短時間待機) |
delete_project_issue | issues:write | issue_id, session_id, occurred_at, client_event_id, correlation_id | issue 削除 |
Issue status は open / in_progress / closed / canceled です。
project が github_repo_full_name にバインドされている場合、write系(upsert_session_continuity / issue作成更新削除 / reindex_snapshots)は github_repo_full_name(または repository)指定が必須で、不一致は fail-closed します。
4. バリデーション仕様
session_id の形式
^[A-Za-z0-9._:@/-]{1,128}$
session系引数はサーバー側で codex:thread:<sha256_40hex> に正規化されます(resolve_session_id / create_snapshot / get_session_continuity / upsert_session_continuity / checkpoint_status / update_project_issue(status=closed) / complete_work_unit)。
mcp-session-idヘッダーがある場合:mcp-session-idを正本に正規化mcp-session-idヘッダーがない場合:session_idを同じ規則で正規化(Codex thread UUID(v7) を含む)- Event Contract v3 対象ツールでは、正規化後の
session_idがcodex:thread:<sha256_40hex>でない入力を reject する
upsert_session_continuity
client_event_idとcorrelation_idが必須occurred_atが必須continuity_state(またはstate)は object 必須- 少なくとも1つの非空フィールドが必要
expected_versionは 0 以上の整数- 競合時は
status: "version_conflict"を返却
create_snapshot の conversation_slice
- 以下の必須項目を構造化 JSON キーで含める
decision/reason/assumptions/constraints/pivots/unresolved/next_action
context_labelと参照URL(https://...)を含めるcontext_label形式はcheckpoint:<note>:<work_slug>を推奨(<note>:<work_slug>も受理)
reindex_snapshots
limit既定値:300limit上限:2000include_hidden既定値:true
get_crate_agent_guide
formatはfull/compactを指定可能(既定:full)audienceはmcp/cliを指定可能(既定:mcp)intentはgeneral/read_only/task_create/work_complete/raw_write/recovery/bootstrap_checkを指定可能(既定:general)compactは最小契約を返し、LLM compaction後の手順欠落を抑える用途向け- Event Contract v3により、クライアントは業務データを送信し、event payload の最終構築はサーバー側allowlistで行う
5. 初回導入の確認手順
list_project_issuesが成功する(issues:read以上)get_session_continuityが成功する(snapshot:write)upsert_session_continuityがstatus=createdまたはstatus=updatedを返す
この3点が通れば、MCP 接続・認証・基本権限の導線は概ね正常です。
6. エラーと対処
| エラー例 | 原因 | 対処 |
|---|---|---|
project_id is required. | project_id 未指定 | URL または tool 引数で指定 |
session_id is required and must match ... | session_id 形式不正 | 許可文字で再指定 |
ingest_token/token query parameters are no longer supported... | 廃止されたクエリ認証を利用 | x-crate-ingest-token へ移行 |
issue ... failed: status=403 | scope 不足 / 権限不足 | issues:write 付与または権限見直し |
Unauthorized (401) | 無効・失効・期限切れ token | token 再発行 |
7. セキュリティ運用の推奨
- token は最小権限で発行する(必要な scope のみ)
- token は共有しない(個人チャット・Issue本文への貼り付け禁止)
- 不要な token は速やかに失効し、定期ローテーションする
- 本番運用は HTTPS を前提にする
- 外部 MCP を併用する場合は、導入元の信頼性と権限範囲を事前確認する
8. 複数Crate MCP接続時の判定
Codex などで複数の Crate MCP が同時接続される場合は、write 実行前に次を推奨します。
git remoteからowner/repoを取得- 各 MCP に
resolve_repo_bindingを同じ repo で実行 decision=matchの接続のみ write を許可0件または複数件の場合は曖昧として中断