Bruno API MCP Server

by djkz
Verified

hybrid server

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

Integrations

  • Exposes Bruno API collections as MCP tools, allowing interaction with APIs defined in Bruno collections through automatic conversion of requests to tools. Supports environment management, variable replacements, and custom request parameters.

Bruno API MCP 服务器

一个模型上下文协议 (MCP) 服务器,将 Bruno API 集合公开为 MCP 工具。此服务器允许您通过 MCP 协议与您的 Bruno API 集合进行交互,从而使您的 API 集合可供 AI 代理和其他 MCP 客户端访问。

为什么这很重要:源代码和数据协同工作

当开发人员需要集成 API 时,他们通常面临三个核心挑战:

  1. 跨系统边界调试:跨单独的代码和数据环境诊断问题需要不断进行上下文切换,这使得故障排除效率低下。
  2. 创建自定义工具:每个第三方 API 集成都需要构建和维护自定义工具,从而导致开发开销和技术债务。
  3. 构建服务 UI :为每个后端服务开发用户界面会增加复杂性和维护成本。

该服务器通过将源代码与数据并置来解决这些精确的问题。它将 Bruno API 集合转换为模型上下文协议工具,使您能够:

  • 在具有完整上下文的先前独立的环境中进行调试
  • 无需额外定制开发,即可将任何 API 转变为代理就绪工具
  • 构建可通过 AI 界面控制的无头服务

对于需要加速 API 集成同时减少维护开销的开发团队来说,这种方法从根本上改变了可能性——使以前复杂的集成变得简单易行。

特征

  • Bruno API 集合自动转换为 MCP 工具
  • 不同API配置的环境管理
  • 带有 SSE 传输的 HTTP
  • 跨域支持
  • 用于 API 集合管理的内置工具

用法

  1. 安装依赖项:
    npm install
  2. 使用您的 Bruno API 集合启动服务器:
    node --loader ts-node/esm src/index.ts --bruno-path /path/to/bruno/collection [--environment env_name] [--include-tools tool1,tool2,tool3] [--exclude-tools tool4,tool5]
    选项:
    • --bruno-path-b :Bruno API 集合目录的路径(必需)
    • --environment-e :要使用的环境名称(可选)
    • --include-tools :要包含的工具名称的逗号分隔列表,过滤掉所有其他工具(可选)
    • --exclude-tools :要排除的工具名称的逗号分隔列表(可选)

    工具过滤选项支持两种格式:

    --include-tools tool1,tool2,tool3 # Space-separated format --include-tools=tool1,tool2,tool3 # Equals-sign format
  3. 从客户端连接:
    • 本地连接: http://localhost:8000/sse
    • 从 Windows 到 WSL: http://<WSL_IP>:8000/sse
    • 使用以下命令获取您的 WSL IP: hostname -I | awk '{print $1}'

预定义脚本

该存储库包含几个用于常见用例的预定义 npm 脚本:

# Start the server with default settings npm start # Start with CFI API path npm run start:cfi # Start with local environment npm run start:local # Start with only specific tools included npm run start:include-tools # Start with specific tools excluded npm run start:exclude-tools

发展

运行测试

运行所有测试:

npm test

运行特定的测试文件:

npm test test/bruno-parser-auth.test.ts

调试

服务器使用debug库进行详细日志记录。您可以通过设置DEBUG环境变量来启用不同的调试命名空间:

# Debug everything DEBUG=* npm start # Debug specific components DEBUG=bruno-parser npm start # Debug Bruno parser operations DEBUG=bruno-request npm start # Debug request execution DEBUG=bruno-tools npm start # Debug tool creation and registration # Debug multiple specific components DEBUG=bruno-parser,bruno-request npm start # On Windows CMD: set DEBUG=bruno-parser,bruno-request && npm start # On Windows PowerShell: $env:DEBUG='bruno-parser,bruno-request'; npm start

可用的调试命名空间:

  • bruno-parser :Bruno API 集合解析和环境处理
  • bruno-request :请求执行和响应处理
  • bruno-tools :工具创建和注册到 MCP 服务器

工具

列出环境

列出 Bruno API 集合中所有可用的环境:

  • 无需参数
  • 返回:
    • 可用环境列表
    • 当前活跃的环境

回声

回显您发送的消息(对于测试有用):

  • 参数: message (字符串)

Bruno API 集合结构

您的 Bruno API 集合应遵循标准 Bruno 结构:

collection/ ├── collection.bru # Collection settings ├── environments/ # Environment configurations │ ├── local.bru │ └── remote.bru └── requests/ # API requests ├── request1.bru └── request2.bru

您收集的每个请求都将自动转换为 MCP 工具,以便通过 MCP 协议使用。

将自定义参数与工具结合使用

调用从 Bruno API 集合生成的工具时,您可以通过提供以下内容来自定义请求:

环境覆盖

您可以为特定请求指定不同的环境:

{ "environment": "us-dev" }

这将使用指定环境中的变量而不是默认变量。

变量替换

您可以覆盖单个请求的特定变量:

{ "variables": { "dealId": "abc123", "customerId": "xyz789", "apiKey": "your-api-key" } }

这些变量将在 URL、标头和请求正文中被替换。例如,如果您的请求 URL 是:

{{baseUrl}}/api/deal/{{dealId}}

并且您提供{ "variables": { "dealId": "abc123" } } ,实际使用的 URL 将是:

https://api.example.com/api/deal/abc123

查询参数

您可以直接添加或覆盖查询参数:

{ "query": { "limit": "10", "offset": "20", "search": "keyword" } }

这会将这些查询参数添加到 URL,无论它们是否在原始请求中定义。例如,如果您的请求 URL 是:

{{baseUrl}}/api/deals

并且您提供{ "query": { "limit": "10", "search": "keyword" } } ,实际使用的 URL 将是:

https://api.example.com/api/deals?limit=10&search=keyword

这种方法比使用变量覆盖查询参数更清晰、更明确。

自定义主体参数

您还可以在请求正文中提供自定义参数:

{ "body": { "name": "John Doe", "email": "john@example.com" } }

完整示例

以下是结合所有四种定制类型的完整示例:

{ "environment": "staging", "variables": { "dealId": "abc123", "apiKey": "test-key-staging" }, "query": { "limit": "5", "sort": "created_at" }, "body": { "status": "approved", "amount": 5000 } }

执照

麻省理工学院

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

将 Bruno API 集合作为模型上下文协议 (MCP) 工具公开,允许 AI 代理和 MCP 客户端与您的 API 集合进行交互。

  1. Why This Matters: Source Code and Data Working Together
    1. Features
      1. Usage
        1. Predefined Scripts
          1. Development
            1. Running Tests
            2. Debugging
          2. Tools
            1. List Environments
            2. Echo
          3. Bruno API Collection Structure
            1. Using Custom Parameters with Tools
              1. Environment Override
              2. Variable Replacements
              3. Query Parameters
              4. Custom Body Parameters
              5. Complete Example
            2. License
              ID: ethgvmsqqz