OpenAPI Contract Guard MCP
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@OpenAPI Contract Guard MCPcompare specs/v1.yaml and specs/v2.yaml"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
OpenAPI Contract Guard MCP
一个可自建、只读的 OpenAPI 契约守卫 MCP。它让 AI 客户端能够校验 OpenAPI 文档、比较两个版本、识别破坏性变更,并生成结构化变更日志。
底层差异分析使用 oasdiff,MCP 服务基于 官方 Python SDK 实现。
能力
工具 | 作用 |
| 校验允许目录内的 OpenAPI 3.x 文档 |
| 输出两个契约版本的完整结构差异 |
| 定位可能破坏现有客户端的变更 |
| 生成按严重级别分类的 API 变更日志 |
Related MCP server: OpenAPI Contracts MCP Server
安全边界
全部工具只读,不修改接口文档。
本地文件只能来自
OPENAPI_GUARD_ALLOWED_ROOTS配置的目录。只接受本地文件,拒绝 URL 和其他 URI scheme。
校验和比较均拒绝外部
$ref,避免读取未授权文件或触发 SSRF。使用参数数组启动子进程,固定
shell=False,不拼接 shell 命令。单个契约文件上限为 20 MiB,单次标准输出和错误输出各上限约 1 MB。
环境要求
下载并解压 oasdiff 后,将可执行文件加入 PATH,或通过
OASDIFF_BIN 指定绝对路径。
本地运行
git clone https://github.com/xiaohuxi/openapi-contract-guard-mcp.git
cd openapi-contract-guard-mcp
uv sync
uv run openapi-contract-guard-mcp默认使用 MCP stdio transport,适合 Codex、Claude Code、Cursor 等本地 AI 客户端。
MCP 配置
{
"mcpServers": {
"openapi-contract-guard": {
"command": "uvx",
"args": [
"--from",
"git+https://github.com/xiaohuxi/openapi-contract-guard-mcp.git",
"openapi-contract-guard-mcp"
],
"env": {
"OPENAPI_GUARD_ALLOWED_ROOTS": "/absolute/path/to/your/api-project",
"OASDIFF_BIN": "/absolute/path/to/oasdiff"
}
}
}
}Windows 可用分号配置多个允许目录,Linux 和 macOS 使用冒号:
OPENAPI_GUARD_ALLOWED_ROOTS=D:\project-a;D:\project-b未配置时,允许目录默认为 MCP 进程的当前工作目录。
使用示例
可以直接向 AI 客户端提出:
“校验
openapi.yaml是否符合 OpenAPI 规范。”“比较
specs/v1.yaml和specs/v2.yaml,列出全部差异。”“检查新版本是否包含破坏性变更,并解释影响。”
“根据两个契约版本生成发布变更日志。”
仓库内的 examples/base.yaml 和 examples/revision.yaml 可用于快速验证。
开发与测试
uv sync --group dev
uv run pytest自动化测试覆盖本地路径边界、URL scheme、外部 $ref、OpenAPI 3.x
校验、三个差异工具、无 shell 子进程调用和 MCP 工具注册。真实联调示例
能够识别删除 GET /users 为破坏性变更。
配置项
环境变量 | 默认值 | 说明 |
| 当前工作目录 | 允许读取的本地根目录列表 |
|
|
|
License
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/xiaohuxi/openapi-contract-guard-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server