fix(stdio): do not create SSE sessions for stdio requests #282
All Vouch review confidence checks passed
Residual risk 0.14 = Change Risk (0.37) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.37 · 218 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.322
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #282"
general
weight: 0.35
rozzilla
Problem
With
enableSSE: true, a POST withoutMcp-Session-Idcreates an SSE session: a session-store entry, a broker subscription onmcp/session/<id>/message, and alocalStreamsentry. These are only freed when a GET stream closes, onDELETE, or at shutdown. The stdio transport never sends a session id and never opens a GET stream, so every stdio message leaked a session. Oneinitializeplus 50pings left 51 subscriptions behind.Fix
POST /mcphandler skips SSE session creation for requests that come from the stdio transport.x-platformatic-mcp-transport: stdioto identify those requests, because any HTTP client can send that header. The stdio transport now also sends a per-process random token header (x-platformatic-mcp-stdio-token) on its injected requests. The token never leaves the process.isStdioRequest()in the newsrc/stdio-marker.tschecks it.network.transport = pipedetection uses the same check, so a spoofed header no longer changes span attributes either. The old header is still sent for compatibility.Tests
enableSSEwith stdio overPassThrough,initializefollowed by 50pings, creates nomcp/session/*subscriptions. It failed before the fix with 51.x-platformatic-mcp-transport: stdiostill gets an SSE session.Not in this PR
The second half of the issue is expiring sessions that a POST created but that never got a GET stream. Open PR #242 (
sessionTtlMsidle expiry) covers that, so this PR doesn't duplicate it.Fixes #257
🤖 Generated with Claude Code
https://claude.ai/code/session_01UF4S3w7iA83V9DVsasLJzM