panda-gateway CLAUDE.md

panda-gateway CLAUDE.md is an instructions file for Claude Code from PalNilsson/panda-gateway. It costs 2,824 tokens per session, scanned A, original, Apache-2.0.

Repository instructions for PanDA Gateway, a routing service that exposes one MCP endpoint and forwards tool requests to the correct upstream server. MCP is a standard way for agents to call external tools.

In plain words
What is it for?
Use them when developing, testing, linting, type-checking, observing, or deploying the gateway.
Why use it?
They explain the project structure, setup commands, tests, and safeguards needed when changing a service that connects several tool providers.

Instructions file for Claude Code

Written for Claude Code: the file is CLAUDE.md. Also seen: mentions CLAUDE.md; mentions Claude Code.

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add instructions/palnilsson/panda-gateway/claude-md
Clone the repo
git clone --depth 1 https://github.com/PalNilsson/panda-gateway

Made for: Claude Code.

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 panda-gateway CLAUDE.md

README.md
[![agentmods](https://agentmods.dev/badge/instructions/palnilsson/panda-gateway/claude-md.svg)](https://agentmods.dev/instructions/palnilsson/panda-gateway/claude-md)
Your own site
<a href="https://agentmods.dev/instructions/palnilsson/panda-gateway/claude-md"><img src="https://agentmods.dev/badge/instructions/palnilsson/panda-gateway/claude-md.svg" alt="Measured on agentmods" height="20"></a>
Per session 2,824 This file is loaded in full into every session.
When invoked 2,824 The same file — it is already loaded in full.
Security scan A 1 finding. Scan, not verified.
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.02824 $0.02824
Opus 5 $0.01412 $0.01412
Sonnet 5 $0.00565 $0.00565
Haiku 4.5 $0.00282 $0.00282

Measured 5d ago against content hash 0feaac20cb93, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

panda-gateway CLAUDE.md scanned grade A 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 5d 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.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

curl http://127.0.0.1:8090/healthz
CLAUDE.md · 118 lines

How it starts

The opening of the file, as written. The whole thing — 118 lines — stays where its author put it; the contents beside it link to each section on GitHub.

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

Project Overview

PanDA Gateway is a thin, stateless MCP routing layer between the PanDA Monitor (or any MCP client) and upstream MCP servers (Bamboo MCP, PanDA MCP, and future additions). It exposes a single MCP endpoint (Streamable HTTP) and routes each tools/call to the correct upstream based on a namespace prefix in the tool name. It carries no LLM logic, no planning, no synthesis.

Human-facing docs live in docs/: architecture.md (components, design decisions), catalog-and-search.md (tool catalog + RAG), security-and-resilience.md (trust model, hardening, failure recovery — read before any non-local deployment change). This file is the Claude-Code-specific companion to those, not a replacement.

Commands

# Install (runtime)
pip install -e .

# Install for development
pip install -e ".[dev]"

# Install with OpenTelemetry support
pip install -e ".[observability]"

# Run tests
python -m pytest tests/

# Run a single test file
python -m pytest tests/test_registry.py -v

# Lint
flake8 panda_gateway tests

# Type check
pyright

# Run the gateway (HTTP mode)
panda-gateway --config gateway.minimal.toml

# Run in stdio mode (development)
panda-gateway --config gateway.minimal.toml --stdio

# Health check
curl http://127.0.0.1:8090/healthz

Requires Python ≥ 3.11.

Architecture

PanDA Monitor (MCP client)
        │  MCP / Streamable HTTP  (Bearer token)
        ▼
┌─────────────────────────────────────────────┐
│              PanDA Gateway                  │
│  GatewayServer · UpstreamRegistry · Router  │
└─────────────────────────────────────────────┘
        │           │           │
   Bamboo MCP   PanDA MCP   (future)
   bamboo.*     panda.*

Module responsibilities

  • config.py — Pydantic models loaded from TOML. Config path comes from --config CLI flag or PANDA_GATEWAY_CONFIG env var. Secrets (tokens) are never in the TOML; the file only names the env var or file path that holds them. All models set extra = "forbid": an unknown/misspelled TOML key raises at load time.
  • auth.py — Inbound pure-ASGI BearerAuthMiddleware (constant-time compare; only /healthz is unauthenticated) and outbound TokenProviders: EnvTokenProvider and FileTokenProvider (re-reads the file on every reconnect for OIDC token renewal).
  • registry.py — One UpstreamHandle per upstream, each running a supervisor task: open transport, initialise a ClientSession (bounded by init_timeout), run the paginated tools/list probe (bounded by probe_timeout, fully following pagination via nextCursor, bounded by _MAX_PROBE_PAGES, committed to the catalog only once all pages succeed) — state only becomes UP once this first probe succeeds, not right after initialize() — then the two-tier health loop (liveness ping every 45 s bounded by ping_timeout, tools/list probe every 12 min). On failure — including one reported by the router via report_failure() for a routed call that hit a broken session — reconnect with exponential backoff + jitter (consecutive-failure count resets after a reconnect completes init and its first probe, not only on clean shutdown). report_failure() is generation-guarded: a stale report about an already-replaced session is a no-op. UpstreamRegistry.start() runs each supervisor behind an outer crash boundary (_supervise) so an unexpected exception in one upstream's lifecycle can never cancel sibling upstreams or the app's own task group — they share one anyio task group (see server.py/cli.py). Outbound redirects are off by default per upstream (allow_redirects); httpx strips Authorization but not custom headers like X-Auth-Token on a cross-origin redirect.
  • router.py — Splits <namespace><sep><tool> on the first separator, looks the namespace up in the registry, forwards the call verbatim. Returns JSON-RPC -32602 for unknown namespace, -32603 for a configured but DOWN upstream. A transport/protocol failure observed here (not a mere call-level timeout, and not a legitimate upstream tool error — those come back as ordinary isError results, never raised) is reported to the owning handle via report_failure(), forcing an immediate reconnect instead of waiting for the next scheduled health check.
  • catalog.py — Per-namespace cache of probed tool lists with a SHA-256 fingerprint over the entire Tool model (not hand-picked fields, so a change to outputSchema/annotations/title/etc. is detected too), plus a ChromaDB RagIndex (cosine similarity over tool description embeddings) for gateway.search_tools. Reindexing embeds the replacement documents before mutating the collection, then upserts new entries and removes only stale ones — a failed embed never empties a namespace's index. RagIndex.query(..., namespaces=...) filters results to the caller's currently-UP namespaces so search never suggests an unavailable tool.
  • server.py — Assembles everything into a FastAPI app; registers the gateway.search_tools tool and the /healthz endpoint. Uses a raw CallToolRequest handler (not the @server.call_tool() decorator) so McpError propagates as a genuine JSON-RPC error rather than an isError tool result.
  • observability.py — Optional OTel tracing; no-op when the SDK/endpoint is absent.
  • cli.py — Entry point (panda-gateway script), parses --config and --stdio flags.

Read the full file on GitHub · 118 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. 5d ago First seen · 118 lines · 2,824 tokens per session scan A 0feaac20cb93

Subscribe to this mod's changes

panda-gateway CLAUDE.md is an instructions file published in the GitHub repository PalNilsson/panda-gateway (0 stars, last pushed 1mo ago), licensed Apache-2.0. It adds 2,824 tokens to every session, about $0.0141 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other instructions, from other repositories

vscode buildNext.instructions.md

Working notes and architecture documentation for the new esbuild-based build system in build/next. Use when making changes to the new build pipeline (transpile/bundle commands, NLS plugin, source-map handling, resource copying, or self-hosting watch tasks).

microsoft/vscode · 6,785 tokens

codex AGENTS.md

AGENTS.md instructions for openai/codex, covering rust/codex-rs, the codex-core crate, code review rules, crate api surface and model visible context.

openai/codex · 5,182 tokens

vscode oss-third-party-notices.instructions.md

Instructions for microsoft/vscode, covering vs code oss third-party-notices pipeline, architecture, pipeline flow in ci, applying the notice (cutover) and fallback chain (never fail the build).

microsoft/vscode · 5,001 tokens

spec-kit AGENTS.md

AGENTS.md instructions for github/spec-kit, covering agents.md, about spec kit and specify, quickstart — add a new integration in 5 steps, integration architecture and integrationmanifest — file tracking.

github/spec-kit · 7,104 tokens

next.js AGENTS.md

AGENTS.md instructions for vercel/next.js, covering next.js development guide, codebase structure, monorepo overview, core package: packages/next and other important packages.

vercel/next.js · 7,296 tokens

langchain AGENTS.md

AGENTS.md instructions for langchain-ai/langchain, covering global development guidelines for the langchain monorepo, corridor security analysis, project architecture and context, monorepo structure and development tools & commands.

langchain-ai/langchain · 4,469 tokens