OpenAPI MCP Server

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

OpenAPI MCP 服务器

一个模型上下文协议 (MCP) 服务器,它将 OpenAPI 端点公开为 MCP 资源。此服务器允许大型语言模型通过 MCP 协议发现并交互 OpenAPI 规范定义的 REST API。

快速入门

您无需克隆此存储库即可使用此 MCP 服务器。您只需在 Claude Desktop 中配置它即可:

  1. 找到或创建您的 Claude Desktop 配置文件:
    • 在 macOS 上: ~/Library/Application Support/Claude/claude_desktop_config.json
  2. 添加以下配置以启用 OpenAPI MCP 服务器:
{ "mcpServers": { "openapi": { "command": "npx", "args": ["-y", "@ivotoby/openapi-mcp-server"], "env": { "API_BASE_URL": "https://api.example.com", "OPENAPI_SPEC_PATH": "https://api.example.com/openapi.json", "API_HEADERS": "Authorization:Bearer token123,X-API-Key:your-api-key" } } } }
  1. 将环境变量替换为您的实际 API 配置:
    • API_BASE_URL :API 的基本 URL
    • OPENAPI_SPEC_PATH :OpenAPI 规范的 URL 或路径
    • API_HEADERS :API 身份验证标头的逗号分隔键值对

开发工具

该项目包括几个开发工具,可以让您的工作流程更轻松:

建筑

  • npm run build - 构建 TypeScript 源
  • npm run clean - 删除构建工件
  • npm run typecheck - 运行 TypeScript 类型检查

开发模式

  • npm run dev - 监视源文件并在发生更改时重建
  • npm run inspect-watch - 运行检查器并在发生更改时自动重新加载

代码质量

  • npm run lint - 运行 ESLint
  • npm run typecheck - 验证 TypeScript 类型

配置

可以通过环境变量或命令行参数配置服务器:

环境变量

  • API_BASE_URL - API 端点的基本 URL
  • OPENAPI_SPEC_PATH - OpenAPI 规范的路径或 URL
  • API_HEADERS - API 标头的逗号分隔键值对
  • SERVER_NAME - MCP 服务器的名称(默认值:“mcp-openapi-server”)
  • SERVER_VERSION - 服务器版本(默认值:“1.0.0”)

命令行参数

npm run inspect -- \ --api-base-url https://api.example.com \ --openapi-spec https://api.example.com/openapi.json \ --headers "Authorization:Bearer token123,X-API-Key:your-api-key" \ --name "my-mcp-server" \ --version "1.0.0"

开发工作流程

  1. 启动开发环境:
npm run inspect-watch
  1. src/中的 TypeScript 文件进行更改
  2. 服务器将自动重建并重启
  3. 使用 MCP 检查器 UI 测试您的更改

调试

服务器会将调试日志输出到 stderr。要查看这些日志,请执行以下操作:

  1. 在开发模式下:
    • 运行inspect-watch的终端中会出现日志
  2. 直接运行时:
    npm run inspect 2>debug.log

贡献

  1. 分叉存储库
  2. 创建功能分支
  3. 进行更改
  4. 运行测试和 linting:
    npm run typecheck npm run lint
  5. 提交拉取请求

执照

麻省理工学院

-
security - not tested
F
license - not found
-
quality - not tested

一种服务器,使大型语言模型能够通过模型上下文协议发现并与 OpenAPI 规范定义的 REST API 交互。

  1. Quick Start
    1. Development Tools
      1. Building
      2. Development Mode
      3. Code Quality
    2. Configuration
      1. Environment Variables
      2. Command Line Arguments
    3. Development Workflow
      1. Debugging
        1. Contributing
          1. License
            ID: org9aj8cva