Skip to content

feat: record AI client metadata for telemetry#325

Draft
hubgan wants to merge 1 commit into
feat/structured-failure-telemetryfrom
feat/ai-client-tool-telemetry
Draft

feat: record AI client metadata for telemetry#325
hubgan wants to merge 1 commit into
feat/structured-failure-telemetryfrom
feat/ai-client-tool-telemetry

Conversation

@hubgan

@hubgan hubgan commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds a coarse, anonymous signal to tool telemetry: which AI coding tool is driving the MCP server (Claude Code, Codex, Cursor, Gemini, VS Code, Windsurf, Zed, opencode, Copilot, or other).

How it works

  1. Source of truth — the MCP initialize handshake clientInfo.name, read at runtime via Server.getClientVersion(). New ai-identity.ts in @argent/telemetry canonicalizes that raw name to a known slug. Unrecognized tools become other plus a bounded, sanitized free-form name.
  2. Cross-process hop — telemetry lives in the tool-server, but clientInfo lives in the MCP server process. The MCP server forwards the identity as X-Argent-AI-Client / X-Argent-AI-Client-Name request headers.
  3. Re-validation at the boundary — the tool-server re-checks both headers against the same allowlist/pattern the sanitizer enforces, so a misbehaving client can't inject arbitrary telemetry values. The free-form name is retained only when ai_client === "other".
  4. Threading through events — AiTelemetryProps is mixed into the tool event types and merged in the registry listener and tool-server stop handler via the shared aiTelemetryFromMeta helper, so keys are omitted entirely when absent.

Privacy

It records only which tool is connected. It is validated at the mcp-server, re-validated at the tool-server, and enforced a third time by the sanitizer allowlist before anything reaches PostHog. Path-like or oversized names are dropped.

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