Repository navigation
Conversation
A tool on the 2026-07-28 revision that asks for more input (for example a confirmation form) answers tools/call with an InputRequiredResult and runs on the client's retry. The SDK counted the round and the retry as two successful $mcp_tool_call events. - instrument(): a round sends $mcp_input_required with $mcp_tool_name, $mcp_duration_ms and $mcp_input_request_methods. Only the retry that completes the call is a $mcp_tool_call. The requests, answers and requestState are never captured. - A round returned to a client on an earlier revision, which mcp answers with an error, is a failed $mcp_tool_call with $mcp_error_type "input_required" instead of a successful one. - PostHogMCP.capture_input_required() for custom dispatchers. - The branch lives in ToolCallLifecycle.record_result, so every adapter gets it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A custom dispatcher had to check the result type itself and hardcode the methods it passed to capture_input_required(). prepare_tool_result() now sets PreparedToolResult.input_request_methods when the result is an input_required round, ordered by key, and leaves it None otherwise. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SDK performance: posthog-pythonBenchmarks completed. No changes flagged for review. Flags require at least a 5% change in the median and all six pairs agreeing on direction. This is a noise filter, not proof of a performance change or a CI gate. View all results
Values are medians of paired measurements. Not flagged does not mean unchanged. Unavailable means a measurement could not be provided, not zero. Estimated allocation measurements retain their instrumentation uncertainty. RSS measures the whole process, not just SDK allocations; observed peaks are sampled checkpoints. Paired ranges in the diagnostics describe variability, not confidence intervals. Each shard uses its own runner; compare Before PR against With PR within a row, not across shards. Compared 102 metric rows; 102 rows shown in all results. Omitted or shortened data remain in |
PR overviewThe PR adds instrumentation to record MCP input-required rounds as One privacy issue remains open: the new event path does not apply configured event options before capture. For identified sessions, this can cause events to omit host-requested cookieless and person-profile processing restrictions. No issues have been addressed yet. Open issues (1)
Fixed/addressed: 0 · PR risk: 4/10 Reviews
|
|
@PostHog review --deep |
|
@gesh PostHog Review is reviewing this pull request. |
There was a problem hiding this comment.
PostHog Review · Standard · reviewed 712e69c: 1 Must fix.
New pushes to this pull request won't start an automatic review. Comment @posthog review to review new changes.
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.
| await _apply_event_properties( | ||
| data, event, build_tool_call_request(name, arguments), extra | ||
| ) | ||
| stamp_transport_identity(event, extra) | ||
| fire_and_forget(capture_event(data, event), data) |
There was a problem hiding this comment.
P1 · Apply configured event options to input-required events
When instrument() configures an event_options callback, record_input_required never invokes it. Consequently, $mcp_input_required loses options such as cookieless_mode, even though the same request previously received them through record_tool_call. Call _apply_event_options with the tool request before scheduling capture.
PostHog Review · Deep · reviewed
|
| Step | Status | Result |
|---|---|---|
| Prepare the diff | done | 10 files, 1 chunk |
| Pick perspectives | done | 3 perspectives |
| Run review passes | done | 6 issues (+1 blind-spot) |
| Merge overlapping findings | done | 7 → 5 |
| Validate findings | done | 1 kept, 4 dismissed |
| Publish | done | 1 posted (view review) |
| await _apply_event_properties( | ||
| data, event, build_tool_call_request(name, arguments), extra | ||
| ) | ||
| stamp_transport_identity(event, extra) |
There was a problem hiding this comment.
Medium: Input-required events bypass configured privacy options
Unlike record_tool_call(), this path never calls _apply_event_options: for an identified session, a callback returning {"cookieless_mode": True, "process_person_profile": False} still produces an event with options={}. Apply the callback before capture so these events preserve the host's configured privacy restrictions.
| stamp_transport_identity(event, extra) | |
| await _apply_event_options( | |
| data, event, build_tool_call_request(name, arguments), extra | |
| ) | |
| stamp_transport_identity(event, extra) |
| if methods is not None: | ||
| # A legacy client cannot receive the round, so the framework answers | ||
| # with an error and the call ends there. | ||
| result, error_type = None, INPUT_REQUIRED_ERROR_TYPE | ||
| failure = error or LEGACY_INPUT_REQUIRED_MESSAGE |
There was a problem hiding this comment.
P2 · Classify legacy FastMCP 4 rejections as input_required
Standalone FastMCP 4 rejects a legacy tool's InputRequiredResult inside _on_call_tool(), before the wrapped handler returns. _wrap_v2_call_tool() therefore calls record_error(), which never sets INPUT_REQUIRED_ERROR_TYPE. Reproduced with FastMCP 4.2.1 and protocol 2025-11-25: the failed $mcp_tool_call has $mcp_error_type: "MCPError". This branch therefore misses the new legacy classification for a supported adapter. Observe FastMCP's interim result before its legacy rejection, or recognize this specific rejection in the error path. Pass INPUT_REQUIRED_ERROR_TYPE through record_error() while preserving the original exception. Add a legacy FastMCP 4 wire test.
💡 Motivation and Context
Changes
instrument()sends$mcp_input_requiredfor each round, as the spec defines and Go and Rust do. It carries the tool name, duration and request methods only.prepare_tool_result()returns the round'sinput_request_methods, andPostHogMCP.capture_input_required()records them.ToolCallLifecycle.record_result, which every adapter calls. mcp 1.x servers see no change.$mcp_tool_call$mcp_input_required$mcp_tool_call$mcp_tool_call$mcp_tool_call, success$mcp_tool_call,input_requirederrorExample event and custom dispatcher
{ "event": "$mcp_input_required", "properties": { "$mcp_tool_name": "delete_project", "$mcp_duration_ms": 3.2, "$mcp_input_request_methods": ["elicitation/create"], "$mcp_protocol_version": "2026-07-28", "$session_id": "ses_...", "$mcp_source": "posthog_mcp_analytics" } }💚 How did you test it?
resources/readandprompts/getrounds. Not run against a real MCP client.📝 Checklist
If releasing new changes
sampo addto generate a changeset file🤖 Agent context
claude-opus-5-5). Skills:debugging-mcp-analytics,writing-pr-descriptions.More context for AI agents
events.mdxtable.record_resultturns the 4 automatic-instrumentation tests red.🤖 Generated with Claude Code