mcp-gateway
mcp-gateway is a lightweight, production-ready gateway for the Model Context Protocol (MCP). It provides unified routing, authentication, logging, and rate limiting for multiple MCP servers, simplifying access for LLM agents and clients. It is designed for developers who need to securely expose and manage multiple MCP tools behind a single HTTP endpoint.
✨ Key features
- Unified routing with automatic tool discovery on startup.
- API key authentication with per-key tool and server allowlists.
- Token bucket rate limiting with configurable burst support.
- LRU response cache with TTL to reduce upstream load.
- SQLite logging of every tool call with timing and truncation.
- Supports stdio, SSE, and HTTP upstream transports.
🎯 Use cases
- Expose multiple local MCP servers (e.g., filesystem, GitHub) to LLM agents via a single authenticated HTTP API.
- Add rate limiting and caching to MCP tool calls to protect upstream servers.
- Centralize logging and monitoring of MCP tool usage across an organization.
- Build a secure gateway for remote MCP servers accessed by cloud-based agents.
📦 Installation
🧰 Requirements: Requires Node.js and npm. No external accounts or API keys are needed to run the gateway itself, but upstream MCP servers must be configured.
npm install -g @niclaw/mcp-gatewaynpm install @niclaw/mcp-gateway🚀 Usage
mcpx start --config ./config.yamlmcpx list-toolsmcpx logs --tail 50mcpx config validate⚠️ Good to know
The project is in early development (version 0.1.0) and has a roadmap with planned features like WebSocket transport, tool namespacing, and health monitoring that are not yet implemented.
❓ FAQ
How do I configure the gateway?
Copy config.example.yaml to config.yaml and edit it with your upstream MCP servers and API keys. The configuration supports environment variable substitution like ${VAR} or ${VAR:-default}.
What authentication methods are supported?
The gateway supports API key authentication via Bearer token or X-API-Key header. Each key can have allowlists for specific tools and servers.
Can I use the gateway programmatically?
Yes, you can import the Gateway class from '@niclaw/mcp-gateway' and use methods like start(), listTools(), callTool(), and getStats() directly.
How do I view logs?
Use the CLI command 'mcpx logs' to view logs from the SQLite database. You can filter by tool or server and output as JSON.
📊 Repository
🤖 Overview, features, install steps and FAQ were generated from the project's README on Sep 4, 2026. Always check the original source before running commands.