Record how MCP queries arrive: transport, protocol, client - #173
Merged
Merged
Conversation
…ient id columns to query_log
…te-limited warning, and normalise the request-context fields in logQuery
…port accepts it, and write the session analytics context from the search and knowledge tools
…and unclassified rows in the analytics summary
… summary omits the count
… in the weekly search report
…t and IP context, and read unique clients from the real summary
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.
Summary
Phase P2 of the stateless-MCP migration plan. Every query_log row now records how the query arrived: transport, protocol era, the protocol version the client requested, client name, and OAuth client id. The analytics summary adds unique clients and a protocol/transport mix, including unclassified counts. The dashboard gets a "Unique Clients" tile. The weekly report gets "Unique clients" and "Protocol mix" lines with coverage ("N of M calls classified", plus partial/inconsistent markers). This is the baseline we need before the new stateless protocol ships (P4), so we can see adoption.
Changes
Worth calling out:
protocol_erais "legacy" for every current writer; "modern" is reserved for the stateless protocol.Local red-green proof
RED ran on 9d6f5e4. The final GREEN ran on d2a32be, whose tree is identical to this head after the commit regroup.
RED vs GREEN on final commit d2a32be (source: p2-red.txt vs p2-green-final.txt)
\d query_lognulbad😀client(NUL stripped, emoji kept, 13 chars, has_nul=f)Review
Three rounds of 25 reviewers each, then a narrowed final pass under surgical scope. The one bug fixed in the final pass: the accessor-failure path (errorClassName / analyticsContextFields) could throw and fail the tool call.
Tests
4202 passing. tsc (both projects), build, prettier with CI's globs, test-shape and version-sync are all clean.
Follow-ups (not in this PR)
Test-strength gaps and comment-accuracy items deferred under surgical scope:
Pre-existing bugs found during review:
getMachineRelayRulesbare catch silently disables relay exclusion (src/db/analytics.ts:187)./messagessession lookup uses a plain-object index, so a prototype-key sid resolves to an inherited property (src/sse-handlers.ts:410)./messages404 log lines log ip and sid unsanitized.src/mcp/tools/knowledge.ts:358returns raw error text to the client.src/server.ts:4131swallows a getConfig throw with no log.Context
Plan: https://www.notion.so/3ed3aa38185281d89892e2c4a20ed154
P1: #172
🤖 Generated with Claude Code
https://claude.ai/code/session_01EDxYQLKhDxwoYe8GV2noDY