Borrowing it
Nothing to install: this file belongs to deuriib/mcp-gateway. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.
curl -O https://raw.githubusercontent.com/deuriib/mcp-gateway/master/AGENTS.mdgit clone --depth 1 https://github.com/deuriib/mcp-gatewayWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/instructions/deuriib/mcp-gateway/agents-md)<a href="https://agentmods.dev/instructions/deuriib/mcp-gateway/agents-md"><img src="https://agentmods.dev/badge/instructions/deuriib/mcp-gateway/agents-md/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/instructions/deuriib/mcp-gateway/agents-md"><img src="https://agentmods.dev/badge/instructions/deuriib/mcp-gateway/agents-md.svg" alt="Reviewed on agentmods" width="80" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.04465 | $0.04465 |
| Opus 5.5 | $0.01786 | $0.01786 |
| Sonnet 5.5 | $0.00893 | $0.00893 |
| Haiku 4.5 | $0.00447 | $0.00447 |
Grade B, and why
mcp-gateway AGENTS.md scanned grade B with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Asks for rootmediumPrivilege escalation
A mod that escalates privileges can change anything on the machine, not only the project.
5. Token storage in `~/.config/mcp-gway/tokens/` (`0o600` via `_secure_atomic_write`, ver `oauth.py:run_oauth_flow`; preferir `refresh --auth`, manual solo con `chmod 600`) How it starts
The opening of the file, as written. The whole thing — 186 lines — stays where its author put it; the contents beside it link to each section on GitHub.
AGENTS.md
Project Overview
MCP Gateway — A standalone Python CLI that aggregates multiple MCP servers behind a single headless HTTP/SSE endpoint with Code Mode, plus an admin web dashboard at / (htpy + htmx + Tailwind CDN, v3.1.0 Unreleased — reintroduces management UI; CLI sigue canónico, catalog permanece retirado).
Nota interna: ver
CHANGELOG.md(al día hasta v3.0.0, 2026-09-22). Releases internos no publicados — no anuncio externo.
Tech Stack
- Language: Python 3.12+
- Package Manager: uv (with mise for tool versions)
- CLI Framework: click
- HTTP Server: Starlette + uvicorn
- MCP SDK: mcp v2.0.0
- Sandbox: starlark-pyo3
- Testing: pytest + pytest-asyncio (621 tests)
- Linting: ruff
- Nota:
htpyreintroducido en v3.1.0 (Unreleased,htpy==26.5.1) como renderer del dashboard admin — retirado en v2.0.0, ahora re-admitido;httpxv1 eliminado en favor dehttpx2(dependencia directa, alineada con mcp v2 y starlette 1.6). - Dashboard: htpy (server rendering) + htmx 2.0.10 + Tailwind — ambos vía CDN (
cdn.jsdelivr.net,cdn.tailwindcss.com); CSP relajado en la constante únicaCSPdegateway.py(script-srcCDNs,style-src 'unsafe-inline',frame-ancestors 'none').
Project Structure
src/mcp_gway/
├── __init__.py # Package version (3.1.0)
├── models.py # Pydantic models (MCPServerConfig OpenCode-only local|remote, ToolInfo, OAuthConfig)
├── registry.py # .pyi file CRUD (servers/ directory) — única fuente de verdad
├── sandbox.py # Starlark sandbox (hermetic execution)
├── server_proxy.py # MCP server wrapper for sandbox
├── server_factory.py # Server structs + sync call wrappers for the sandbox
├── code_mode.py # 4 meta-tools orchestrator
├── gateway.py # HTTP/SSE server (JSON-RPC 2.0), local-first 127.0.0.1 + CSP — rutas /mcp por transporte (gateway.py:320-340, mcp_routes condicional; app.state.transport; sin fallback): http = POST /mcp (GET → 405 Allow: POST) + /health, /ready, /live, /metrics → 6 entradas; sse = GET /mcp (SSE) + POST /mcp → 405 Allow: GET + /mcp/messages (alias POST al handler _mcp_post, no endpoint independiente) + probes → 7 entradas
├── cli.py # CLI commands (add/remove/update/list/inspect/refresh/serve --transport stdio|http|sse/mcp-hidden/local-unrestricted --host 127.0.0.1)
├── admin/ # Admin dashboard: theme, components, icons (SVG authored), layout, data, routes + pages/{status,overview,servers,tools,observability,policy} (htpy+htmx, CDN)
├── oauth.py # OAuth2 support (dynamic registration, token storage); usa httpx2 (dependencia directa)
├── transport.py # Shim deprecado → mcp_gway.core.transport (DeprecationWarning; eliminar en next major)
├── stdio.py # SERVIDOR-side NDJSON: lee JSON-RPC 2.0 de stdin, responde por stdout (`mcp-gway serve --transport stdio`; `mcp` alias deprecado)
├── stdio_transport.py # CLIENT-side: filtered_stdio_client conecta a niños MCP y filtra ruido no-JSON de su stdout
├── core/
│ ├── __init__.py # Re-exports (create_client_transport, detect_transport, discover_tools, parse_envs/headers, refresh_server)
│ ├── transport.py # Auto-detección de transporte remote (streamable-http → sse → http)
│ ├── policy.py # Allow-list local + break-glass 72h (ADR-009), cwd/env gates, audit
│ ├── parsing.py # parse_headers / parse_envs (KEY=VALUE)
│ ├── install.py # Discovery + persist helpers (semáforo 3, oauth fallback)
│ └── client.py # create_client_transport (local|remote), discover_tools, refresh_server
└── observability/
├── __init__.py # Re-exports (JSONFormatter, MetricsRegistry, request_id_ctx, setup_logging)
├── logging.py # JSONFormatter (stderr), request_id ContextVar, setup_logging
├── middleware.py # Correlation (X-Request-ID), Metrics, Logging middlewares
├── metrics.py # MetricsRegistry hand-rolled Prometheus exposition (counter/gauge/histogram)
└── health.py # /health, /ready, /live, /metrics (X-Warning: exposed gating)
> **Retirado en v2.0.0 (no servir):** dashboard legacy (`/dashboard`, `/api/servers`, `/static`) y catalog (`/api/catalog`, `/dashboard/catalog`, Bifrost fetch, `~/.config/mcp-gway/catalog.json`). El alias `/` fue reactivado en v3.1.0 como índice del admin (`/admin*`) — superficie nueva, no el dashboard legacy.
tests/
├── conftest.py # Fixtures compartidos
├── test_models.py # Model validation tests (+ SSRF guard)
├── test_registry.py # Registry CRUD tests (path traversal/symlink)
├── test_sandbox.py # Sandbox execution tests
├── test_server_proxy.py # Server proxy tests
├── test_server_factory.py # Server factory structs + call wrappers
├── test_code_mode.py # Code mode tests
├── test_gateway.py # HTTP/SSE server tests
├── test_admin_dashboard.py # Admin dashboard (pages, partials, CSRF, loopback gate, parity mutations)
├── test_cli.py # CLI command tests
├── test_integration.py # End-to-end flow tests
├── test_transport.py # Transport auto-detection tests
├── test_stdio.py # Server-side NDJSON (mcp-gway mcp) tests
├── test_stdio_transport.py # Client-side filtered stdio tests
├── test_policy_local_commands.py # feat-006 allow-list policy tests
├── test_break_glass.py # Break-glass marker TTL/permissions tests
├── test_feat006_harden.py # feat-006 hardening tests (PATCH bypass, regates)
├── test_p0_fixes.py # P0 regression fixes
├── test_wave2_api.py # Wave-2 API asserts (CSP header etc.)
└── test_observability_*.py # metrics / logging / probes / instrumentation
docs/
├── specs/SPEC-UI-001.md (+ SCENARIOS/ACCEPTANCE) # SUPERSEDED 2026-09-10 (retirado; headless, CLI-only) — reversado parcial 2026-09-23: admin UI nueva en `/` + `/admin*` (v3.1.0 Unreleased, spec distinta)
├── adr/ADR-007-release-workflow-hybrid.md, ADR-008-catalog-mcp-001.md
├── architecture/adr-009-dynamic-local-commands.md, adr-010-unified-serve.md (referenciado, ausente en repo; enmienda ADR-010 AC-05 2026-09-22: http/sse comparten el entrypoint `_serve_http`, NO la app — rutas `/mcp` separadas por transporte, sin fallback)
├── sbtdd/specs/feat-006-dynamic-local-commands/ # spec + scenarios + acceptance + verify
├── superpowers/plans/ # Planes fechados (históricos)
└── superpowers/specs/2026-08-2X-* # Specs de diseño (históricos)
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 1mo ago Changed · +4 lines · +559 tokens per session 1ebc1c6905b8
- 1mo ago Changed · +289 tokens per session 3e9cd461238f
- 1mo ago Changed · +1 lines · +32 tokens per session d192401cb9f1
- 1mo ago Changed · -46 tokens per session 5a8ba297f613
- 1mo ago Changed · +33 lines · +927 tokens per session b0a276a2b60c
- 1mo ago Changed · -16 lines · -86 tokens per session scan A → B ec9d323b5866
- 2mo ago First seen · 164 lines · 2,790 tokens per session scan A 14ba395b1868
mcp-gateway AGENTS.md is an instructions file published in the GitHub repository deuriib/mcp-gateway (0 stars, last pushed 1mo ago), licensed MIT. It adds 4,465 tokens to every session, about $0.0179 per session on Opus 5.5. A static security scan graded it B with 1 finding (asks for root). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.
mcp-gateway AGENTS.md compared with instructions from other repositories
| Mod | Type | Stars | Last push | Licence | Scan | Tokens | Works with |
|---|---|---|---|---|---|---|---|
| mcp-gateway AGENTS.mddeuriib/mcp-gateway | Instructions file | 0 | 1mo ago | MIT | B | 4,465 | Codex, OpenCode |
| vscode buildNext.instructions.mdmicrosoft/vscode | Instructions file | 195k | yesterday | MIT | A | 9,719 | GitHub Copilot |
| next.js AGENTS.mdvercel/next.js | Instructions file | 143k | yesterday | MIT | A | 7,461 | Codex, OpenCode |
| langchain AGENTS.mdlangchain-ai/langchain | Instructions file | 149k | yesterday | MIT | A | 4,680 | Codex, OpenCode |
| vscode oss-third-party-notices.instructions.mdmicrosoft/vscode | Instructions file | 195k | yesterday | MIT | A | 5,516 | GitHub Copilot |
| vscode copilot-instructions.mdmicrosoft/vscode | Instructions file | 195k | yesterday | MIT | A | 3,093 | GitHub Copilot |
| deepseek-harness AGENTS.mddeepseek-ai/deepseek-harness | Instructions file | 274k | 2d ago | MIT | A | 4,313 | Codex, OpenCode |