MCP API Gateway MCP Server

Local setup required. This server has to be cloned and prepared on your machine before you register it in Claude Code.
1

Set the server up locally

Run this once to clone and prepare the server before adding it to Claude Code.

Run in terminal
pip install aiohttp pyyaml
2

Register it in Claude Code

After the local setup is done, run this command to point Claude Code at the built server.

Run in terminal
claude mcp add mcp-api-gateway -- python "<FULL_PATH_TO_MCP_API_GATEWAY>/dist/index.js" -c config.yaml

Replace <FULL_PATH_TO_MCP_API_GATEWAY>/dist/index.js with the actual folder you prepared in step 1.

README.md

A unified local API gateway with caching, rate limiting, and MCP compatibility.

MCP API Gateway

A unified local API gateway with caching, rate limiting, and full MCP (Model Context Protocol) compatibility.

Features

  • πŸ”Œ Unified API Aggregation - Manage multiple API endpoints through a single gateway
  • πŸ’Ύ Multi-Strategy Caching - LRU, LFU, FIFO, and TTL cache eviction policies
  • ⚑ Rate Limiting - Token bucket and sliding window algorithms
  • πŸ”— MCP Protocol - Full Model Context Protocol support for AI agent integration
  • πŸ“Š Observability - Built-in statistics and metrics
  • πŸ”„ Retry Logic - Automatic retry with exponential backoff

Installation

# Clone the repository
git clone https://github.com/bandageok/mcp-api-gateway.git
cd mcp-api-gateway

# Install dependencies
pip install -r requirements.txt

# Or install directly
pip install aiohttp pyyaml

Quick Start

1. Create a Configuration File

python gateway.py --create-config

This creates a config.yaml with sample endpoints:

host: localhost
port: 8080
cache:
  enabled: true
  max_size: 1000
  ttl: 300
  strategy: lru
rate_limit:
  enabled: true
  requests_per_minute: 60
apis:
  - name: github-api
    url: https://api.github.com
    method: GET

2. Run the Gateway

# With config file
python gateway.py -c config.yaml

# Or with command line arguments
python gateway.py --host 0.0.0.0 --port 8080

3. Use the Gateway

# Call an API endpoint
curl http://localhost:8080/api/github-api/users/bandageok

# Check health
curl http://localhost:8080/health

# Get statistics
curl http://localhost:8080/stats

# Clear cache
curl -X DELETE http://localhost:8080/cache/clear

# Get configuration
curl http://localhost:8080/config

MCP Protocol Integration

The gateway provides full MCP protocol support for AI agents:

MCP Tools

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/list",
  "params": {}
}

Response:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "tools": [
      {
        "name": "github-api",
        "description": "Call GET https://api.github.com",
        "inputSchema": {
          "type": "object",
          "properties": {
            "params": {"type": "object"},
            "data": {"type": "object"}
          }
        }
      }
    ]
  }
}

Call a Tool

{
  "jsonrpc": "2.0",
  "id": 2,
  "method": "tools/call",
  "params": {
    "name": "github-api",
    "arguments": {
      "params": {"path": "/users/bandageok"}
    }
  }
}

MCP Resources

{
  "jsonrpc": "2.0",
  "id": 3,
  "method": "resources/list",
  "params": {}
}

Configuration Options

Option Type Default Description
host string localhost Host to bind to
port int 8080 Port to bind to
debug bool false Enable debug mode
log_level string INFO Logging level
cache.enabled bool true Enable caching
cache.max_size int 1000 Maximum cache entries
cache.ttl int 300 Cache TTL in seconds
cache.strategy string lru Cache strategy (lru/lfu/fifo/ttl)
rate_limit.enabled bool true Enable rate limiting
rate_limit.requests_per_minute int 60 Rate limit threshold

API Endpoints

Endpoint Method Description
/ GET Health check
/health GET Detailed health status
/stats GET Gateway statistics
/config GET Current configuration
/cache/clear DELETE Clear the cache
/api/{name} * Proxy to configured API
/mcp POST MCP protocol endpoint

Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                      MCP API Gateway                         β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚   Cache     β”‚    β”‚Rate Limiter β”‚    β”‚  MCP Handler  β”‚  β”‚
β”‚  β”‚  (LRU/LFU)  β”‚    β”‚   (Token)   β”‚    β”‚               β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                     API Client Pool                          β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚ GitHub   β”‚  β”‚ Weather  β”‚  β”‚  Stocks  β”‚  β”‚  Custom  β”‚  β”‚
β”‚  β”‚    API   β”‚  β”‚    API   β”‚  β”‚    API   β”‚  β”‚    API   β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Use Cases

1. AI Agent Integration

Connect AI agents to external APIs through MCP:

import requests

# Initialize MCP
response = requests.post("http://local

Tools (1)

github-apiCall GET https://api.github.com

Configuration

claude_desktop_config.json
{"mcpServers": {"mcp-api-gateway": {"command": "python", "args": ["gateway.py", "-c", "config.yaml"]}}}

Try it

β†’Fetch the user profile for 'bandageok' using the github-api tool.
β†’List all available tools provided by the MCP API Gateway.
β†’Check the current health status of the gateway.
β†’Retrieve the current gateway statistics.

Frequently Asked Questions

What are the key features of MCP API Gateway?

Unified API aggregation for multiple endpoints. Multi-strategy caching including LRU, LFU, FIFO, and TTL. Rate limiting using token bucket and sliding window algorithms. Full Model Context Protocol support for AI agents. Built-in observability with statistics and metrics.

What can I use MCP API Gateway for?

Connecting AI agents to external APIs through a standardized MCP interface. Managing rate limits for third-party API integrations. Caching frequent API responses to improve agent performance. Aggregating multiple disparate API services into a single local gateway.

How do I install MCP API Gateway?

Install MCP API Gateway by running: pip install aiohttp pyyaml

What MCP clients work with MCP API Gateway?

MCP API Gateway works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Turn this server into reusable context

Keep MCP API Gateway docs, env vars, and workflow notes in Conare so your agent carries them across sessions.

Need the old visual installer? Open Conare IDE.
Open Conare