MCP 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
make setup
make run
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 -e "GATEWAY_API_KEYS_FILE=${GATEWAY_API_KEYS_FILE}" -e "GATEWAY_UPSTREAM_CONFIG_FILE=${GATEWAY_UPSTREAM_CONFIG_FILE}" mcp-gateway-2c10 -- python "<FULL_PATH_TO_MCP_GATEWAY>/dist/index.js"

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

Required:GATEWAY_API_KEYS_FILEGATEWAY_UPSTREAM_CONFIG_FILE+ 2 optional
README.md

Unified entry point for AI agents implementing the Model Context Protocol

MCP Gateway

Production-ready unified entry point for AI Agents and downstream APIs, implementing the Model Context Protocol (MCP).


Quick Start (Local — 5 minutes)

Prerequisites

Tool Minimum Version Check
Python 3.10+ python3 --version
pip 23+ pip3 --version
make any make --version
Docker (optional) 24+ docker --version

macOS: Install Python via Homebrew: brew install python@3.12 Windows: Install Python from python.org, then use make via WSL or Git Bash.


Option A — Run with Python directly (recommended for development)

# 1. Clone / open the project folder
cd mcp-gateway

# 2. One-command setup (creates virtualenv + installs deps + copies .env)
make setup

# 3. Start the gateway
make run

The gateway starts at http://localhost:8080.

Open the interactive API docs at http://localhost:8080/docs.


Option B — Run with Docker Compose (full stack)

# Starts gateway + Redis + Prometheus + Grafana + Jaeger
make docker-up
Service URL
Gateway API http://localhost:8080
API Docs http://localhost:8080/docs
Grafana http://localhost:3000 (admin/admin)
Prometheus http://localhost:9091
Jaeger (traces) http://localhost:16686

Manual Setup (step by step)

If you prefer not to use make:

# 1. Create virtual environment
python3 -m venv .venv
source .venv/bin/activate          # macOS/Linux
# .venv\Scripts\activate           # Windows

# 2. Install dependencies
pip install -e ".[dev]"

# 3. Copy environment config
cp .env.example .env

# 4. Create log directory
mkdir -p logs

# 5. Start the gateway
uvicorn src.main:app --host 0.0.0.0 --port 8080 --reload

Configuration

All configuration is in the .env file (copied from .env.example during setup).

Key settings

# Auth — who can call the gateway
GATEWAY_AUTH_ENABLED=true
GATEWAY_API_KEYS_FILE=config/api_keys.json      # your API keys

# Upstream APIs — what the gateway proxies to
GATEWAY_UPSTREAM_CONFIG_FILE=config/upstreams.json

# Rate limiting
GATEWAY_RATE_LIMIT__DEFAULT_RPM=60             # requests per minute per identity
GATEWAY_RATE_LIMIT__BURST_ALLOWANCE=10

# Debug / dev mode
GATEWAY_DEBUG=true
GATEWAY_ENVIRONMENT=development

Add your own upstream API

Edit config/upstreams.json:

[
  {
    "name": "my-api",
    "url": "https://api.example.com",
    "description": "My downstream API",
    "upstream_token": "your-bearer-token-here",
    "timeout_seconds": 30,
    "tags": ["internal"]
  }
]

Add an API key

Edit config/api_keys.json:

[
  {
    "key": "my-secret-key-001",
    "owner": "your-name",
    "allowed_upstreams": [],
    "rate_limit_rpm": -1,
    "scopes": ["read", "write"]
  }
]

Try It Out

Once the gateway is running, open a new terminal and try these:

Health check (no auth required)

curl http://localhost:8080/health

List configured upstreams

curl http://localhost:8080/upstreams \
  -H "X-Api-Key: dev-key-alice-001"

Send an MCP initialize request

curl -X POST http://localhost:8080/mcp \
  -H "Content-Type: application/json" \
  -H "X-Api-Key: dev-key-alice-001" \
  -d '{
    "version": "1.0",
    "request": {
      "jsonrpc": "2.0",
      "id": 1,
      "method": "initialize",
      "params": {
        "protocolVersion": "2024-11-05",
        "clientInfo": {"name": "my-agent", "version": "1.0"}
      }
    }
  }'

Register an AI agent (get a session token)

curl -X POST http://localhost:8080/agents/register \
  -H "Content-Type: application/json" \
  -H "X-Api-Key: dev-key-alice-001" \
  -d '{
    "agent_name": "my-llm-agent",
    "agent_version": "1.0.0",
    "requested_upstreams": [],
    "requested_scopes": ["read", "write"]
  }'

Use agent token to call MCP

# Replace <token> with the token from the register response
curl -X POST http://localhost:8080/mcp \
  -H "Content-Type: application/json" \
  -H "X-Agent-Token: <token>" \
  -d '{
    "request": {
      "jsonrpc": "2.0",
      "id": 2,
      "method": "tools/list"
    }
  }'

Proxy directly to an upstream

curl -X POST http://localhost:8080/mcp/notion \
  -H "Content-Type: application/json" \
  -H "X-Api-Key: dev-key-alice-001" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'

Common Commands

make run           # Start gateway (http://localhost:8080)
make run-reload    # Start with hot-reload (auto-restarts on code change)
make test          # Run all tests
make test-unit     # Run unit tests only
make lint          # Lint code with ruff
make format        # Auto-format code
make typecheck     # Type check with mypy
make docker-up     # Start full stack (gateway + Redis + monitoring)
make dock

Tools (1)

mcp-proxyProxies MCP requests to downstream APIs with authentication and rate limiting.

Environment Variables

GATEWAY_AUTH_ENABLEDEnable or disable authentication for the gateway
GATEWAY_API_KEYS_FILErequiredPath to the JSON file containing API keys
GATEWAY_UPSTREAM_CONFIG_FILErequiredPath to the JSON file containing upstream API configurations
GATEWAY_RATE_LIMIT__DEFAULT_RPMDefault requests per minute per identity

Configuration

claude_desktop_config.json
{ "mcpServers": { "mcp-gateway": { "command": "python", "args": ["/path/to/mcp-gateway/src/main.py"], "env": { "GATEWAY_AUTH_ENABLED": "true" } } } }

Try it

List all available upstream APIs configured in the gateway.
Register a new AI agent named 'research-bot' to access the gateway.
Send an MCP initialize request to the gateway to start a session.
Call the 'tools/list' method on the upstream notion API through the gateway.

Frequently Asked Questions

What are the key features of MCP Gateway?

Unified entry point for AI agents and downstream APIs. Built-in rate limiting per identity. Authentication management via API keys. Observability integration with Prometheus, Grafana, and Jaeger. Support for proxying MCP requests to multiple downstream services.

What can I use MCP Gateway for?

Centralizing access to multiple internal AI tools and APIs. Securing AI agent access to sensitive downstream services. Monitoring and throttling AI agent traffic in production. Standardizing MCP communication across different agent architectures.

How do I install MCP Gateway?

Install MCP Gateway by running: make setup && make run

What MCP clients work with MCP Gateway?

MCP 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 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