GA

gomcpgo/api-wrapper-mcp

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

20 stars 11 forks 质量 48 趋势 0

为任何 API 创建 MCP 服务器

概览

这是一个模型上下文协议(MCP)的通用API包装服务器。它允许你轻松将REST API包装为MCP工具,供Claude和其他MCP客户端访问。 - 多个API端点的简易YAML配置 - 支持GET和POST请求 - 参数验证和默认值 - 通过环境变量进行认证 - API调用的自定义超时 1. 创建一个定义 API 端点的 YAML 配置文件(参见 example-config.yaml) 2.将任何必需的 API 令牌设置为环境变量 3.运行带有配置文件的服务器: 配置文件使用以下结构的YAML格式: 要配合 Claude Desktop,请在claude_desktop_config.json中添加以下内容: 可以看看 example-config.yaml 里的示例 API 配置。 - 使用auth.token_env_var字段中指定的环境变量设置主认证令牌。

概述(AI 翻译)

这是一个模型上下文协议(MCP)的通用API包装服务器。它允许你轻松将REST API包装为MCP工具,供Claude和其他MCP客户端访问。

特色

  • 多API端点的简便YAML配置
  • 支持 GET 和 POST 请求
  • 参数验证和默认值
  • 通过环境变量进行认证
  • API 调用的自定义超时

用途

  1. 创建一个定义 API 端点的 YAML 配置文件(参见 example-config.yaml)
  2. 将任何必需的 API 令牌设置为环境变量
  3. 用你的配置文件运行服务器:

配置格式

配置文件使用以下结构的YAML格式:

Claude桌面集成

要配合 Claude Desktop,请在你的 [claude_desktop_config.json 中添加以下内容:

示例

可以查看example-config.yaml,获取API配置示例。

环境变量

  • 使用auth.token_env_var字段中指定的环境变量设置主认证令牌。
  • 你也可以使用 {{env:VARIABLE_NAME}} 语法在模板中引用其他环境变量。

本页由 AI 翻译,技术细节请以原文为准。

README

API Wrapper MCP Server

This is a generic API wrapper server for the Model Context Protocol (MCP). It allows you to easily wrap REST APIs as MCP tools that can be accessed by Claude and other MCP clients.

Features

  • Easy YAML configuration for multiple API endpoints
  • Support for both GET and POST requests
  • Parameter validation and default values
  • Authentication via environment variables
  • Custom timeouts for API calls

Usage

  1. Create a YAML configuration file defining your API endpoints (see example-config.yaml)
  2. Set any required API tokens as environment variables
  3. Run the server with your config file:
# Build the server
go build -o api_wrapper

# Run with your config
./api_wrapper my-apis.yaml

Configuration Format

The configuration file uses YAML format with the following structure:

# Server info
server:
  name: "API Gateway MCP"
  description: "Generic API gateway that wraps REST APIs as MCP tools"
  version: "1.0.0"
  
# Authentication
auth:
  token_env_var: "API_GATEWAY_TOKEN"  # Environment variable for the API token

# Tool definitions
tools:
  - name: "tool-name"
    description: "Tool description"
    endpoint: "https://api.example.com/endpoint"
    method: "POST"  # or "GET"
    timeout: 30  # in seconds
    template: |
      {
        "param1": "{{variable1}}",
        "param2": {{variable2}}
      }
    # For GET requests, use query_params
    query_params:
      param1: "{{variable1}}"
      param2: "{{variable2}}"
    parameters:
      variable1:
        type: "string"
        description: "Description of variable1"
        required: true
      variable2:
        type: "number"
        description: "Description of variable2"
        default: 10

Claude Desktop Integration

To use with Claude Desktop, add the following to your claude_desktop_config.json:

{
  "mcpServers": {
    "api-wrapper": {
      "command": "path/to/api_wrapper",
      "args": ["path/to/your-config.yaml"],
      "env": {
        "API_GATEWAY_TOKEN": "your-api-token"
      }
    }
  }
}

Examples

Check out example-config.yaml for sample API configurations.

Environment Variables

  • Set the main authentication token using the environment variable specified in the auth.token_env_var field.
  • You can also reference other environment variables in your templates using {{env:VARIABLE_NAME}} syntax.
在 GitHub 查看完整 README

安装

This server does not publish a one-line install command.

Open the repository installation guide 新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "api-wrapper": { "command": "path/to/api_wrapper", "args": ["path/to/your-config.yaml"], "env": { "API_GATEWAY_TOKEN": "your-api-token" } } } }