API包装器
STDIO将REST API转换为MCP工具的通用包装器
将REST API转换为MCP工具的通用包装器
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.
example-config.yaml)# Build the server go build -o api_wrapper # Run with your config ./api_wrapper my-apis.yaml
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
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" } } } }
Check out example-config.yaml for sample API configurations.
auth.token_env_var field.{{env:VARIABLE_NAME}} syntax.