Capture host environment signals on MCP initialize#540
Open
edgarsskore wants to merge 2 commits into
Open
Conversation
Claude Code CLI, Claude Code inside the Claude Desktop app, and Cowork all report clientInfo.name 'claude-code', so client_name alone cannot attribute initializes to the actual host. Capture three raw, non-PII environment signals on run_server_mcp_initialized so analytics can tell them apart without client-specific branching in code: - host_entrypoint (CLAUDE_CODE_ENTRYPOINT): 'cli' for Claude Code CLI, 'claude-desktop' for Claude Code inside the desktop app - host_agent (AI_AGENT): e.g. 'claude-code_2-1-198_harness' - host_plugin_id (basename of CLAUDE_PLUGIN_DATA): plugin identifier, e.g. 'desktop-commander-inline' for the desktop app's inline plugin Verified against production telemetry with one controlled initialize per host: Cowork sets no entrypoint/agent but carries the inline plugin id, giving a distinct signature for all three contexts. Clients that set none of these send no extra fields. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthrough
ChangesInitialization Telemetry Enrichment
Estimated code review effort: 1 (Trivial) | ~3 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Same convention as containerName/containerImage: an oversized environment value can get the whole event rejected by GA4, so clip each host signal to 100 chars instead of trusting host-controlled env vars to be short. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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
Telemetry-only change, no behavior impact. Claude Code CLI, Claude Code inside the Claude Desktop app, and Cowork all report
clientInfo.name = 'claude-code', soclient_namealone cannot attribute initializes to the actual host.Adds three raw, non-PII environment signals to the existing
run_server_mcp_initializedevent (no new event types):host_entrypointCLAUDE_CODE_ENTRYPOINTcliclaude-desktophost_agentAI_AGENTclaude-code_<v>_harnessclaude-code_<v>_harnesshost_plugin_idCLAUDE_PLUGIN_DATAdesktop-commander-inlinedesktop-commander-inlineNo client-specific branching in code — raw values are captured and segmentation happens in analytics:
Testing
Verified end-to-end against production BigQuery telemetry with one controlled initialize per host (fresh client id each): all three contexts produced distinct signatures; non-Claude clients (e.g.
codex-mcp-client) send no extra fields. Only the basename ofCLAUDE_PLUGIN_DATAis captured — no user paths.🤖 Generated with Claude Code
Summary by CodeRabbit