mcp-gateway: Instructions file for Codex

AGENTS.md

mcp-gateway AGENTS.md is an instructions file for Codex, OpenCode from deuriib/mcp-gateway. It costs 4,465 tokens per session, scanned B, original, MIT.

A set of project instructions for MCP Gateway, a Python command-line tool that combines multiple MCP servers behind one HTTP/SSE endpoint and provides a local dashboard. HTTP/SSE is a way for clients to communicate with a web server and receive streamed events.

In plain words
What is it for?
Understanding or changing the gateway's Python code, server registry, sandbox, dashboard, HTTP endpoint, Code Mode, tests, and linting setup.
Why use it?
It gives coding agents the project's structure, technologies, conventions, and commands so they can work consistently in the repository.

Instructions file for CodexOpenCode

Written for Codex and OpenCode: the file is AGENTS.md. Also seen: mentions AGENTS.md; mentions OpenCode.

This is deuriib/mcp-gateway's own configuration. It tells Codex and OpenCode how to work on mcp-gateway itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything mcp-gateway configures →

Reuse

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.

Copy the file
curl -O https://raw.githubusercontent.com/deuriib/mcp-gateway/master/AGENTS.md
Clone the repo
git clone --depth 1 https://github.com/deuriib/mcp-gateway

Made for: Codex, OpenCode.

Wrote 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.

agentmods badge for mcp-gateway AGENTS.md

README.md
[![agentmods](https://agentmods.dev/badge/instructions/deuriib/mcp-gateway/agents-md/github.svg)](https://agentmods.dev/instructions/deuriib/mcp-gateway/agents-md)
Your own site
<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.

agentmods 80×15 button for mcp-gateway AGENTS.md

Your own site · 80×15
<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>
Per session 4,465 This file is loaded in full into every session.
When invoked 4,465 The same file — it is already loaded in full.
Security scan B 1 finding. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

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.

ModelPer sessionOnce 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

Measured 1mo ago against content hash 1ebc1c6905b8, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

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`)
AGENTS.md · 186 lines

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: htpy reintroducido en v3.1.0 (Unreleased, htpy==26.5.1) como renderer del dashboard admin — retirado en v2.0.0, ahora re-admitido; httpx v1 eliminado en favor de httpx2 (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 única CSP de gateway.py (script-src CDNs, 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)

Read the full file on GitHub · 186 lines

Changes

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.

  1. 1mo ago Changed · +4 lines · +559 tokens per session 1ebc1c6905b8
  2. 1mo ago Changed · +289 tokens per session 3e9cd461238f
  3. 1mo ago Changed · +1 lines · +32 tokens per session d192401cb9f1
  4. 1mo ago Changed · -46 tokens per session 5a8ba297f613
  5. 1mo ago Changed · +33 lines · +927 tokens per session b0a276a2b60c
  6. 1mo ago Changed · -16 lines · -86 tokens per session scan A → B ec9d323b5866
  7. 2mo ago First seen · 164 lines · 2,790 tokens per session scan A 14ba395b1868

Subscribe to this mod's changes

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.

Related

mcp-gateway AGENTS.md compared with instructions from other repositories

mcp-gateway AGENTS.md next to 6 instructions from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
mcp-gateway AGENTS.mddeuriib/mcp-gatewayInstructions file01mo agoMITB4,465Codex, OpenCode
vscode buildNext.instructions.mdmicrosoft/vscodeInstructions file195kyesterdayMITA9,719GitHub Copilot
next.js AGENTS.mdvercel/next.jsInstructions file143kyesterdayMITA7,461Codex, OpenCode
langchain AGENTS.mdlangchain-ai/langchainInstructions file149kyesterdayMITA4,680Codex, OpenCode
vscode oss-third-party-notices.instructions.mdmicrosoft/vscodeInstructions file195kyesterdayMITA5,516GitHub Copilot
vscode copilot-instructions.mdmicrosoft/vscodeInstructions file195kyesterdayMITA3,093GitHub Copilot
deepseek-harness AGENTS.mddeepseek-ai/deepseek-harnessInstructions file274k2d agoMITA4,313Codex, OpenCode