Swagger MCP 服务器

一个模型上下文协议(MCP)服务器,通过Swagger/OpenAPI文档为AI助手提供对Spring Boot后端API的访问。

  • by Pradeepmajji702
  • JavaScript
  • 本地部署
  • 更新于
在 GitHub 查看 Pradeepmajji702/MCP_SPRINGBOOT

使用说明

Swagger MCP服务器

一个模型上下文协议(MCP)服务器,通过Swagger/OpenAPI文档为AI助手提供对Spring Boot后端API的访问。

特性

  • 列出端点:从Spring Boot后端获取所有可用的API端点
  • 描述端点:获取有关特定API终结点的详细信息
  • 生成前端呼叫:React或Angular的自动生成前端API调用代码

安装

全局安装(推荐)

npm install -g @pradeepmajji702/swagger-mcp

本地安装

npm install @pradeepmajji702/swagger-mcp

配置

适用于克劳德台式机/复印机

将此添加到MCP设置配置文件中:

视窗: %APPDATA%\Code\User\globalStorage\github.copilot-chat\mcp.json
macOS/Linux: ~/.config/Code/User/globalStorage/github.copilot-chat/mcp.json

{
  "mcpServers": {
    "swagger-mcp": {
      "command": "npx",
      "args": ["-y", "@pradeepmajji702/swagger-mcp"],
      "env": {
        "SWAGGER_URL": "http://localhost:8080/v3/api-docs"
      }
    }
  }
}

重要:替换 SWAGGER_URL 使用您实际的Spring Boot Swagger文档URL。

常见的Swagger URL

  • 弹簧靴3: http://localhost:8080/v3/api-docs
  • 弹簧靴2: http://localhost:8080/v2/api-docs
  • 自定义路径: http://localhost:8080/your-app/v3/api-docs

用法

配置后,您可以询问您的AI助手:

  • “列出所有可用后端终结点”
  • “描述GET/api/用户端点”
  • “为POST/API/用户生成React API调用”
  • “显示调用登录端点的Angular代码”

可用工具

list_endpoints

列出Spring Boot后端的所有API端点。

describe_endpoint

获取特定端点的详细信息,包括参数、请求正文和响应。

参数:

  • path (字符串):API路径(例如,“/API/用户”)
  • method (string):HTTP方法(例如,“get”、“post”、“put”、“delete”)

generate_frontend_call

生成前端代码以调用特定的API终结点。

参数:

  • path (字符串):API路径
  • method (string):HTTP方法
  • framework (string):“反应”或“角度”

需求

  • Node.js>=18.0.0
  • 启用Swagger/OpenAPI的正在运行的Spring Boot应用程序

发展

# Clone the repository
git clone https://github.com/Pradeepmajji702/MCP_SPRINGBOOT.git
cd MCP_SPRINGBOOT

# Install dependencies
npm install

# Run locally
SWAGGER_URL=http://localhost:8080/v3/api-docs node server.js

出版

要将此包发布到npm:

然后发布:

npm login
npm publish --access public

许可证

麻省理工学院

贡献

欢迎投稿!请打开问题或提交拉取请求。