mcp-gway
Click on "Deploy 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-gwaylist all connected MCP 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 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. v1.4.1 GA adds a local-first Dashboard (Python htpy + python-htmx + Tailwind vendoreado, sin Node).
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
Dashboard (v1.4.1) — Local-first UI en
http://127.0.0.1:8080para listar/agregar/inspeccionar/enable-disable/remover/refrescar servers. SSR conhtpy, mutacioneshtmx, Tailwind vendoreado (<100KB), sinpackage.jsonni build Node. Registry única fuente, masking***obligatorio.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
Related MCP server: MCP Server Proxy
Installation
pip install mcp-gwayOr with mise:
mise install
uv sync --all-groups # installs dev group with pre-commitQuick Start
OpenCode Format (Primary)
OpenCode schema — remote / local with transport auto-detection. This is the recommended path.
# Remote — auto-detects transport (streamable-http → sse → http)
mcp-gway add youtube --type remote --url http://localhost:3001/mcp
# Remote with headers
mcp-gway add supabase --type remote --url https://mcp.supabase.com/mcp --header "Authorization=Bearer TOKEN"
# Remote with pre-registered OAuth
mcp-gway add supabase --type remote --url https://mcp.supabase.com/mcp --oauth-client-id ID --oauth-client-secret SECRET --oauth-scope "openid profile"
# Remote with timeout and enable toggle
mcp-gway add api --type remote --url https://api.example.com/mcp --timeout 10000 --enabled
mcp-gway add api --type remote --url https://api.example.com/mcp --timeout 10000 --no-enabled
# Local
mcp-gway add filesystem --type local --command "npx -y @anthropic/mcp-filesystem"
mcp-gway add tools --type local --command "python -m my_mcp_server" --env MY_VAR=value --cwd /path/to/workdir
mcp-gway add tools --type local --command "npx -y my-mcp" --env KEY=VALUE --env OTHER=123 --cwd /tmp/workdir
# List and serve (local-first)
mcp-gway list
mcp-gway serve --port 8080 # bindea 127.0.0.1 por defecto
mcp-gway serve --host 127.0.0.1 --port 8080
open http://127.0.0.1:8080/dashboardDeprecated Format (still works)
Old --type http|stdio|sse|streamable-http syntax is kept for backward compat and internally mapped to remote/local. Prefer remote/local for new configs.
# Equivalent old syntax — prefer remote/local above
mcp-gway add youtube --type http --url http://localhost:3001/mcp
mcp-gway add filesystem --type stdio --command npx --args '["-y", "@anthropic/mcp-filesystem"]'
mcp-gway add supabase --type streamable-http --url https://mcp.supabase.com/mcp
mcp-gway add legacy --type sse --url https://example.com/sseDashboard — Local-First SSR (htpy)
Stack:
htpy+python-htmx+ TailwindCSS vendoreado ensrc/mcp_gway/dashboard/static/(<100KB + <20KB). Sin Node, sinpackage.json, sin build. Todo HTML tipado en Python; Registry es única fuente (dashboard nunca toca FS directo).
Un solo proceso Gateway(registry, host) monta dashboard embebido: GET /dashboard (SSR) + GET /api/servers (JSON) sobre el mismo Starlette que sirve /mcp y /health.
Routes
Method | Path | Response | Nota |
|
| HTML | banner ámbar si host != loopback |
|
| Fragmento |
|
|
| Drawer | |
|
| Vacía drawer | |
|
| CSS vendoreado | sin CDN |
|
| htmx vendoreado | |
|
|
| secrets |
|
|
| secrets |
|
|
|
|
|
|
| vía |
|
|
| |
|
|
|
|
|
|
| solo |
Content negotiation: HX-Request: true → text/html fragment (swap); sin header → application/json. CSP default-src 'self' en todas las respuestas.
curl Examples
# Serve local-first
mcp-gway serve --port 8080 &
curl -s http://127.0.0.1:8080/dashboard | head -n 20 # 200 HTML htpy
curl -s http://127.0.0.1:8080/api/servers | jq # secrets masked ***
# Add remote (JSON)
curl -X POST http://127.0.0.1:8080/api/servers \
-H 'Content-Type: application/json' \
-d '{"name":"gh","type":"remote","url":"https://example.com/mcp"}' # 201 {name,tool_count}
# Add local (form, htmx)
curl -X POST http://127.0.0.1:8080/api/servers \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'name=echo_srv&type=local&command=echo+hi&cwd=/tmp'
# Fragment htmx (polling tabla)
curl -H "HX-Request: true" http://127.0.0.1:8080/dashboard/servers # <tbody>
# Inspect + reveal
curl -s http://127.0.0.1:8080/api/servers/gh | jq # masked
curl -X POST http://127.0.0.1:8080/api/servers/gh/reveal \
-H 'Content-Type: application/json' -d '{"field":"headers"}' | jq # solo loopback POST
# Toggle / refresh / delete
curl -X PATCH http://127.0.0.1:8080/api/servers/gh \
-H 'Content-Type: application/json' -d '{"enabled":false}' | jq
curl -X POST http://127.0.0.1:8080/api/servers/gh/refresh | jq # 202 background, health <50ms
curl -X DELETE http://127.0.0.1:8080/api/servers/gh # 204HTMX Examples
<!-- Add: form SSR + hx-post swap tabla -->
<form hx-post="/api/servers" hx-target="#server-table-body" hx-swap="outerHTML" hx-indicator="#add-spinner">
<input name="name" required /><select name="type"><option>remote</option><option>local</option></select>
<input name="url" /><input name="command" /><button>Add</button>
</form>
<!-- Inspect: click fila abre drawer -->
<tr hx-get="/dashboard/servers/gh" hx-target="#drawer" hx-swap="innerHTML"><td>gh</td></tr>
<!-- Toggle / Refresh / Delete con confirm -->
<button hx-patch="/api/servers/gh" hx-vals='{"enabled":false}' hx-target="#drawer">Disable</button>
<button hx-post="/api/servers/gh/refresh" hx-target="#toast">Refresh</button>
<button hx-delete="/api/servers/gh" hx-confirm="Delete gh?" hx-target="#server-table-body" hx-swap="outerHTML">Delete</button>Local-First Security
# Default seguro — solo loopback
mcp-gway serve --port 8080 # bindea 127.0.0.1
# Exponer en 0.0.0.0 requiere opt-in explícito
MCP_GWAY_ALLOW_REMOTE=1 mcp-gway serve --host 0.0.0.0 --port 8080
# └─ log warning "dashboard exposed on non-loopback"
# └─ header X-Warning: exposed + banner ámbar en UI + botón Reveal deshabilitado
# Sin opt-in → error controlado
mcp-gway serve --host 0.0.0.0
# Error: binding to non-loopback host '0.0.0.0' requires MCP_GWAY_ALLOW_REMOTE=1
# exit 2Masking
***obligatorio:GET /api/servers,GET /api/servers/{name},GET /dashboardnunca exponenheaders/oauth.clientSecret/environmentreales.Reveal solo
POST /api/servers/{name}/revealdesde127.0.0.1, rate-limit 5/min, audit log sin valor,403si no loopback,405si GET.
Observability — Logs + Metrics + Health (Approach C, v1.4.1)
Zero vendor lock-in: stdlib
jsonlogs (nostructlog), vendoredMetricsRegistry(noprometheus_client), correlation viaX-Request-ID+contextvars, health probes/health|/ready|/live+ Prometheus text/metrics. Local-first + masking***preserved;/metricsgated likereveal.
Health & Metrics:
curl -s http://127.0.0.1:8080/health | jq
# {"status":"ok","version":"1.4.1","checks":{"registry":"ok","dashboard":"ok"},"uptime_seconds":42}
curl -s http://127.0.0.1:8080/ready | jq # 200 ready / 503 not_ready (registry/routes/event_loop checks)
curl -s http://127.0.0.1:8080/live | jq # 200 alive — no FS I/O, <5ms
curl -s http://127.0.0.1:8080/metrics | head -n 20
# # HELP mcp_gway_http_requests_total Total HTTP requests
# # TYPE mcp_gway_http_requests_total counter
# mcp_gway_http_requests_total{method="GET",path="/health",status="200"} 7
curl -s http://127.0.0.1:8080/api/health | jq # dashboard-friendly JSON + metrics_summaryCorrelation & JSON logs:
curl -s -H "X-Request-ID: demo123" http://127.0.0.1:8080/health -D - | grep -i X-Request-ID
# X-Request-ID: demo123 ← echo on every response; json log line also has "request_id":"demo123"
uv run mcp-gway serve --port 8080 2>&1 | head # each line valid JSON: timestamp, level, logger, message, request_id, method, path, status, duration_msX-Request-IDorX-Correlation-IDaccepted, sanitized to^[A-Za-z0-9_-]{1,64}$, truncated; autouuid4if absent.Labels bounded:
pathtemplated to/api/servers/{name}(not concrete), server sanitized[^A-Za-z0-9_]→_32 chars.Metrics catalog:
http_requests_total,http_request_duration_seconds(buckets 0.005..5),mcp_tool_calls_total{server,tool,status},discovery_duration_seconds,sandbox_execute_total{status},registry_operations_total{op},gateway_sessions_active.
Dashboard ops card:
GET /dashboardrendersid="ops-card"(htpy) with badgehealthy/degraded/not_ready, uptime, p95, checks; pollsGET /api/health(hx-get every 15s).HX-Request:true→ fragment, else JSON. No secrets, CSP intact.
Local-first gating: /metrics never leaks secrets; if somehow bound non-loopback without MCP_GWAY_ALLOW_REMOTE=1, serve exits 2; if bypassed, /metrics returns 403 + X-Warning: exposed.
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 |
| Add an MCP server and generate |
| Remove an MCP server |
| Update tools for a server |
| List all connected servers |
| Show tool signatures for a server |
| Refresh connection and re-discover tools |
| Start gateway (MCP + Dashboard). Default |
Backward compat:
mcp-gway add --type http|stdio|sse|streamable-httpstill works (deprecated).http/sse/streamable-http→remote(withresolved_transportcached),stdio→local. Useremote/localgoing forward.
Options for add (OpenCode) — 12+ flags grouped by scope:
Option | Description |
| Server type (primary) |
| URL for |
| HTTP header for |
| Command for |
| Environment variable for |
| Working directory for |
| Pre-registered OAuth client ID |
| Pre-registered OAuth client secret |
| OAuth scope |
| Local port for OAuth callback (default 8989) |
| Connection timeout in ms (default 5000) |
| Enable/disable without removal (default enabled) |
| Comma-separated tool filter (default |
| JSON array of extra args — deprecated compat, used with |
| Deprecated — accepted for compat but not persisted (legacy) |
Code Mode
When connected, the gateway exposes 4 meta-tools:
Tool | Description |
| List all available |
| Read function signatures from a stub |
| Get detailed documentation for a tool |
| 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.jsonDevelopment
# Install dependencies
uv sync --all-groups # installs dev group with pre-commit
uv run pre-commit install # once per clone — hooks already configured in .pre-commit-config.yaml
# Run checks
uv run pre-commit run --all-files # ruff + ruff-format + hygiene (trailing-whitespace, end-of-file-fixer, check-yaml, check-added-large-files)
uv run pytest -v # 254 tests v1.4.1 — incluye test_dashboard_* + test_catalog_* + test_observability_*
uv run ruff check src/ tests/
uv run ruff format --check src/ tests/
# Verification Dashboard (sin Node, sin build)
uv run pytest tests/test_dashboard_views.py tests/test_dashboard_api.py -v # masking, HX-Request, reveal, refresh, local gating
curl -s http://127.0.0.1:8080/dashboard | grep -q '<table' && echo "dashboard ok"
curl -s http://127.0.0.1:8080/api/servers | jq 'map(select(.headers))' # *** masked
curl -H "HX-Request: true" http://127.0.0.1:8080/dashboard/servers | head # fragment tbody
# Local-first check
mcp-gway serve --host 0.0.0.0 2>&1 | grep -q "requires MCP_GWAY_ALLOW_REMOTE" && echo "gate ok"
MCP_GWAY_ALLOW_REMOTE=1 mcp-gway serve --host 0.0.0.0 --port 8081 & curl -s -D - http://127.0.0.1:8081/dashboard | grep -qi X-WarningPre-commit is already in place (.pre-commit-config.yaml — ruff v0.16.4, ruff-format, trailing-whitespace, end-of-file-fixer, check-yaml, check-added-large-files).
Architecture
┌──────────────────────────────────────────────────────────────────────┐
│ MCP Gateway v1.4.1 GA │
├──────────────────────────────────────────────────────────────────────┤
│ CLI (click) │ Gateway (Starlette + uvicorn, CSP) │
│ - add remote/local │ - POST /mcp (JSON-RPC) │
│ - remove/inspect/list │ - GET /mcp (SSE endpoint event) │
│ - refresh --auth │ - POST /mcp/messages?session_id=... │
│ - serve --host 127.0.0.1 │ - GET /health │
│ (local-first default) │ │
├───────────────────────────┼──────────────────────────────────────────┤
│ Dashboard (htpy+htmx, vendoreado) │
│ SSR: GET /dashboard, /dashboard/servers, /dashboard/servers/{name} │
│ API: GET/POST /api/servers, PATCH/DELETE /api/servers/{name}, │
│ POST /api/servers/{name}/refresh (202 background), /reveal │
│ Static: /static/tailwind.css (<100KB) + /static/htmx.min.js (<20KB) │
│ Content-negotiation HX-Request + masking *** + rate-limit reveal │
├──────────────────────────────────────────────────────────────────────┤
│ Code Mode (4 meta-tools) │ Starlark Sandbox │
│ - listToolFiles │ - Hermetic execution │
│ - readToolFile │ - Server injection │
│ - getToolDocs │ │
│ - executeToolCode │ │
├──────────────────────────────────────────────────────────────────────┤
│ Registry (única fuente) │ OAuth2 (RFC 7591, reutilizado) │
│ - servers/*.pyi = signatures │ - Dynamic registration │
│ - servers/*.json = config │ - PKCE + FileTokenStorage │
│ - last-write-wins, atómico │ - tokens/ no expuesto vía API │
└──────────────────────────────────────────────────────────────────────┘
│ │ │
┌────┴────┐ ┌────┴────┐ ┌────┴────┐
│ Server1 │ │ Server2 │ │ Server3 │
│ (remote)│ │ (local) │ │ (remote)│
└─────────┘ └─────────┘ └─────────┘Sin Node en runtime ni CI: Tailwind + htmx vendoreados commit,
ruffúnico linter,uv_buildbackend.Release híbrido (ADR-007):
push tags v*→uv build+pypi-publish(GAv1.4.1tag manual) +workflow_run Tests completed→python-semantic-release@v9parafix/perfpatches auto.concurrency: release,fetch-depth:0,[tool.semantic_release]syncpyproject.toml+__init__.py(1.4.1exacta).
License
MIT
This server cannot be deployed
Maintenance
Related MCP Connectors
MCP server for secureFlows: token-free URL builders and integration-linting tools for AI agents.
Self-hosted federated MCP gateway: one OAuth 2.1 MCP server in front of N apps, user-level scopes.
Governed MCP gateway: one endpoint for your tools, with credential custody and audit log.
Hosted MCP server with managed OAuth for 15+ toolkits: Google Workspace, Fitbit, Oura, Kalshi, etc.
Related MCP Servers
- FlicenseNot gradedqualityNot gradedmaintenanceAggregates multiple MCP servers behind a single, secure endpoint with unified tool/resource discovery, OAuth authentication, and resilient request routing. Enables users to manage and interact with multiple MCP backends through one centralized interface with load balancing and circuit breakers.2-
- AlicenseNot gradedqualityDmaintenanceAggregates multiple MCP servers into a single endpoint, enabling LLM clients to access tools, resources, and prompts from various backends through one connection.7 npmMIT
- AlicenseBqualityCmaintenanceAggregates multiple MCP servers via a single interface with token optimization and multiple operating modes (Gateway, Meta, Proxy, Search, Code).78MIT
- AlicenseNot gradedqualityAmaintenanceCentralizes management and routing of multiple MCP servers, exposing them to AI clients via HTTP/SSE endpoints with configurable visibility, sharing, and smart routing.547 npmApache 2.0