feat(mcp): support conversations in custom dispatchers - #982
Conversation
posthog-python Compliance ReportDate: 2026-10-01T15:55:16.439579+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
|
PR overviewAll previously flagged issues have been addressed. No open security concerns remain on this pull request. Security reviewNo open security issues remain on this pull request. Fixed/addressed: 1 · PR risk: 0/10 |
|
[Medium risk] Adds conversation tracking to the MCP dispatcher API. The PR is not safe to merge until SDK-free custom dispatchers can return non-dict tool results without the MCP SDK installed. Reviews (2) · Last reviewed commit: "fix(mcp): preserve conversation result i..." |
Port posthog-js#5074 to PostHogMCP. Custom dispatchers now correlate calls through an agent-carried conversation_id and a derived session id, like instrument() already does. - enable_conversation_id constructor option, on by default - prepare_tool_list() injects conversation_id and _mcp_instructions - prepare_tool_call() accepts a carried session_id and returns the resolved session_id and conversation_id - new prepare_tool_result() delivers a minted handle without mutating the original result - capture methods accept conversation_id Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Generated-By: PostHog Desktop Task-Id: 6fa508f7-af04-48ef-b7ea-31732d3ca42e
49ccde6 to
d18bd52
Compare
Generated-By: PostHog Desktop Task-Id: 6fa508f7-af04-48ef-b7ea-31732d3ca42e
lucasheriques
left a comment
There was a problem hiding this comment.
The port follows @posthog/mcp closely, and the tests cover the no-mutation handling well. Approving so you're unblocked, but please fix the two blocking items before merging: both leave conversation_id in the args the handler receives, which strict validation rejects. Some points apply to JS too.
Generated-By: PostHog Desktop Task-Id: 6fa508f7-af04-48ef-b7ea-31732d3ca42e
Generated-By: PostHog Desktop Task-Id: 6fa508f7-af04-48ef-b7ea-31732d3ca42e
Why
Custom MCP dispatchers need the same conversation and session grouping as instrumented servers. Stateless transports otherwise split related tool calls, and shared result objects must not expose one caller's conversation handle to another caller.
What changed
PostHogMCP.Testing
uv run pytest --verbose --timeout=30uv run ruff format --check .uv run ruff check .uv run mypy --no-site-packages --config-file mypy.ini . | uv run mypy-baseline filteruv run make public_api_checkCreated with PostHog Desktop