feat(mcp): add HTTP request log middleware and hosted wiring (#373 stack 2/3)#376
Draft
adriannoes wants to merge 3 commits into
Draft
feat(mcp): add HTTP request log middleware and hosted wiring (#373 stack 2/3)#376adriannoes wants to merge 3 commits into
adriannoes wants to merge 3 commits into
Conversation
This was referenced Jul 8, 2026
Emit one structured JSON line per HTTP request from middleware that only inspects response.start, stores request_id in scope state, and reads caller identity from the auth context at emit time.
Wire RequestLogMiddleware through streamable_http_app once and replace FastMCP.run(streamable-http) with explicit uvicorn serve and access_log disabled so structured request lines replace text access logs.
configure_observability_logging ran before the transport branch, arming a stdout handler in the stdio process too, where stdout is the JSON-RPC wire. Nothing emits under stdio today, but the D10 guarantee was conventional rather than structural: one future emit call in shared code would corrupt the protocol. The call now lives in _serve_streamable_http, and the stdio test asserts configuration never happens there. Also imports AuthenticatedUser from its defining module (bearer_auth) and extends the middleware tests: bearer absent from output with an Authorization header planted, UnauthenticatedUser yields null identity, the ordering test fails fast instead of hanging, and a send that raises mid-stream still emits exactly one line.
a843c1c to
f9bca74
Compare
651dec7 to
932c9f2
Compare
This was referenced Jul 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #373 (stack 2/3). Depends on #375.
Summary
RequestLogMiddleware: one JSON line per HTTP request, no body buffering (ordering + disconnect tests).wire_hosted_observability: callsstreamable_http_app()once, mounts middleware, storesrequest_idinscope["state"].access_log=False(structured lines replace text access logs).What lands
Structured HTTP request lines on the hosted profile. Tool-call lines arrive in stack 3/3 (#377).
Stack status
dev(post-refactor: reshape the Pipefy client into an engine/session split #348) and restacked on feat(mcp): add JSON structured logging emitter and JWT sub claim (#373 stack 1/3) #375.Test plan
uv run pytest packages/mcp/tests/observability/test_request_log_middleware.py packages/mcp/tests/observability/test_wiring.py -quv run pytest packages/mcp/tests/test_server.py -qrg BaseHTTPMiddleware packages/mcp/src(only documented prohibition in AGENTS.md)