Back to MCP directory
publicPublicdnsLocal runtime

openapi_mcp_server

该项目是一个OpenAPI MCP服务器,用于为LLM提供配置好的REST API上下文,使LLM能够通过提示与REST API进行交互。

article

README

🚀 OpenAPI MCP 服务器

本项目提供 MCP - Model Context Protocol Server,该服务器配置了 REST API 作为大语言模型(LLM)的上下文,可让 LLM 与 REST API 交互,并通过 LLM 提示执行 REST API 调用,当前支持 GET/PUT/POST/PATCH 这几种 HTTP 请求方法。

🚀 快速开始

此项目将安装 MCP - Model Context Protocol Server,借助该服务器,我们能够实现 LLM 与 REST API 的交互,通过 LLM 提示执行 REST API 调用。当前支持的 HTTP 请求方法为 GET/PUT/POST/PATCH

✨ 主要特性

  • 安装 MCP - Model Context Protocol Server,为 LLM 提供配置好的 REST API 作为上下文。
  • 支持 LLM 与 REST API 交互,可通过 LLM 提示执行 REST API 调用。
  • 支持 GET/PUT/POST/PATCH 这几种 HTTP 请求方法。

📦 安装指南

安装包

pip install openapi_mcp_server

配置环境变量

在文件夹中创建 .env 文件,设置必要的值以配置 OPENAPI_SPEC_PATHAPI_BASE_URL。示例文件可在此处下载 这里

测试服务器

使用以下命令测试 openapi_mcp_server 服务器:

uv run openapi_mcp_server

💻 使用示例

Claud 桌面配置

{
    "mcpServers": {
        "openapi_mcp_server":{
            "command": "uv",
            "args": ["run","openapi_mcp_server"],
            "env": {
                "DEBUG":"1",
                "API_BASE_URL":"https://petstore.swagger.io/v2",
                "OPENAPI_SPEC_PATH":"https://petstore.swagger.io/v2/swagger.json",
                "API_HEADERS":"Accept:application/json",
                "API_WHITE_LIST":"addPet,updatePet,findPetsByStatus"
            }
        }
    }
}

宠物商店示例

配置说明

| 属性 | 详情 | |------|------| | DEBUG | 启用调试日志记录(可选,默认为 False) | | OPENAPI_SPEC_PATH | OpenAPI 文档路径(必需) | | API_BASE_URL | API 请求的基础 URL(必需) | | API_HEADERS | 包含在 API 请求中的头信息(可选) | | API_WHITE_LIST | 白名单操作 ID 列表(格式为 ["operationId1", "operationId2"],可选) | | API_BLACK_LIST | 黑名单操作 ID 列表(格式为 ["operationId3", "operationId4"],可选) | | HTTP_PROXY | HTTP 代理信息(可选) | | HTTPS_PROXY | HTTPS 代理信息(可选) | | NO_PROXY | 无代理信息(可选) |

📚 详细文档

UV 命令使用

mkdir -m777 openapi_mcp_server
cd openapi_mcp_server
uv init
uv add mcp 协议 协议、协议、协议
uv sync
uv run
uv build
  • uv init:初始化项目。
  • uv add [依赖项...]:添加所需的依赖项。例如,运行 uv add openapi-spec 协议 可能会自动添加 OpenAPI 相关的依赖项。
  • uv sync:同步代码。
  • uv run:运行服务器。
  • uv build:构建项目。

这些命令帮助开发者快速初始化、配置和部署 MCP 服务器,确保所有依赖项已正确安装,并且代码处于最新状态。通过这种方式,用户可以轻松地将服务器集成到现有的开发环境中,并进行进一步的自定义和扩展。

📄 许可证

本项目根据 MIT 许可证的条款进行许可。

反馈与支持

如果在使用过程中遇到任何问题或需要进一步的支持,请随时查阅项目文档或联系维护人员。您的反馈对我们改进项目非常宝贵!

smithery badge Star History Chart

help

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client