一个通过Claude探索和分析Swagger/OpenAPI规范的管理控制平面(MCP)服务器。
使用npx全局安装并运行:
npx -y @johnneerdael/swagger-mcp
或者使用环境变量进行安装:
npx -y @johnneerdael/swagger-mcp \
--env BASE_URL=/api \
--env AUTH_TOKEN=your-token \
--env PORT=3000
名称: Swagger Explorer
命令: npx -y @johnneerdael/swagger-mcp
参数: --swagger-url=$SWAGGER_URL
这里是一些与Claude交互的例子:
人类: 你能探索位于http://localhost:8080/docs的Swagger文档吗?
Claude: 我会帮助你使用Swagger Explorer MCP来探索那个Swagger文档。
让我为你分析API端点和模式:
[Claude会使用MCP获取并分析Swagger文档]
人类: /pets POST端点有哪些可用的响应模式?
Claude: 我会使用MCP检查该端点的响应模式。
[Claude会使用MCP获取特定端点的详细信息]
人类: 你能展示Pet模式的详细结构吗?
Claude: 我会使用MCP检索详细的模式信息。
[Claude会使用MCP分析模式结构]
认证支持
自定义响应格式化
模式分析
API探索
环境变量:
BASE_URL:API的基本路径(默认:'')AUTH_TOKEN:用于认证的Bearer令牌PORT:服务器端口(默认:3000)SWAGGER_URL:默认的Swagger文档URLcurl -X POST http://localhost:3000/api/explore \
-H "Authorization: Bearer your-token" \
-H "Content-Type: application/json" \
-d '{
"url": "http://your-swagger-url",
"options": {
"paths": true,
"schemas": true
}
}'
curl -X POST http://localhost:3000/api/schema-details \
-H "Authorization: Bearer your-token" \
-H "Content-Type: application/json" \
-d '{
"url": "http://your-swagger-url",
"schemaName": "Pet"
}'
curl -X POST http://localhost:3000/api/response-schemas \
-H "Authorization: Bearer your-token" \
-H "Content-Type: application/json" \
-d '{
"url": "http://your-swagger-url",
"path": "/pets",
"method": "post"
}'
{
"status": "success",
"data": {
// 只有非空值
}
}
{
"status": "success",
"timestamp": "2025-01-29T10:00:00.000Z",
"data": {
// 完整响应
},
"metadata": {
"version": "1.0",
"format": "detailed"
}
}
API文档审查
人类: 你能总结所有可用的端点及其用途吗?
模式验证
人类: 创建新宠物需要哪些字段?
响应分析
人类: 登录端点可能有哪些错误响应?
集成规划
人类: 我应该如何构建请求以创建新订单?
连接问题
授权错误
模式未找到
要贡献或修改:
npm install
npm run build
npm start
MIT许可证 - 查看LICENSE文件以获取详细信息