MCP Gateway
A standalone CLI gateway that aggregates multiple MCP (Model Context Protocol) servers behind a single HTTP/SSE endpoint with Code Mode — reducing LLM input token usage by up to 92% when using multiple MCP servers.
Features
- Multi-Server Aggregation — Connect to multiple MCP servers (HTTP, SSE, Stdio, Streamable HTTP) and expose them through a single endpoint
- Code Mode — 4 meta-tools that let LLMs discover and use tools dynamically without loading all schemas upfront
- OAuth 2.0 Support — Built-in OAuth flow with dynamic client registration (RFC 7591) and token storage
- Hermetic Sandbox — Starlark-based sandbox for safe code execution
- MCP Protocol Compliant — Works with Claude Desktop, Cursor, and any MCP-compatible client
Installation
pip install mcp-gway
Or with mise:
mise install
uv sync
Quick Start
# Add an MCP server
mcp-gway add youtube --type http --url http://localhost:3001/mcp
# Add a stdio server
mcp-gway add filesystem --type stdio --command npx --args '["-y", "@anthropic/mcp-filesystem"]'
# Add a server requiring OAuth
mcp-gway add supabase --type streamable-http --url https://mcp.supabase.com/mcp
# List all servers
mcp-gway list
# Start the gateway
mcp-gway serve --port 8080
Connect from Claude Desktop
Add to your Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json):
{
"mcpServers": {
"gateway": {
"url": "http://localhost:8080/mcp"
}
}
}
Commands
| Command | Description |
|---|---|
mcp-gway add |
Add an MCP server and generate .pyi stub |
mcp-gway remove |
Remove an MCP server |
mcp-gway update |
Update tools for a server |
mcp-gway list |
List all connected servers |
mcp-gway inspect |
Show tool signatures for a server |
mcp-gway refresh |
Refresh connection and re-discover tools |
mcp-gway serve |
Start the gateway server |
Code Mode
When connected, the gateway exposes 4 meta-tools:
| Tool | Description |
|---|---|
listToolFiles |
List all available .pyi stub files |
readToolFile |
Read function signatures from a stub |
getToolDocs |
Get detailed documentation for a tool |
executeToolCode |
Execute code in a sandboxed Starlark interpreter |
OAuth Authentication
For servers requiring OAuth (e.g., Supabase):
# Trigger OAuth flow
mcp-gway refresh supabase --auth
# Or store token manually
mkdir -p ~/.config/mcp-gway/tokens
echo '{"access_token": "YOUR_TOKEN"}' > ~/.config/mcp-gway/tokens/supabase.json
Development
# Install dependencies
mise install
uv sync
# Run tests
uv run pytest -v
# Lint and format
uv run ruff check src/ tests/
uv run ruff format src/ tests/
Architecture
┌─────────────────────────────────────────────────────────┐
│ MCP Gateway │
├─────────────────────────────────────────────────────────┤
│ CLI (click) │ HTTP/SSE Server (Starlette) │
│ - add │ - POST /mcp (JSON-RPC) │
│ - remove │ - GET /mcp (SSE stream) │
│ - list │ - POST /mcp/messages │
│ - refresh │ │
├─────────────────────────────────────────────────────────┤
│ Code Mode (4 meta-tools) │ Starlark Sandbox │
│ - listToolFiles │ - Hermetic execution │
│ - readToolFile │ - Server injection │
│ - getToolDocs │ │
│ - executeToolCode │ │
├─────────────────────────────────────────────────────────┤
│ Registry (.pyi files) │ OAuth2 (RFC 7591) │
│ - servers/*.pyi │ - Dynamic registration│
│ - Tool signatures │ - Token storage │
└─────────────────────────────────────────────────────────┘
│ │ │
┌────┴────┐ ┌────┴────┐ ┌────┴────┐
│ Server1 │ │ Server2 │ │ Server3 │
│ (HTTP) │ │ (SSE) │ │ (Stdio) │
└─────────┘ └─────────┘ └─────────┘
License
MIT
Metadata
Release files for mcp-gway 0.5.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mcp_gway-0.5.2.tar.gz | 18.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mcp_gway-0.5.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 42.5 kB
Release files / mcp_gway-0.5.2.tar.gz
| Download URL | mcp_gway-0.5.2.tar.gz |
|---|---|
| Size | 18.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
226f46c04c4bd3fb0423e52edb54f30db613a7e5c7c057aba5a5032d82d25ec8
|
|
BLAKE2b-256 checksum How to use checksums |
3f0cdf371ba5b30cd091c265a326ced7a6ca1b93a21946447651716c612bf2d0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 24, 2026.
Transparency logRelease files / mcp_gway-0.5.2-py3-none-any.whl
| Download URL | mcp_gway-0.5.2-py3-none-any.whl |
|---|---|
| Size | 23.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7a0c91b64d3bb97ea9d6ea337096ba08616978671e527f2c0e9409125d2ffdbd
|
|
BLAKE2b-256 checksum How to use checksums |
0f69dd3c66379e554cd283215de0eae0a3b841eaede742b58e1f68fe8bf4849e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 24, 2026.
Transparency log