Sign inSign up

rflpazini/mcp-api-gateway

By rflpazini

•Updated 6 months ago

Image
API management
Machine learning & AI
Developer tools
0

1.9K

rflpazini/mcp-api-gateway repository overview

⁠mcp/api-gateway

Universal Model Context Protocol (MCP) server to connect any REST API (with Swagger/OpenAPI) to Claude Desktop.

No manual API calls, no Postman — just chat!

⁠🚀 Quick Start

docker run --rm -i \
  -e API_1_NAME=petstore \
  -e API_1_SWAGGER_URL=https://petstore.swagger.io/v2/swagger.json \
  -e API_1_BASE_URL=https://petstore.swagger.io/v2 \
  rflpazini/mcp-api-gateway:latest

In your claude_desktop_config.json:

{
  "mcpServers": {
    "petstore": {
      "command": "docker",
      "args": [
        "run", "--rm", "-i",
        "-e", "API_1_NAME=petstore",
        "-e", "API_1_SWAGGER_URL=https://petstore.swagger.io/v2/swagger.json",
        "-e", "API_1_BASE_URL=https://petstore.swagger.io/v2",
        "rflpazini/mcp-api-gateway:latest"
      ]
    }
  }
}

⁠🌟 Features

  • Multiple APIs via environment variables (API_1_*, API_2_*, ...)
  • Grouped tools — collapses hundreds of endpoints into resource-based tools (92% payload reduction)
  • Compact schemas — strips large enums and optional params for faster LLM processing
  • Path/tag filtering — load only the endpoints you need from large APIs
  • Cookie persistence — automatic session handling for cookie-based auth APIs
  • Retry with backoff — automatic retries on 429/5xx with exponential backoff and Retry-After support
  • Health checks — built-in check_api_health tool to verify API connectivity
  • Response truncation — large responses are automatically capped to prevent context overflow
  • Distroless runtime — minimal attack surface, non-root, Node.js 24 LTS
  • Custom headers (Authorization, API keys, etc.)
  • Works out-of-the-box with Claude Desktop
  • Also available via npx mcp-api-gateway

⁠🛠 Environment Variables

⁠Core
VariableDescriptionRequired
API_N_NAMEUnique API nameYes
API_N_SWAGGER_URLSwagger/OpenAPI spec URLYes
API_N_BASE_URLAPI base URL (overrides spec)No
API_N_HEADER_*Custom headers (e.g., API_1_HEADER_AUTHORIZATION)No
API_N_HEADERSJSON object with multiple headersNo
⁠Performance
VariableDescriptionDefault
API_N_TOOL_MODEindividual or grouped (group by resource/tag)individual
API_N_SCHEMA_MODEfull or compact (strip enums, flatten optional params)full
API_N_PATH_PREFIXComma-separated path prefixes to includeAll
API_N_TAGSComma-separated OpenAPI tags to includeAll
API_N_EXCLUDE_PARAMSComma-separated param names to stripNone
⁠Reliability
VariableDescriptionDefault
API_N_TIMEOUTRequest timeout in ms30000
API_N_MAX_RETRIESMax retries for 429/5xx errors3
MAX_RESPONSE_SIZEMax response bytes before truncation102400

⁠⚡ Performance

Tested with a 925-endpoint enterprise API:

ConfigurationToolsPayloadReduction
No optimization10932,269 KB—
SCHEMA_MODE=compact1093633 KB72%
TOOL_MODE=grouped53184 KB92%
PATH_PREFIX + compact9450 KB98%

Tip: Use API_N_TOOL_MODE=grouped for any API with more than 50 endpoints.

⁠💬 Example Commands in Claude

  • "Show me all pets."
  • "Create a new user with name John Doe."
  • "List today's orders."
  • "Is the API reachable?" (triggers health check)
  • "What APIs are configured?"

Tag summary

Content type

Image

Digest

sha256:11e2844c6…

Size

54 MB

Last updated

6 months ago

docker pull rflpazini/mcp-api-gateway