Repository navigation
Conversation
There was a problem hiding this comment.
PostHog Review · Standard · reviewed 4571911: 1 Should fix.
This is the only automatic review while this pull request is a draft. Comment @posthog review to review new changes sooner. Otherwise, a review of the new changes runs when you mark it ready for review.
See this review and its findings in PostHog Review. Comment @posthog review --deep for a Deep review. A Deep review takes longer and looks deeper than a Standard review.
MCPAnalyticsOptions(capture_initialize=False) stops $mcp_initialize. The option is on by default. Many clients reconnect before every few tool calls, so the handshake event can outnumber $mcp_tool_call. With the option off, record_initialize and the first-request fallback return early. Nothing else changes: the middleware still mints the session token, so tool calls keep their sessions and client names. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4571911 to
dca253f
Compare
posthog-python Compliance ReportDate: 2026-10-23T13:49:19.359903+00:00 ✅ All Tests Passed!121/121 tests passed Capture_V1 Tests✅ 95/95 tests passed View Details
Capture_Ai Tests✅ 5/5 tests passed View Details
Feature_Flags Tests✅ 17/17 tests passed View Details
Feature_Flags_Local_Evaluation Tests✅ 4/4 tests passed View Details
|
record_initialize returned before handle_identify when the option was off. An identify callback that resolves the user only from the initialize request then left the session anonymous, so later tool calls lost the user. Identify now runs first, and the option stops only the event. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@PostHog review |
|
@gesh PostHog Review is reviewing this pull request. |
There was a problem hiding this comment.
Not approved — this change needs a human reviewer.
Re-adding the stamphog label gives the same result unless the changed files change.
stamphog can't approve this pull request, because two gates refused it. The deny-list gate matched public_api: the change adds capture_initialize to MCPAnalyticsOptions in posthog/mcp/types.py and updates references/public_api_snapshot.txt. The tier gate classified the change as T2-never (108 lines across 6 files, cross-cutting, a feature), so it always needs a human reviewer. The size gate passed, so splitting the PR won't change this outcome. The next step is to ask a human maintainer to review it, ideally one who owns the public API surface of the MCP module.
- posthog[bot] reviewed the current head.
Gate mechanics and policy version
| Gate | Result | |
|---|---|---|
| prerequisites | ✓ | all clear |
| deny-list | ✗ | matches: public_api |
| size | ✓ | 14L, 2F substantive, 108L/6F incl. docs/generated/snapshots — within ceiling |
| tier | ✗ | classified as T2-never: T2-never (108L, 6F, cross-cutting, feat) |
| stamphog 2.6.1 | .stamphog/policy.yml @ unknown · reviewed head 7e1f2f7 |
💡 Motivation and Context
$mcp_initializecan outnumber$mcp_tool_call.Part of one change across three repos: PostHog/posthog-js#5401 (
@posthog/mcp) and PostHog/sdk-specs#141 (the spec).Follow-up, stacked on this PR: #1116 adds the same option for
$mcp_tools_list.Changes
MCPAnalyticsOptions(capture_initialize=False). It is on by default, so nothing changes unless a host sets it.record_initializeand the first-request fallback return early. These are the only places that send the event.minorchangeset.💚 How did you test it?
test_capture_initialize_off_sends_no_initialize_and_keeps_sessionsdrives two round-robin pods over HTTP, for the SDK high-level server, standalone fastmcp, and a low-levelServer, on both SDK majors. It asserts no$mcp_initialize, a minted token, each connection's tool calls in that token's session, and the client name on every pod.test_capture_initialize_off_also_gates_the_first_request_fallbackcovers SDK 1.x without HTTP, as on stdio, with the option on and off.📝 Checklist
If releasing new changes
sampo addto generate a changeset file🤖 Agent context
Autonomy: Human-driven (agent-assisted)
claude-opus-5-5).🤖 Generated with Claude Code