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.
npx agentmods add instructions/shigechika/mcp-stdio/claude-mdgit clone --depth 1 https://github.com/shigechika/mcp-stdioWrote 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/shigechika/mcp-stdio/claude-md)<a href="https://agentmods.dev/instructions/shigechika/mcp-stdio/claude-md"><img src="https://agentmods.dev/badge/instructions/shigechika/mcp-stdio/claude-md.svg" alt="Measured on agentmods" 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 | $0.02769 | $0.02769 |
| Opus 5 | $0.01385 | $0.01385 |
| Sonnet 5 | $0.00554 | $0.00554 |
| Haiku 4.5 | $0.00277 | $0.00277 |
Grade A, and why
mcp-stdio CLAUDE.md scanned grade A with 0 findings 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 4d 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.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 66 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.
Language Policy (Public Repository)
- Code comments, commit messages, documentation, and PR descriptions: English
- README.md in English; README.ja.md in Japanese
Build & Test
# Setup
python3 -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
# Run all tests
pytest tests/ -v
# Run a single test file or class
pytest tests/test_relay.py -v
pytest tests/test_relay.py::TestWriteLine -v
# Integration harness against python-sdk v2, the 2026-07-28 reference peer
# (#367). Real localhost HTTP and a real relay subprocess, so it is a
# SEPARATE directory the unit gate never walks. Needs the extra; without it
# a conftest guard skips collection.
pip install -e ".[dev,integration]"
pytest tests_integration/ -v
# Build package
pip install build && python -m build
Uses hatchling as the build backend (build-backend = "hatchling.build" in pyproject.toml). Version is defined in src/mcp_stdio/__init__.py (__version__).
Architecture
A gateway between stdio JSON-RPC framing and MCP's HTTP transports, in both directions:
- relay (the original job,
relay.py) — the client side (stdin/stdout in, HTTP out): translates a local stdio MCP host to a remote Streamable HTTP or legacy SSE server. - serve (
server.py,mcp-stdio serve) — the mirror image, the server side (HTTP in, stdio out): publishes a locally-spawned stdio MCP server as a Streamable HTTP endpoint.
Only runtime dependency is httpx (the serve path is stdlib-only).
The substantive modules under src/mcp_stdio/:
relay.py— Two transport implementations sharing stdin/stdout plumbing (file name kept for import compatibility):run()— Streamable HTTP transport (MCP current spec, default). Reads JSON-RPC from stdin line-by-line, streams POST to the remote URL via httpx, parses JSON or SSE responses, writes to stdout. On the modern era (2026-07-28) a dedicated daemon reader thread owns stdin and feeds a FIFO queue, so anotifications/cancelledcan abort the matching in-flight POST by closing its response stream; the legacy era keeps the literal synchronous stdin loop and spawns none of the modern era's threads (stdin reader, listen/resource streams). OAuth machinery is era-independent, though:_start_proactive_refresh()and the--oauth-eagercold-start daemon are both started unconditionally, before the era branch, so either can put a daemon thread on the legacy era too when OAuth is configured. Handles retry with backoff (3 attempts), session ID tracking (Mcp-Session-Idheader), 404-based session recovery, and 401-based token refresh.run_sse()— SSE transport (MCP 2024-11-05 legacy). Spawns a daemon reader thread that maintains a long-livedGET /sseconnection, parsesendpoint/messageevents per the WHATWG SSE spec, and resolves the POST endpoint URL (possibly relative). The main thread reads stdin and POSTs to that endpoint. Auto-reconnects on stream disconnect, synthesizing a-32000error for every request whose reply was still in flight on the dropped stream (tracked in_SseState.pending, drained by_drain_pending; cancelled ids are skipped).- Both paths enforce the MCP cancellation spec's receiver-side SHOULD (and shield the client from canceller-side bugs) via a shared
_CancelTracker+_emitgate: ids seen innotifications/cancelledon stdin are tracked with a 60 s TTL, and any late JSON-RPC response for a tracked id is dropped before it reaches stdout. Disable with--no-cancel-filter. - Signal handlers (
signal.signal) are set from the main thread only — both transports now run daemon threads (run_sse's SSE reader;run()'s modern-era listen/resource streams and stdin reader;run()'s OAuth proactive-refresh and cold-start daemons, on either era), so pytest tests must driverun()andrun_ssefrom the main thread.
cli.py— argparse-based CLI. Builds headers, resolvesMCP_BEARER_TOKEN/MCP_OAUTH_CLIENT_IDenv vars, runs the OAuth flow before relay if--oauthor--oauth-deviceis set, and dispatches torun()orrun_sse()based on--transport.oauth.py— OAuth 2.1 client: RFC 9728/8414 discovery, RFC 7591 dynamic client registration, RFC 7636 PKCE, RFC 8707 resource indicators, authorization code flow with localhost callback server, RFC 8628 device authorization grant, RFC 9470 step-up authorization, token exchange and refresh.token_store.py— Token persistence in~/.config/mcp-stdio/tokens.json(0o600). Stores per-server-URL tokens with client credentials and endpoint URLs for refresh. Migrates legacy~/.mcp-stdio/tokens on first read.server.py— themcp-stdio servereverse gateway (dispatched fromcli.pywhenargv[1] == "serve"). Dual-era since #270 Phase 3: one endpoint answers both revisions, and_request_era()classifies each POST body conservatively — modern only on positive evidence (params._metacarries theprotocolVersionKEY, or the method isserver/discover); everything else falls through to the untouched legacy path.- Legacy path (unchanged, AC2). One backend stdio child per MCP session (
SessionRegistry, keyed onMcp-Session-Id) over a stdlibhttp.serverStreamable HTTP endpoint: session minted oninitialize, 400 sessionless, 404 on an unknown id, DELETE to terminate, GET SSE for server-initiated messages. Pinned byte-for-byte bytests_integration/test_serve_legacy_pin.py, which every Phase 3 PR had to keep green with zero diffs. - Modern path (2026-07-28). A request-plane validation ladder (
_validate_modern; first failure wins, in python-sdk v2's order — the header rungs run BEFORE the unsupported-version rung): required_meta→-32602;MCP-Protocol-Version/Mcp-Method/Mcp-Nameagreement, the last sentinel-decoded via relay's_decode_mcp_name→-32020; unsupported version →-32022withdata.supported. Notifications are exempt from the ladder entirely (O9)._dispatch_modernthen serves the request statelessly from aModernBackendPoolchild, keyed on the authenticated principal and NOT on a session (one shared child under no-auth or a static token, one per OAuth user), with the gateway performing theinitialize+notifications/initializedhandshake the modern wire omits and caching the result.server/discoveris synthesised locally and never forwarded (a legacy child would answer-32601); every modern result is stampedresultType: "complete", the six cacheable ops additionally getttlMs(--cache-ttl-ms, default 60000) /cacheScope: "private", and every result carries the child'sserverInfounder_meta. Client ids are remapped to a mintedmcp-stdio/serve/id so concurrent stateless clients sharing one child cannot collide.subscriptions/listenis SERVED by serve itself, never forwarded: SCOPE is the listChanged trio (_LISTEN_FILTER_METHODS, #374) plusresourceSubscriptions(#381, detailed below), honor-all on the three booleans, attach-BEFORE-ack, ack as frame 1 with the honored subset atparams.notificationsand the id atparams._meta[subscriptionId](both nestings are load-bearing — a top-level echo is silently ignored by a compliant client). Every frame is stamped with the subscription id.BackendProcessfans notifications out to attached_ListenStreams (filtering on the reader thread, bounded 1024-deep queue per stream, ≤4 streams per pooled child →-32603/503 pre-ack). Endings: gateway shutdown → terminalresultType: "complete"frame then close (signal_end(graceful=True)+ a boundeddrain_listeners); child death or backlog overflow → abrupt close with NO terminal frame; NEVER a server-sentnotifications/cancelled(the v2 client settles that as LOST). First ending wins. #381 added the fourth field,resourceSubscriptions: honoring is entirely LOCAL (child's advertisedresources.subscribevia_child_supports_resource_subscribe, then sanitize + dedup + cap at_LISTEN_MAX_RESOURCE_SUBSCRIPTIONS=256with truncate-and-honor), so the ack ships BEFORE anyresources/subscribeis driven — the drive runs on a background daemon thread and can never stall the ack or the pump.notifications/resources/updatedgets its OWN routing branch (never folded into_LISTEN_FORWARDED_METHODS, which would make any non-empty URI list match every URI and leak across streams); matching is exact string equality, no normalization. URIs are refcounted per child inBackendProcess._resource_refsunder a dedicated_sub_lockHELD ACROSS the send (order_sub_lock->_lock, never reversed): subscribe on the first reference, unsubscribe on the last, ids from the existing_mint_modern_id()._ListenStream.torn_downcloses the async-drive-vs-sync-release race. Failure is reply-then-degrade (log once per URI per stream via_ListenStream.subscribe_failure_logged, #388 review, keep honored)._UNDELIVERABLE_NOTIFICATION_FLAGSstill listsresources.subscribeas the DEFAULT, lifted per-child by_synthesize_discover_result'skeep=on the same predicate the ack uses. O16 is closed by construction, zero production code:notifications/messageis never in any listen-forward set, serve's modern face has no other streaming channel to gate, and SEP-2577 deprecated the feature. Pool lifecycle (#376): entries carry aholdscheckout refcount (taken byget_or_create, released in_dispatch_modern'sfinally) which — together withhas_pendingand the PENDING check — forms the single_reapable_lockedpredicate shared by cap-eviction and themodern-pool-reaperidle thread (--modern-idle-ttl, 0 = off);holdsis also #374's attach seam.--modern-onlyrefuses legacy callers after the auth gate (GET/DELETE 405 +Allow, legacyinitialize→-32022). - Auth is optional, layered, and applies to both eras: open by default,
--auth-token(or theMCP_STDIO_SERVE_TOKENenv var, preferred so the token isn't exposed inps) for a static bearer, or--enable-oauthfor an embedded OAuth 2.1 authorization server with optional--token-storepersistence. IncomingHost/X-Forwarded-Hostvalues are sanitized against_HOST_ALLOWEDbefore they reach theWWW-Authenticatechallenge / metadata responses. Stdlib only — adds no runtime dependency.
- Legacy path (unchanged, AC2). One backend stdio child per MCP session (
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.
- 4d ago First seen · 66 lines · 2,769 tokens per session scan A 0a3457f531de
mcp-stdio CLAUDE.md is an instructions file published in the GitHub repository shigechika/mcp-stdio (8 stars, last pushed 12d ago), licensed MIT. It adds 2,769 tokens to every session, about $0.0138 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.
Other instructions, from other repositories
Ruckus-vSZ-MCP AGENTS.md
AGENTS.md instructions for 0xEkho/Ruckus-vSZ-MCP, covering agents.md — ruckus vsz mcp server, vue d'ensemble du projet, agents disponibles, flux de travail pour une nouvelle fonctionnalité and canonical tool registry (52 tools — 12 modules).
Ruckus-vSZ-MCP copilot-instructions.md
Copilot instructions for 0xEkho/Ruckus-vSZ-MCP, covering copilot instructions — mcp template, quand invoquer les 4 agents (obligatoire), protocole de réponse and rappels mcp non négociables.
casdoor CLAUDE.md
Claude Code instructions for casdoor/casdoor, a project described as: An open-source Agent-first Identity and Access Management (IAM) /LLM MCP & agent gateway and auth server with web UI supporting OpenClaw, MCP, OAuth, OIDC, SAML, CAS, LDAP, SCIM, WebAuthn, TOTP, MFA, Face ID, Google Workspace, Azure AD.
casbin-gateway CLAUDE.md
Claude Code instructions for apache/casbin-gateway, covering claude.md and code style.
pi-anthropic-auth AGENTS.md
Instructions for gotgenes/pi-anthropic-auth, covering agents guide: pi-anthropic-auth, project, primary goal, current status and principles.
pixiv-cli AGENTS.md
AGENTS.md instructions for FlanChanXwO/pixiv-cli, covering agents.md, 核心命令, 边界规则, 注意事项 and 文档路由.