
API网关
STDIO通用MCP服务器集成任意API与Claude
通用MCP服务器集成任意API与Claude
A universal MCP (Model Context Protocol) server to integrate any API with Claude Desktop using only Docker configurations.
Add to your claude_desktop_config.json
:
{ "mcpServers": { "my-api": { "command": "docker", "args": [ "run", "--rm", "-i", "--pull", "always", "-e", "API_1_NAME=my-api", "-e", "API_1_SWAGGER_URL=https://api.example.com/swagger.json", "-e", "API_1_BASE_URL=https://api.example.com/v1", "-e", "API_1_HEADER_AUTHORIZATION=Bearer YOUR_TOKEN", "rflpazini/mcp-api-gateway:latest" ] } } }
# Clone the repository git clone https://github.com/rflpazini/mcp-api-gateway cd mcp-api-gateway # Build the image docker build -t mcp-api-gateway . # Local test docker run --rm -it \ -e API_1_NAME=test \ -e API_1_SWAGGER_URL=https://petstore.swagger.io/v2/swagger.json \ -e API_1_BASE_URL=https://petstore.swagger.io/v2 \ mcp-api-gateway
Variable | Description | Required |
---|---|---|
API_N_NAME | Unique API name | Yes |
API_N_SWAGGER_URL | Swagger/OpenAPI file URL | Yes |
API_N_BASE_URL | API base URL (overrides Swagger) | No |
API_N_HEADER_* | Custom headers | No |
API_N_HEADERS | JSON with multiple headers | No |
{ "mcpServers": { "github-api": { "command": "docker", "args": [ "run", "--rm", "-i", "-e", "API_1_NAME=github", "-e", "API_1_SWAGGER_URL=https://api.github.com/swagger.json", "-e", "API_1_HEADER_AUTHORIZATION=token ghp_xxxxxxxxxxxx", "mcp-api-gateway:latest" ] } } }
{ "mcpServers": { "company-apis": { "command": "docker", "args": [ "run", "--rm", "-i", // Users API "-e", "API_1_NAME=users", "-e", "API_1_SWAGGER_URL=https://api.company.com/users/swagger.json", "-e", "API_1_HEADER_X_API_KEY=users_key_123", // Products API "-e", "API_2_NAME=products", "-e", "API_2_SWAGGER_URL=https://api.company.com/products/openapi.yaml", "-e", "API_2_HEADER_AUTHORIZATION=Bearer products_token", // Orders API (with multiple headers) "-e", "API_3_NAME=orders", "-e", "API_3_SWAGGER_URL=https://api.company.com/orders/spec.json", "-e", "API_3_HEADERS={\"Authorization\":\"Bearer token\",\"X-Tenant\":\"company123\"}", "mcp-api-gateway:latest" ] } } }
View available APIs
Explore endpoints
Execute operations
You: "Create a new customer named Mary Smith"
Claude: "I'll create the customer for you. Using the customers API..."
{ "id": "12345", "name": "Mary Smith", "createdAt": "2024-01-15T10:30:00Z" }
"Customer Mary Smith created successfully! ID: 12345"
# Build for multiple architectures docker buildx create --use docker buildx build --platform linux/amd64,linux/arm64 \ -t your-username/mcp-api-gateway:latest \ -t your-username/mcp-api-gateway:1.0.0 \ --push .
"-e", "API_1_NAME=erp", "-e", "API_1_SWAGGER_URL=https://erp.company.local/api/swagger.json", "-e", "API_1_BASE_URL=https://erp.company.local/api", "-e", "API_1_HEADER_X_COMPANY_ID=company123", "-e", "API_1_HEADER_AUTHORIZATION=Bearer internal_token"
// Mount local Swagger file "-v", "/path/to/swagger.yaml:/swagger.yaml", "-e", "API_1_NAME=local-api", "-e", "API_1_SWAGGER_URL=file:///swagger.yaml", "-e", "API_1_BASE_URL=http://localhost:3000"
"-e", "API_1_NAME=graphql", "-e", "API_1_SWAGGER_URL=https://api.example.com/graphql-swagger.json", "-e", "API_1_BASE_URL=https://api.example.com/graphql"
# Create the secret echo "your_token_here" | docker secret create api_token - # Use in claude_desktop_config.json "args": [ "run", "--rm", "-i", "-e", "API_1_HEADER_AUTHORIZATION=Bearer $(cat /run/secrets/api_token)", "--secret", "api_token", "mcp-api-gateway:latest" ]
docker logs <container_id>
--pull always
only the first timePRs are welcome! Some ideas:
MIT License - see LICENSE file for details.