Skip to main content
Glama

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

入力

出力

list_endpoints

tag?

エンドポイント表 メソッド / パス / 要約(キー+要約)+ データソース注記

get_endpoint

method, path

エンドポイント詳細:認証、パラメータ表、request body($ref は1層のみインライン化)、responses

get_schema

name

schema 属性表 + ネストした $ref のドリルダウンキー

select

patterns?, security?, tag?, schema_glob?

一括選択:認証列を含むエンドポイントキー表 + 一致する schema 名(横断集計、例「すべての認証エンドポイント」)

get_batch

keys, include_refs?

一括下層探索:混合キーを一度に全詳細取得、参照された 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)

変数

デフォルト

説明

OPENAPI_URL

http://localhost:8000/openapi.json

実行時 spec(優先)。/docs ドキュメントページの URL を直接指定可能:自動で spec を発見(Swagger UI url: / ReDoc spec-url を抽出)、発見失敗時は同一オリジンの /openapi.json → /openapi.yaml にフォールバック

OPENAPI_FILE

空

フォールバック spec ファイルパス(実行時に到達不能な場合に使用)

OPENAPI_TIMEOUT

2.0

取得タイムアウト(秒)

  • 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 tools
get_batchA
Read-only

批量获取端点详情与 schema 属性表,引用的 schema 自动整合为共享附录(去重)。keys 混合 "METHOD /path" 端点键与 schema 名(去重后 ≤40 个);键从 list_endpoints / select 获得。

Inputs: keys (required), include_refs. Returns: result

get_endpointA
Read-only

获取单个端点的 markdown 详情(鉴权、参数、请求体、响应)。method 大小写不敏感;键从 list_endpoints 获得。

Inputs: path (required), method (required). Returns: result

get_schemaA
Read-only

获取单个 schema 的属性表与嵌套下钻键。schema 名从 get_endpoint 输出的 → get_schema(Name) 获得。

Inputs: name (required). Returns: result

list_endpointsA
Read-only

列出 API 全部端点(方法/路径/摘要表)。了解 API 全貌的第一步;需要细节时用 get_endpoint / get_schema 按键下钻。

Inputs: tag. Returns: result

selectA
Read-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

    A4.1/5.0

    Scored across 5 tools

    Disambiguation5/5

    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.

    Naming Consistency4/5

    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.

    Tool Count5/5

    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.

    Completeness4/5

    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

    Related MCP Servers

    • A
      license
      Not graded
      quality
      B
      maintenance
      Exposes 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 npm
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Lets 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.
      3
      27 npm
      MIT