MCP Gateway
Lightweight Model Context Protocol gateway that exposes one entry point for multiple downstream MCP services, enabling efficient tool discovery and routing.
README
English | 简体中文
MCP Gateway
MCP Gateway is a lightweight Model Context Protocol gateway that exposes one small MCP entry point for multiple downstream MCP services.
Instead of flattening every downstream tool into the client at startup, the gateway exposes a fixed discovery and routing API. Agents can list services, inspect tools for one service, fetch one schema, and then forward the actual tool call.
Features
- One MCP entry point for multiple downstream MCP services.
- Token-efficient discovery through a small fixed gateway tool surface.
- Stdio and Streamable HTTP downstream transports.
- Optional inbound Streamable HTTP endpoint enabled by CLI flags.
- Hot reload for service-pool config changes.
- Stops removed, disabled, or replaced downstream services during reload.
- Restarts failed downstream processes up to three times before marking them unavailable.
- Atomic config reload that keeps the previous valid config when a new config is invalid.
- Optional newline-delimited JSON file logging that never writes operational logs to MCP stdout.
- Version reporting through
--versionor-v.
Why Use It
- Keep agent-side MCP configuration small: every agent connects to the gateway, while downstream services are managed in one config file.
- Reduce initial tool context: agents discover only the service, tool, and schema needed for the current task.
- Keep service lifecycle control centralized instead of duplicating command paths, environment variables, and secrets across multiple clients.
Quick Start
Install globally:
npm install -g @jadchene/mcp-gateway-service
Create a local config:
cp config.example.json config.json
Start the stdio gateway:
mcp-gateway-service --config ./config.json
Start with inbound Streamable HTTP:
mcp-gateway-service --config ./config.json --http --host 127.0.0.1 --port 3100 --path /mcp
Use stateless JSON responses for HTTP clients that expect direct JSON-RPC responses from POST:
mcp-gateway-service --config ./config.json --http --port 3100 --path /mcp --json-response
Check the installed version:
mcp-gateway-service --version
mcp-gateway-service -v
Configuration
Pass the config file by CLI argument:
mcp-gateway-service --config ./config.json
Or by environment variable:
MCP_GATEWAY_CONFIG=./config.json mcp-gateway-service
If neither is provided, the service tries config.json in the current working directory.
Config example:
{
"logging": {
"enable": false,
"path": "./logs/mcp-gateway.log"
},
"services": [
{
"serviceId": "demo-echo",
"enable": true,
"name": "Demo Echo Service",
"description": "Sample echo MCP service.",
"transport": {
"type": "stdio",
"command": "node",
"args": [
"--experimental-strip-types",
"examples/echo-service.ts"
]
}
},
{
"serviceId": "remote-http",
"enable": false,
"name": "Remote Streamable HTTP Service",
"description": "Example downstream MCP service over Streamable HTTP.",
"transport": {
"type": "http",
"url": "http://127.0.0.1:3200/mcp",
"headers": {
"Authorization": "Bearer ${MCP_TOKEN}"
},
"enableJsonResponse": false
}
}
]
}
Configuration notes:
logging.enabledefaults tofalse.logging.pathis required only whenlogging.enableistrue.- Relative
logging.pathvalues are resolved from the config file directory. - Service
enabledefaults totrue; setting it tofalseskips that service. cwdandenvare optional for stdio services.- Stdio
transport.framingmay belineorcontent-length. When omitted, the gateway trieslineand thencontent-length. - HTTP downstream services use
transport.type: "http"andtransport.url. - HTTP
transport.headersprovides static request headers. - HTTP
transport.enableJsonResponseenables stateless JSON response mode for that downstream service.
Inbound Streamable HTTP
Inbound HTTP is enabled only with --http. Passing --host, --port, --path, or --json-response without --http does not start an HTTP listener.
The HTTP endpoint uses the same path for GET and POST:
GET /mcpopens the SSE read channel and returns the session in theMcp-Session-Idresponse header.POST /mcpsends JSON-RPC messages. New clients should bind the session through theMcp-Session-Idrequest header.- Query-string
sessionIdis accepted for compatibility. - The
endpointSSE event advertises the single path, such as/mcp.
Gateway Tools
The gateway exposes six public tools:
| Tool | Purpose |
|---|---|
gateway_list_services |
List all downstream MCP services managed by the gateway, including each serviceId, description, and availability. |
gateway_get_service |
Return one service summary, runtime state, recent errors, and cached metadata. Use this for diagnostics. |
gateway_list_tools |
List tools exposed by one downstream service. Optional toolName filters by one or more name fragments. |
gateway_get_tool_schema |
Return the input and output schema for one downstream tool. |
gateway_manage_service |
Reconnect a service or persistently enable/disable it in the config file. |
gateway_call_tool |
Call one downstream tool through the gateway and return the downstream MCP result. |
Default token-efficient workflow:
- Call
gateway_list_servicesonce. - Call
gateway_list_tools(serviceId)only when a service is needed. UsetoolNameto filter large tool lists by name. - Call
gateway_get_tool_schema(serviceId, toolName)before first use of a tool. - Call
gateway_call_toolto execute the downstream tool. - Use
gateway_get_serviceonly for diagnostics. - Use
gateway_manage_serviceonly to reconnect, enable, or disable a service.
gateway_manage_service actions:
reconnect: retry the current downstream lifecycle without modifying config.enable: persistenable: truefor the service and reload config.disable: persistenable: falsefor the service and reload config.
Skill Integration
This repository includes a public gateway skill:
- Skill path:
skills/mcp-gateway/SKILL.md
Use it when your agent supports skills. It keeps discovery token-efficient and routes downstream calls through the minimal gateway contract.
MCP Client Configuration
Codex:
[mcp_servers.gateway]
command = "mcp-gateway-service"
args = ["--config", "./config.json"]
Gemini CLI:
{
"mcpServers": {
"gateway": {
"type": "stdio",
"command": "mcp-gateway-service",
"args": ["--config", "./config.json"]
}
}
}
Claude Code:
{
"mcpServers": {
"gateway": {
"type": "stdio",
"command": "mcp-gateway-service",
"args": ["--config", "./config.json"]
}
}
}
Streamable HTTP mode:
Start one shared HTTP gateway process first:
mcp-gateway-service --config ./config.json --http --host 127.0.0.1 --port 3100 --path /mcp
Then point MCP clients at the HTTP endpoint.
Codex:
[mcp_servers.gateway]
url = "http://127.0.0.1:3100/mcp"
Gemini CLI:
{
"mcpServers": {
"gateway": {
"httpUrl": "http://127.0.0.1:3100/mcp"
}
}
}
Claude Code:
{
"mcpServers": {
"gateway": {
"type": "http",
"url": "http://127.0.0.1:3100/mcp"
}
}
}
Use the same URL for every client that should share the gateway service pool. Use --json-response only when your HTTP client expects stateless JSON-RPC responses directly from POST requests.
Development
npm install
npm run dev
Build and test:
npm run build
npm test
Run the built server:
node dist/index.js --config ./config.json
License
MIT. See LICENSE.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.