openapi-md-mcp
openapi-md-mcp
OpenAPI spec を段階的開示(progressive disclosure)して markdown にする MCP server。
なぜ
Swagger UI(
/docs)は JS シェルで、AI が内容を取得できない/openapi.jsonは全体で数十 K tokens になり、コンテキストに丸ごと入れるのは高コスト本ツールは AI の常駐コンテキストを「キー + 要約」のエンドポイント表のみ(~1k tokens)に抑え、 キーでドリルダウンして単一エンドポイント / 単一 schema の markdown 詳細を取得。実測で約 90% のコンテキストを節約
Related MCP server: openapi-spec-mcp
ツール面(渐进的开示、出力はすべて markdown)
tool | 入力 | 出力 |
|
| エンドポイント表 |
|
| エンドポイント詳細:認証、パラメータ表、request body($ref は1層のみインライン化)、responses |
|
| schema 属性表 + ネストした |
|
| 一括選択:認証列を含むエンドポイントキー表 + 一致する schema 名(横断集計、例「すべての認証エンドポイント」) |
|
| 一括下層探索:混合キーを一度に全詳細取得、参照された schema は自動で重複排除した付録に統合 |
ドリルダウンキー = METHOD /path または schema 名で、上位の出力から直接取得できます。
バッチモード(select + get_batch)
単一キーのドリルダウンでは横断的な質問(「すべての認証エンドポイント」は個別に get_endpoint を数十回行う必要がある)に答えられないため、
バッチ層で補完します:
select(patterns=["GET /v1/auth/*", "* /v1/scoring/*"], security="X-Service-Token", tag="scoring", schema_glob="Credit*")patterns の要素は
"METHOD /path/glob"形式:メソッドは*可(大文字小文字を区別しない);パス glob は大文字小文字を区別securityは scheme 名;patterns 間は OR、security/tag とは ANDゼロ一致は成功テキストを返す(利用可能な scheme / tag + 緩和の提案)、エラーではない
get_batch(["POST /v1/scoring/credit", "CreditBatchRequest"])キーは重複排除して順序保持、上限 40 個;レンダリング総文字数上限 100k、超過時は
include_refs=Falseまたは分割を推奨include_refs=Trueはレンダリング中に参照された$refを自動で「共有 schema 付録」に統合(各名前は1回のみレンダリング)
設定(env)
変数 | デフォルト | 説明 |
|
| 実行時 spec(優先)。 |
| 空 | フォールバック spec ファイルパス(実行時に到達不能な場合に使用) |
|
| 取得タイムアウト(秒) |
spec は JSON と YAML に対応;ロード後はプロセス内に 60 秒キャッシュ
リクエストは直接接続(
trust_env=False):対象は localhost / 内ネットワークの spec で、システムプロキシを経由しない(macOS のシステムプロキシは localhost を 502 に乗っ取るため)読み取り専用で、API 呼び出し機能は提供しない(認証ヘッダーは MCP 層に入らない)
任意のリポジトリへの接続
Claude Code ユーザーレベル登録(一度登録すれば全リポジトリで利用可能):
claude mcp add openapi-md -s user -- \
uv run --directory /path/to/openapi-md-mcp openapi-md-mcp異なるデータソースが必要なリポジトリは、各プロジェクトレベルの .mcp.json で env を上書きするだけです。
プロトコル準拠(MCP 2026-07-28、通称 2.0)
ツール名 / 説明 / inputSchema は仕様 §Tools に準拠(名前の文字セットと長さ、決定論的な
tools/list順序)5 ツールすべてが
annotations.readOnlyHint: true(読み取り専用)を宣言エラー意味論は仕様 §Tools Error Handling に準拠:spec ロード失敗、不明なキー(類似キーの提案を含む)、 不正なフィルターパターンとバッチ上限超過は Tool Execution Error として
ToolErrorをスロー → オンライン上ではCallToolResult(isError=true)として現れ、クライアントは提案をモデルにフィードバックして自己修正;ゼロ一致は成功テキスト;call(API 呼び出し)機能は提供しないバージョン交渉:stdio は initialize ハンドシェイクエポック(最大 2025-11-25);2026-07-28 のステートレス エンベロープエポックは SDK が HTTP トランスポート層で処理(
server/discover)、stdio シナリオでは関与しない
開発
uv sync # 安装依赖
uv run pytest --cov=openapi_md_mcp # 测试(fixture 为真实 OpenAPI 3.1 快照)Available Tools
5 toolsget_batchARead-only
批量获取端点详情与 schema 属性表,引用的 schema 自动整合为共享附录(去重)。keys 混合 "METHOD /path" 端点键与 schema 名(去重后 ≤40 个);键从 list_endpoints / select 获得。
Inputs: keys (required), include_refs. Returns: result
get_endpointARead-only
获取单个端点的 markdown 详情(鉴权、参数、请求体、响应)。method 大小写不敏感;键从 list_endpoints 获得。
Inputs: path (required), method (required). Returns: result
get_schemaARead-only
获取单个 schema 的属性表与嵌套下钻键。schema 名从 get_endpoint 输出的 → get_schema(Name) 获得。
Inputs: name (required). Returns: result
list_endpointsARead-only
列出 API 全部端点(方法/路径/摘要表)。了解 API 全貌的第一步;需要细节时用 get_endpoint / get_schema 按键下钻。
Inputs: tag. Returns: result
selectARead-only
按 glob 模式与鉴权 / tag 过滤批量选中端点键与 schema 名(含鉴权列的键表)。patterns 元素形如 "GET /v1/*"(方法可为 *、大小写不敏感);零匹配返回可用条件提示。选中后用 get_batch 批量取详情。
Inputs: tag, patterns, security, schema_glob. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 5 tools
Each tool is clearly anchored to a distinct stage of the workflow: overview, single endpoint details, single schema details, bulk selection, and bulk retrieval. There is no meaningful overlap between the five operations.
The names mostly follow a clear verb_noun pattern, with list_endpoints for the collection and get_endpoint / get_schema for individual items. The bare 'select' and the somewhat generic 'get_batch' are minor deviations from the otherwise consistent style.
Five tools form a tight, well-scoped set for navigating OpenAPI documents: overview, detail, schema access, filtering, and batch retrieval. Each tool has a clear purpose and none feel redundant.
The main exploration workflow is complete: list endpoints, inspect endpoint and schema details, filter selections, and batch fetch. A dedicated way to enumerate all schemas up front would be a minor improvement, but the select/get_batch flow provides a workable path.
Related MCP Connectors
Same functionality, consuming only 1/20 of the context window tokens.
Provide your AI coding tools with token-efficient access to up-to-date technical documentation for…
Schema-aware API monitoring: diff OpenAPI specs for breaking changes, manage endpoints.
Remote MCP gateway for 20-folder Obsidian vaults in TOON format (-36.7% to -45% LLM tokens).
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables LLMs to explore and query OpenAPI specifications, allowing natural language interaction with API endpoints, parameters, request bodies, and response schemas from any OpenAPI 3.x spec.16 npmMIT
- FlicenseNot gradedqualityDmaintenanceTurns any OpenAPI/Swagger spec into queryable tools for LLMs, enabling endpoint search, detail retrieval, and schema exploration.1-
- AlicenseNot gradedqualityBmaintenanceExposes an OpenAPI catalog as tools for AI agents (e.g., Claude Code, Cursor) to query API endpoints via list_endpoints and get_endpoint tools, enabling interactive API exploration without a browser.39 npmMIT
- AlicenseAqualityBmaintenanceLets AI coding agents retrieve a single endpoint at a time from an OpenAPI or Swagger specification as a compact, schema-resolved summary — with searchable endpoint listings — instead of downloading or reading the entire spec document.327 npmMIT