Skip to content

feat(mcp): instrument the remote MCP tool-dispatch chokepoint with PostHog events #6237

Description

@JSONbored

Context

Part of #6228. With the remote-side telemetry wrapper module in place (companion issue), this issue wires it into src/mcp/server.ts's actual tool-dispatch path.

Requirements

  • Find (or, if one doesn't cleanly exist, create) a single chokepoint in src/mcp/server.ts through which every registered tool's invocation passes, and call the telemetry wrapper's recordMcpToolCall there — one instrumentation point, not one per tool.
  • Record: tool name, caller type ("remote"), success/failure, and coarse latency (start-to-finish duration) — nothing else, per Spec: usage-telemetry instrumentation strategy for MCP (PostHog) #6228's field allowlist.
  • Must not change any tool's actual behavior or response shape — this is pure observability, zero functional change.
  • Must not throw or block a tool response if the telemetry call fails — telemetry failures are silently swallowed (matching the wrapper module's own no-op guarantee).

Test Coverage Requirements

99%+ Codecov patch coverage; a regression test confirming a tool call still succeeds and returns its normal response even if the telemetry call fails/throws.

Deliverables

  • Every tool invocation on the remote server triggers exactly one recordMcpToolCall.
  • Zero behavior change to any tool's actual response.

Expected Outcome

Real usage data starts flowing for every MCP tool call made against the remote server.

Links & Resources

Metadata

Metadata

Assignees

No one assigned

    Labels

    gittensor:featureGittensor-scored feature linked to a feature issue — scores a 0.25x multiplier.help wantedExtra attention is needed

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions