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、responses |
|
| schema 属性表 + 嵌套 |
|
| 批量圈键(横向聚合,如「所有鉴权端点」) |
|
| 批量下探,引用的 schema 整合为去重附录 |
单键下钻用 get_endpoint / get_schema;横向问题先 select 圈键再 get_batch 一次取回。
下钻键 = METHOD /path 或 schema 名,从上层输出直接获得;键与 pattern 的完整文法见 KEYS.md。
快速开始
Claude Code 用户级注册(一次注册,所有仓库可用):
claude mcp add openapi-md -s user -- \
uv run --directory /path/to/openapi-md-mcp openapi-md-mcpOPENAPI_URL 指向目标项目的 /docs 或 /openapi.json(其他数据源在各自项目级 .mcp.json 覆盖),完整一轮:
select(patterns=["* /v1/scoring/*"]) # 圈键:键表 + 匹配 schema 名
get_batch(["GET /v1/scoring/credit", # 下探:引用 schema 自动进附录
"POST /v1/scoring/batch", "CreditBatchRequest"])不确定路径形态就先不带 patterns 调 select() 拿全表,照表中「方法 + 路径」两列拼 pattern——表即素材,照抄必中。
配置(env)
变量 | 默认 | 说明 |
|
| 运行时 spec;可直接填 |
| 空 | 兜底 spec 文件路径(运行时不可达时使用) |
|
| 拉取超时(秒) |
spec 支持 JSON 与 YAML,进程内缓存 60s;请求直连不走系统代理(目标是 localhost / 内网 spec);只读,不提供调用 API 的能力。
开发
uv sync # 安装依赖
uv run pytest --cov=openapi_md_mcp # 测试(fixture 为真实 OpenAPI 3.1 快照)协议合规(MCP 2026-07-28):五工具均声明 readOnlyHint: true;错误按规范 §Tools Error Handling 抛 isError=true 并附自纠建议,零匹配是成功文本。
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