Repository navigation
feat(mcp): add a sendToolsListEvent option - #5404
Conversation
Coherence0 spec problems · 0 failing chokepoints · 2 spec gaps · 0 guard failures 44 components, 7 bullets (5 invariants, 2 requirements), 0 problems Chokepoints: none declared. Spec gaps: 2 entrances with outside or unknown trust and no traced control, and 10 more held by the adoption baseline
Close one with |
|
@PostHog review |
|
@gesh PostHog Review is reviewing this pull request. |
9649f86 to
52f806e
Compare
3cbc53a to
cca259f
Compare
There was a problem hiding this comment.
Not approved — escalated to a human reviewer.
Re-add the stamphog label to request another review once you have addressed this.
The disclosed changes enter public API and analytics write-path territory without current-head independent assurance; the older review does not cover the current head. Request a current-head review from Manoel Aranda Neto, another teammate, or an agent reviewer before re-requesting.
- Author wrote 0% of the modified lines and has 31 merged PRs in these paths (familiarity MODERATE).
- Risky territory without independent assurance: Public API contracts — packages/mcp/src/types.ts adds an optional setting to the exported MCPAnalyticsOptions interface, with its default supplied in packages/mcp/src/index.ts.; Data ingestion or write paths — packages/mcp/src/extensions/instrumentation.ts conditionally suppresses analytics capture for successful, empty, and failed tool listings, including associated exception events.
Gate mechanics and policy version
| Gate | Result | |
|---|---|---|
| prerequisites | ✓ | all clear |
| deny-list | ✓ | no deny categories matched |
| size | ✓ | 21L, 3F substantive, 89L/6F incl. docs/generated/snapshots — within ceiling |
| tier | ✓ | T1-agent / T1c-medium (89L, 6F, two-areas, feat) |
| stamphog 2.6.1 | .stamphog/policy.yml @ cca259f · reviewed head cca259f |
lucasheriques
left a comment
There was a problem hiding this comment.
LGTM, approving. One nit inline; the naming question on #5401 applies here too.
| } | ||
|
|
||
| /** Sends `$mcp_tools_list` unless the host set `captureToolsList: false`. */ | ||
| function captureToolsListEvent(...args: Parameters<typeof captureEvent>): void { |
There was a problem hiding this comment.
nit: could this be the same shape as captureInitialize in #5401, a plain if (data.options.captureToolsList !== false) at the emit points? The ...args: Parameters<typeof captureEvent> wrapper that looks up the tracking data again through args[0] is a bit indirect, and having the two options gated two different ways in the same file will trip someone up. getTracedToolsList would need data (or the flag) passed in, which seems fine.
cca259f to
ecaf13a
Compare
sendToolsListEvent: false stops $mcp_tools_list. The option is on by default. Clients list tools on every reconnect, so the listing event is about as common as $mcp_tool_call. All three places that send the event go through captureToolsListEvent, which skips the capture when the option is off. That also drops a failed listing's $exception. Nothing else changes: tools keep their injected arguments, and the virtual tools stay listed. The name says "event" to match sendInitializeEvent. PostHogMCP.captureToolsList() already captures the event by hand. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ize event The captureToolsListEvent wrapper read the tracking data again through its first argument. Now each of the three emit points checks sendToolsListEvent directly, as handleInitializeRequest does for sendInitializeEvent. getTracedToolsList gets the flag as an argument for its failed-listing path. The behaviour does not change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
0df7896 to
56ad84b
Compare
Problem
$mcp_tools_listis about as common as$mcp_tool_call.Follows #5401, which added the same option for
$mcp_initialize. Part of one change across three repos: PostHog/posthog-python#1116 and PostHog/sdk-specs#142.Changes
sendToolsListEvent.DEFAULT_OPTIONSsets it totrue, so nothing changes unless a host turns it off.sendInitializeEventin feat(mcp): add a sendInitializeEvent option #5401.PostHogMCP.captureToolsList()already captures the event by hand.sendToolsListEventwith a plainif, as feat(mcp): add a sendInitializeEvent option #5401 does for$mcp_initialize. A failed listing's$exceptiongoes too.minorchangeset.Testing
send-tools-list-event.test.tsruns a realMcpServerand client with the option on and off. A listing sends one or no$mcp_tools_list. The listed schema still has the injectedcontext, and the tool call still records its intent.$exception.test:integration:sdk-v1andtest:integration:sdk-v2pass. That includes the v2 matrix with its longlived rows.Release info Sub-libraries affected
Libraries affected
Checklist
If releasing new changes
pnpm changesetto generate a changeset file🤖 Agent context
Autonomy: Human-driven (agent-assisted)
claude-opus-5-5).tools/listwrapper still injects arguments, because tool calls depend on them.🤖 Generated with Claude Code