Skip to content

feat(mcp): add structured analytics logging - #328

Open
nuclearcat wants to merge 1 commit into
kernelci:mainfrom
nuclearcat:feat/mcp-analytics-reviewed
Open

nuclearcat wants to merge 1 commit into
kernelci:mainfrom
nuclearcat:feat/mcp-analytics-reviewed

Conversation

@nuclearcat

Copy link
Copy Markdown
Member

Add newline-delimited JSON analytics for MCP tool usage, outcomes, latency, and server lifecycle events. Analytics go to stderr by default or an append-only file selected with --log-file, and omit arguments, results, credentials, and exception messages.

Replaces #319 following the request to submit a new PR when ready. Addresses all three review comments:

  • Check pending cancellation after the protocol handler returns, so cancellation during shielded tool_offload() execution is recorded correctly. A protocol-level test cancels the registered get_node tool while its worker is blocked.
  • Use WatchedFileHandler to reopen externally rotated files on Unix. Test rename-and-replace rotation and document the Windows stop/rotate/restart procedure.
  • Restore the logger level with setLevel() to invalidate Python's enabled-level cache. Test logging after both normal and exceptional context exits.

Validation: the full suite passes (713 tests on Python 3.14 with MCP 1.30.0), including all 11 analytics tests; the four added regression cases fail against the original implementation. Black, isort, and git diff --check pass.

Assisted-by: OpenAI Codex

Record tool outcomes and latency, including pending cancellation after shielded worker execution. Support external file rotation and restore logger configuration through its public API.

Assisted-by: OpenAI Codex
Signed-off-by: Denys Fedoryshchenko <denys.f@collabora.com>
@nuclearcat
nuclearcat force-pushed the feat/mcp-analytics-reviewed branch from 00ffc84 to 16c7f9b Compare November 2, 2026 11:29

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant