fix: intercept GET /mcp in session registry + request logger (#178)#233
Conversation
Session registry now handles GET /mcp with session IDs — previously only POST/DELETE were intercepted, causing stale SSE reconnects to bypass re-initialization and get 409 from FastMCP directly. New McpRequestLogger middleware logs method, truncated session ID, client IP, and response status for every /mcp request. Placed outside the session registry for full visibility. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The exact count goes stale on every PR and adds maintenance burden. CI badge and coverage reports are the authoritative source. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Additional commit (f9a60eb): Removed exact test count from README. The count went stale on every PR and QA flagged it multiple times this session. CI badge and Codecov reports are the authoritative source — no more manual maintenance. |
|
Adding QA Active — reviewing GET /mcp intercept fix. |
cmeans
left a comment
There was a problem hiding this comment.
QA Review — Round 1
Code review
Session registry GET intercept — minimal, targeted fix. Two lines changed in session_registry.py: added "GET" to the method filter and to the _handle_subsequent routing. GET requests with session IDs now go through the same lookup → validate owner → pass through / re-init path as POST requests.
McpRequestLogger — clean ASGI middleware. Logs method, truncated session ID (12 chars + ellipsis), client IP, and response status. Placed outside the session registry (between session registry and SecretPathMiddleware) so it captures both intercepted and pass-through requests. Only logs /mcp requests — health checks and other paths skip.
README — replaced specific test count with "Comprehensive test suite". Prevents recurring test count drift.
| Check | Result |
|---|---|
GET now routed through _handle_subsequent |
✅ |
| GET without session passes through (no interception) | ✅ |
| Logger truncates session IDs > 12 chars | ✅ |
| Logger skips non-MCP paths | ✅ |
| Logger placed outside session registry in both MOUNT_PATH and plain transport paths | ✅ |
| CHANGELOG: both entries (Added + Fixed) | ✅ |
| README: "Comprehensive test suite" replaces count | ✅ |
| 763/763 full suite pass | ✅ |
| CI all green | ✅ |
Manual test results (Docker QA instance)
| # | Test | Result |
|---|---|---|
| 1 | Request logger output | ✅ MCP POST /mcp session=none/... visible in logs |
| 2 | GET with stale session intercepted | ✅ Middleware intercepts, routes through _handle_subsequent |
| 3 | GET without session passes through | ✅ Returns 400 from FastMCP (no handshake) |
| 4 | Non-MCP paths not logged | ✅ Zero MCP log lines for /health |
Test sufficiency
The 4 GET intercept tests cover the key cases: known session (pass through), no session (pass through), unknown session (404 from FastMCP), and owner mismatch (403). The 4 logger tests cover POST with/without session, GET, non-MCP skip, and non-HTTP scope. Solid coverage for both features.
Zero findings. Verdict: Pass — ready for signoff.
|
Applying Ready for QA Signoff — GET intercept and request logger both verified on Docker QA instance, 763/763 tests pass, CI green, zero findings. |
6 bug-fix PRs since v0.16.1: - #226 LazyStore thread safety (#164) - #227 SQL template injection hardening (#165) - #232 Stateless HTTP mode (#180) - #233 GET /mcp intercept + request logger (#178) - #234 delete_entry IDOR fix (#193) - #236 RLS-safe opt-in cleanup (#179, #183) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
6 bug-fix PRs since v0.16.1: - #226 LazyStore thread safety (#164) - #227 SQL template injection hardening (#165) - #232 Stateless HTTP mode (#180) - #233 GET /mcp intercept + request logger (#178) - #234 delete_entry IDOR fix (#193) - #236 RLS-safe opt-in cleanup (#179, #183) Co-authored-by: cmeans-claude-dev[bot] <3223881+cmeans-claude-dev[bot]@users.noreply.github.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
GET /mcp(SSE reconnect) with session IDs — previously only POST/DELETE were handled, causing stale GET requests to return 409 directly from FastMCPMcpRequestLoggermiddleware logs method, truncated session ID, client IP, and response status for every/mcprequestCloses #178
QA
Prerequisites
pip install -e ".[dev]"AWARENESS_PORT=8421)Manual tests (via MCP tools)
_handle_subsequent(confirmed via log)🤖 Generated with Claude Code