Skip to content

Reference

Terminal window
mcp-gateway [options]
FlagEnvironment VariableDefaultDescription
--portMCP_GATEWAY_PORT3333HTTP server port
--storage-dirMCP_GATEWAY_STORAGE_DIR~/.mcp-gatewayStorage directory
N/AMCP_GATEWAY_TOKEN(auto-generated)Auth token
--helpShow help
--versionShow version
Terminal window
# Examples
mcp-gateway --port 8080
MCP_GATEWAY_TOKEN=my-secret-token mcp-gateway
DEBUG=* mcp-gateway # Enable debug logging

CLI flags override environment variables.

Bearer token required for /ui/*, /api/*, and /gateway/mcp. Proxy endpoints (/s/{name}/mcp) are unauthenticated—upstream handles its own auth.

Token is auto-generated on startup (shown in terminal) or set via MCP_GATEWAY_TOKEN.

Terminal window
# API authentication
curl -H "Authorization: Bearer YOUR_TOKEN" http://localhost:3333/api/servers
# Web UI (token in query string)
http://localhost:3333/ui?token=YOUR_TOKEN

Route MCP clients through the gateway to capture traffic:

Direct: MCP Client → http://localhost:3001/mcp → MCP Server
Proxied: MCP Client → http://localhost:3333/s/my-server/mcp → Gateway → MCP Server
SQLite Storage

Proxy URL pattern: http://localhost:3333/s/{serverName}/mcp

Example (Claude Code):

Terminal window
claude mcp add --transport http "my-server" \
"http://localhost:3333/s/my-server/mcp"

Proxy endpoints do not require authentication—upstream servers handle their own auth.

Files stored under ~/.mcp-gateway/:

~/.mcp-gateway/
├── mcp.json # Server registry
├── logs.db # SQLite traffic logs
└── logs.db-* # SQLite files

HTTP server:

{
"servers": [
{
"name": "my-server",
"type": "http",
"url": "http://localhost:3000/mcp",
"enabled": true
}
]
}

Stdio server:

{
"servers": [
{
"name": "memory",
"type": "stdio",
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-memory"],
"sessionMode": "shared",
"timeout": 30000
}
]
}
  • sessionMode: "shared" (default) or "isolated" (per x-session-id)
  • Stdio servers are long-lived; restart via UI/API

Access: http://localhost:3333/ui?token=YOUR_TOKEN

  • Activity Log — view/filter captured MCP traffic
  • Server Management — add, edit, remove servers
  • Health Status — real-time health checks
  • Export — download logs as JSONL

Updates in real-time; no manual refresh needed.

Base: http://localhost:3333/api

All endpoints require Bearer token authentication.

List registered servers with health status.

Terminal window
curl -H "Authorization: Bearer TOKEN" http://localhost:3333/api/servers

Add a server.

Terminal window
curl -X POST http://localhost:3333/api/servers \
-H "Content-Type: application/json" \
-H "Authorization: Bearer TOKEN" \
-d '{"name": "my-server", "url": "http://localhost:3001/mcp"}'

With auth headers for upstream:

{
"name": "private-api",
"url": "https://api.example.com/mcp",
"headers": { "Authorization": "Bearer SERVER_KEY" }
}

Query parameters: serverName, sessionId, method, limit (default 100), before, after

Terminal window
curl -H "Authorization: Bearer TOKEN" \
"http://localhost:3333/api/logs?serverName=my-server&limit=50"

Clear logs. Optional: ?serverName=... or ?before=2025-01-01T00:00:00Z

List active sessions.

List connected clients.

Health check.

Endpoint: http://localhost:3333/gateway/mcp (or /g/mcp)

Requires Bearer token. Any MCP client can connect to manage the gateway programmatically.

ToolDescription
add_serverAdd server (name, url, headers)
remove_serverRemove server by name
list_serversList servers (filter: all/active/inactive)
search_recordsQuery logs (serverName, sessionId, method, limit, order)