Install
$ agentstack add mcp-harrisoncn-mcp-gateway β scanned Β· β verified, works with Claude Code, Cursor, and more.
Security review
β PassedNo issues found. Passed automated security review. Β· v0.1.0 How review works β
- β Prompt-injection patterns
- β Secret / credential exfiltration
- β Dangerous shell & filesystem operations
- β Untrusted network calls
- β Known-malicious package signatures
What it can access
- β Network access Used
- β Filesystem access No
- β Shell / process execution No
- β Environment & secrets No
- β Dynamic code execution No
From automated source analysis of v0.1.0. βUsedβ means the capability is present in the source β more access means more to trust, not that itβs unsafe.
Verified badge
Passed review? Show it. Paste this badge into your README, it links to the public security report.
Reliability & compatibility
Declared compatibility
Compatibility is declared by the source manifest. End-to-end runtime verification is coming, see below.
We're building live execution health for every listing: tool-call success rate, median latency, uptime, and last-checked timestamps, measured, not self-reported. It isn't live yet, so we don't show numbers we can't stand behind.
How agent discovery & health will work βAbout
mcp-gateway
A lightweight, open-source gateway for your MCP servers.
Route Β· Authenticate Β· Rate-limit Β· Monitor β all your Model Context Protocol servers from a single endpoint.
[](LICENSE) [](https://nodejs.org) [](https://www.typescriptlang.org) [](https://www.npmjs.com/package/mcp-gateway) [](https://ghcr.io/HarrisonCN/mcp-gateway)
[English](#) Β· [δΈζ](docs/README.zh-CN.md) Β· [Docs](docs/) Β· [Examples](examples/)
The Problem
As MCP becomes the standard protocol for AI agents to interact with tools, teams are running dozens of MCP servers β filesystem, GitHub, databases, Slack, search, and more. Managing them is chaos:
- Every AI client connects to every server independently
- No central authentication or access control
- No visibility into which tools are being called, by whom, and how often
- No rate limiting to prevent runaway agents from hammering your APIs
mcp-gateway solves this. It sits between your AI clients and your MCP servers, acting as a single, observable, secure entry point.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β AI Clients β
β Claude Code Β· Cursor Β· Copilot Β· Your App Β· Scripts β
βββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββ
β HTTP / REST
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β mcp-gateway β
β β
β ββββββββββββ ββββββββββββ ββββββββββββββββββββββββ β
β β Auth β β Router β β Metrics / Monitor β β
β β API Key β β Tool β β β Prometheus Β· Logs β β
β β JWT β β Server β β Dashboard β β
β ββββββββββββ ββββββββββββ ββββββββββββββββββββββββ β
β β
β ββββββββββββ ββββββββββββ ββββββββββββ β
β βRate Limitβ β Registry β β Health β β
β ββββββββββββ ββββββββββββ ββββββββββββ β
ββββββββ¬βββββββββββββββ¬βββββββββββββββ¬βββββββββββββββββββββ
β β β stdio / SSE / WS
βΌ βΌ βΌ
ββββββββββββ ββββββββββββ ββββββββββββ
βFilesystemβ β GitHub β βPostgreSQLβ ... more
β Server β β Server β β Server β
ββββββββββββ ββββββββββββ ββββββββββββ
Features
- Unified API endpoint β one URL for all your MCP tools, auto-routed by tool name
- Authentication β API key, JWT, or no-auth modes
- Rate limiting β per-key sliding window, with standard
X-RateLimit-*headers - Health monitoring β automatic health checks with configurable intervals
- Metrics β Prometheus-compatible
/metricsendpoint + JSON aggregation - Tool discovery β
GET /api/v1/toolslists all tools across all servers - YAML/JSON config β simple, declarative configuration with env var overrides
- Docker-ready β official Docker image, Compose examples included
- TypeScript SDK β embed the gateway as a library in your own project
Quick Start
Install
npm install -g mcp-gateway
# or
npx mcp-gateway init
Configure
# Generate a default config file
mcp-gateway init
# Edit mcp-gateway.yml to add your servers
# mcp-gateway.yml
port: 4000
servers:
- id: filesystem
name: Filesystem
transport: stdio
command: npx
args: ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"]
- id: github
name: GitHub
transport: stdio
command: npx
args: ["-y", "@modelcontextprotocol/server-github"]
env:
GITHUB_PERSONAL_ACCESS_TOKEN: "${GITHUB_TOKEN}"
Run
mcp-gateway start
# β mcp-gateway listening on http://0.0.0.0:4000
# β β Filesystem β 8 tools available
# β β GitHub β 26 tools available
Call a Tool
# List all available tools
curl http://localhost:4000/api/v1/tools
# Call a tool (auto-routes to the right server)
curl -X POST http://localhost:4000/api/v1/tools/call \
-H "Content-Type: application/json" \
-d '{"tool": "read_file", "arguments": {"path": "/tmp/hello.txt"}}'
# With authentication
curl -X POST http://localhost:4000/api/v1/tools/call \
-H "Authorization: Bearer your-api-key" \
-H "Content-Type: application/json" \
-d '{"tool": "create_issue", "server": "github", "arguments": {"title": "Bug report", "body": "..."}}'
API Reference
| Method | Path | Description | |--------|------|-------------| | GET | /api/v1/health | Gateway health and server summary | | GET | /api/v1/servers | List all registered servers | | GET | /api/v1/servers/:id | Get server details and tools | | GET | /api/v1/tools | List all tools (filterable by ?server= or ?tag=) | | POST | /api/v1/tools/call | Invoke a tool | | GET | /api/v1/metrics | Aggregated metrics (JSON or Prometheus) | | GET | /api/v1/requests | Recent request log |
Configuration Reference
port: 4000 # HTTP port (env: MCP_GATEWAY_PORT)
host: 0.0.0.0 # Bind address (env: MCP_GATEWAY_HOST)
logLevel: info # debug | info | warn | error
auth:
strategy: api-key # none | api-key | jwt
apiKeys:
- "your-secret-key"
rateLimit:
limit: 100 # Max requests per window
windowSeconds: 60 # Window duration
perKey: true # Per-key or global
monitor:
requestLog: true # Log all requests
prometheus: true # Enable Prometheus /metrics
retentionHours: 24 # Metrics retention
corsOrigins:
- "https://your-app.com"
servers:
- id: my-server # Unique identifier
name: My Server # Display name
transport: stdio # stdio | sse | websocket
command: npx
args: ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"]
env:
MY_VAR: "${ENV_VAR}" # Environment variable substitution
tags: [files, local]
enabled: true
timeout: 30000 # ms
maxConcurrency: 10
Docker
# Pull and run
docker run -p 4000:4000 \
-v $(pwd)/mcp-gateway.yml:/app/mcp-gateway.yml \
-e GITHUB_TOKEN=ghp_... \
ghcr.io/harrisonCN/mcp-gateway:latest
# Or with Docker Compose
cd examples/docker
docker compose up
Embed as a Library
import { Gateway, loadConfig } from 'mcp-gateway';
const config = await loadConfig('./mcp-gateway.yml');
const gateway = new Gateway(config);
await gateway.start();
// Gateway is now running at http://localhost:4000
// Graceful shutdown
process.on('SIGTERM', () => gateway.stop());
What's New in v0.2.0
| Feature | Description | |---------|-------------| | SSE Transport | Connect to MCP servers via Server-Sent Events | | WebSocket Transport | Full-duplex WS transport with keep-alive pings | | Config Hot Reload | Edit mcp-gateway.yml without restarting | | Request Tracing | X-Request-Id on every request & response | | CORS Middleware | Configurable cross-origin support | | Web Dashboard | Live monitoring UI at /dashboard | | 4 Bug Fixes | Concurrency, id collision, handle leaks, timeouts |
Roadmap
| Feature | Status | |---------|--------| | stdio transport | β Done | | SSE transport | β Done (v0.2.0) | | WebSocket transport | β Done (v0.2.0) | | Config hot reload | β Done (v0.2.0) | | Web dashboard UI | β Done (v0.2.0) | | Redis-backed rate limiting | π Planned | | OAuth2 / OIDC auth | π Planned | | Tool-level access control (RBAC) | π Planned | | Request replay & debugging | π Planned | | Multi-tenant mode | π Planned | | OpenTelemetry tracing | π Planned |
Contributing
Contributions are welcome! See [CONTRIBUTING.md](docs/CONTRIBUTING.md).
git clone https://github.com/HarrisonCN/mcp-gateway.git
cd mcp-gateway
npm install
npm run dev -- start -c examples/basic/mcp-gateway.yml
License
MIT Β© 2026 HarrisonCN
Built for the agentic era Β· If this helps you, please β star the repo
Source & license
This open-source MCP server is cataloged on AgentStack and links to its original source β we do not rehost the code.
- Author: HarrisonCN
- Source: HarrisonCN/mcp-gateway
- License: MIT
Install and usage instructions live in the source repository linked above.
Reviews
No reviews yet, be the first.
Write a review
Versions
- v0.1.0 Imported from the upstream source.