Swagger MCP 服务器
通过模型上下文协议 (MCP) 提取并提供 Swagger/OpenAPI 规范的服务器。
特征
加载 Swagger/OpenAPI 规范
支持多种认证方式:
基本身份验证
持有者令牌
API 密钥(标头或查询)
OAuth2
从 API 端点自动生成 MCP 工具
服务器发送事件 (SSE) 支持实时通信
TypeScript 支持
安全
这是个人服务器!请勿将其暴露在公共互联网上。如果底层 API 需要身份验证,则不应将 MCP 服务器暴露在公共互联网上。
待办事项
secrets - MCP 服务器应该能够使用用户的 secrets 来验证 API 请求
综合测试套件
先决条件
Node.js(v18 或更高版本)
Yarn 包管理器
TypeScript
安装
克隆存储库:
安装依赖项:
根据示例创建一个
.env
文件:
配置您的 Swagger/OpenAPI 规范:
将您的 Swagger 文件放入项目中(例如,
swagger.json
)或者提供你的 Swagger 规范的 URL
使用您的服务器设置更新
config.json
中的配置:
注意:服务器优先使用 Swagger 规范中的设置,而不是配置文件中的设置:
如果 Swagger 文件包含
servers
数组,则第一个服务器 URL 将用作基本 URL如果 Swagger 文件定义了安全方案,它们将用于身份验证
当 Swagger 文件中未指定时,配置文件设置将作为后备
用法
启动开发服务器:
为生产而构建:
启动生产服务器:
API 端点
GET /health
- 检查服务器健康状态GET /sse
- 建立服务器发送事件连接POST /messages
- 向 MCP 服务器发送消息
测试
运行测试套件:
验证
服务器支持多种身份验证方法。当 Swagger 文件中未指定这些方法时,请在config.json
文件中配置它们作为后备:
基本身份验证
持有者令牌
API 密钥
OAuth2
发展
启动开发服务器:
执照
该项目采用 Apache 2.0 许可证授权。
环境变量
PORT
:服务器端口(默认值:3000)API_USERNAME
:API 身份验证的用户名(后备)API_PASSWORD
:API 身份验证的密码(后备)API_TOKEN
:用于身份验证的 API 令牌(后备)DEFAULT_API_BASE_URL
:API 端点的默认基本 URL(后备)DEFAULT_SWAGGER_URL
:默认 Swagger 规范 URL
This server cannot be installed
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
一种服务器,能够通过模型上下文协议(MCP)与任何具有 Swagger/OpenAPI 规范的 API 进行交互,自动从 API 端点生成工具,并支持多种身份验证方法。
Related Resources
Related MCP Servers
- AsecurityAlicenseAqualityAn MCP server that connects to a Swagger specification and helps an AI to build all the required models to generate a MCP server for that service.Last updated -52177MIT License
- AsecurityFlicenseAqualityA server based on Model Context Protocol that parses Swagger/OpenAPI documents and generates TypeScript types and API client code for different frameworks (Axios, Fetch, React Query).Last updated -121216
- AsecurityAlicenseAqualityMCP server providing token-efficient access to OpenAPI/Swagger specs via MCP Resources for client-side exploration.Last updated -1052MIT License
- AsecurityAlicenseAqualityA tool that creates MCP (Model Context Protocol) servers from OpenAPI/Swagger specifications, enabling AI assistants to interact with your APIs.Last updated -3925MIT License