MCP Gateway
Provides integration with GitHub for managing repositories, issues, pull requests, and code search functionality.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MCP Gatewaylist available servers"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MCP Gateway
A lazy-loading proxy that sits between Claude and your MCP servers. Instead of loading every server at startup (which dumps hundreds of tool schemas into context and burns tokens), the gateway exposes just 4 lightweight tools. Backend servers only start when you actually need them.
Before: 10 MCP servers = 200+ tool schemas loaded into every conversation = thousands of wasted tokens.
After: 10 MCP servers behind the gateway = 4 tool schemas loaded. Each server starts on demand.
The Problem
Every MCP server you add to Claude Code registers all its tools upfront. A typical server has 10-30 tools, each with a full JSON schema. With 10 servers that's 100-300 tool definitions eating your context window before you even ask a question.
Most conversations only use 1-2 servers. The rest are dead weight.
How It Works
The gateway exposes 4 tools to Claude:
Tool | What it does |
| Shows available servers and their status |
| Connects to a server and discovers its tools |
| Calls a tool on a connected server |
| Reconnects a server (picks up code changes) |
When Claude needs a server, it calls gateway_load_server. The gateway starts the subprocess, does the MCP handshake, and caches the connection. Subsequent calls reuse the running process.
Servers that aren't used never start. No tokens wasted.
Quick Start
git clone https://github.com/raiansar/mcp-gateway.git
cd mcp-gateway
./install.shEdit config.json to add your servers, then add the gateway to Claude Code:
claude mcp add gateway -- /path/to/mcp-gateway/run.shThat's it. All your servers are now behind a single gateway.
Configuration
config.json is a simple map of server names to their connection details. The gateway supports both stdio (local processes) and HTTP (remote servers) transports.
Stdio Servers (local)
{
"servers": {
"my-server": {
"type": "stdio",
"command": "npx",
"args": ["-y", "some-mcp-server@latest"],
"env": {
"API_KEY": "your-key"
},
"timeout": 30,
"description": "What this server does"
}
}
}HTTP Servers (remote)
{
"servers": {
"remote-server": {
"type": "http",
"url": "https://mcp.example.com/mcp",
"headers": {
"Authorization": "Bearer your-token"
},
"timeout": 60,
"description": "Remote MCP server"
}
}
}Python Servers (uv)
{
"servers": {
"my-python-server": {
"type": "stdio",
"command": "uv",
"args": ["run", "--directory", "/path/to/server", "server-name"],
"env": {},
"timeout": 120,
"description": "Python server managed by uv"
}
}
}Config Fields
Field | Required | Default | Description |
| No |
| Transport: |
| Yes (stdio) | - | Command to run the server |
| No |
| Command arguments |
| No |
| Environment variables |
| Yes (http) | - | Server URL |
| No |
| HTTP headers (auth tokens, etc.) |
| No | 30/60 | Request timeout in seconds (30 for stdio, 60 for http) |
| No | - | Human-readable description shown in |
Migrating Your Existing MCP Servers
If you already have MCP servers configured in Claude Code, move them to the gateway:
Before (in ~/.claude.json or Claude Desktop config):
{
"mcpServers": {
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": { "GITHUB_PERSONAL_ACCESS_TOKEN": "ghp_xxx" }
},
"tavily": {
"command": "npx",
"args": ["-y", "tavily-mcp@latest"],
"env": { "TAVILY_API_KEY": "tvly-xxx" }
},
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/home/user"],
"env": {}
}
}
}After (in config.json):
{
"servers": {
"github": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": { "GITHUB_PERSONAL_ACCESS_TOKEN": "ghp_xxx" },
"description": "GitHub - repos, issues, PRs, code search"
},
"tavily": {
"type": "stdio",
"command": "npx",
"args": ["-y", "tavily-mcp@latest"],
"env": { "TAVILY_API_KEY": "tvly-xxx" },
"description": "Tavily AI search"
},
"filesystem": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/home/user"],
"env": {},
"description": "File system access"
}
}
}Then remove the individual servers from Claude and add just the gateway:
claude mcp remove github -s user
claude mcp remove tavily -s user
claude mcp remove filesystem -s user
claude mcp add gateway -- /path/to/mcp-gateway/run.shUsage
Once configured, Claude automatically uses the gateway. A typical interaction:
Claude calls
gateway_list_serversto see what's availableClaude calls
gateway_load_server("github")when it needs GitHubClaude calls
gateway_call_tool("github", "search_repositories", '{"query": "mcp"}')to use a toolThe GitHub server stays running for subsequent calls in the same session
The description field in your config helps Claude decide which server to load for a given task, so write good descriptions.
How This Differs from RTK
RTK is a CLI proxy that compresses shell command output (git, ls, test runners, etc.) to reduce token consumption by 60-90%.
MCP Gateway solves a different problem: it prevents MCP tool schema bloat by lazy-loading servers on demand instead of registering all tools upfront.
MCP Gateway | RTK | |
Problem | Tool schemas from idle MCP servers waste context | Verbose CLI output wastes context |
How | Lazy-loads servers, exposes 4 proxy tools | Compresses command output before it hits context |
When | Startup / tool registration | Runtime / command execution |
Scope | MCP server management | Shell commands (git, npm, cargo, etc.) |
They're complementary. Use both for maximum token savings.
Requirements
Python 3.10+
mcppackage (installed byinstall.sh)
License
MIT
This server cannot be installed
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/RaiAnsar/mcp-gateway'
If you have feedback or need assistance with the MCP directory API, please join our Discord server