Repository navigation
Conversation
This was referenced Oct 7, 2026
MCP instrumentation relabeled the whole client, so the app's own events and flag requests reported posthog-python-mcp. Capture v1 takes $lib from the per-request PostHog-Sdk-Info header, which is now always posthog-python.
eli-r-ph
force-pushed
the
v1-capture-migration-docs
branch
from
October 8, 2026 00:08
e129027 to
4fd8597
Compare
eli-r-ph
force-pushed
the
v1-sdk-identity
branch
from
October 8, 2026 00:08
44123ba to
956c711
Compare
3 of 5 tasks
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
💡 Motivation and Context
Stacked on #1030. Part of the 8.0 series (checklist in #1016).
Capture v1 sets
$liband$lib_versionfrom the per-requestPostHog-Sdk-Infoheader and overwrites any value in the event. One request carries events from every caller of a client, so one client can have only one identity. 8.0 fixes that identity atposthog-python/<version>.In 7.x,
posthog.mcp.instrument()andPostHogMCPrelabeled the client asposthog-python-mcp: the header,$lib, and theUser-Agentof feature flag requests.instrument()with no client uses the default client, the same one behindposthog.capture(). So after instrumenting, every event and flag request from the app reportedposthog-python-mcp, not only the MCP events. That happened on both the legacy and the v1 paths.Changes:
_lib_identity.py,POSTHOG_MCP_LIB_NAME,Client._set_library_identity, and the request plumbing that existed only to send the relabeledUser-Agenton flag, flag definition and remote config requests.$libor$lib_versionset in a call, insuper_propertiesor inbefore_senddoes not reach PostHog. To find MCP traffic, filter on$mcp_*events and properties.Go makes the same call in PostHog/posthog-go#361 (removes
Capture.Library). posthog-rs always sendsposthog-rs.Note for reviewers: SDK Health and flag analytics list
posthog-python-mcpas its own SDK. After 8.0, MCP servers count asposthog-pythonthere. A per-event way for MCP SDKs to identify themselves is tracked as a follow-up.💚 How did you test it?
test_instrument_keeps_the_host_client_identity(wastest_instrument_relabels_the_host_client) now checks that a client passed toinstrument()keeps$lib: posthog-python. Bringing back the relabel fails it.test_mcp_client_keeps_the_sdk_identitychecks that aPostHogMCPclient sendsPostHog-Sdk-Info: posthog-python/<version>.posthog-python-mcpidentity on events, flags, flag definitions and remote config are removed, together with the code they covered.ruff,mypy(baseline filter),make public_api_check,python -W error -c "import posthog", and the fullpytestsuite pass locally.📝 Checklist
If releasing new changes
sampo addto generate a changeset file🤖 Agent context
Autonomy: Human-driven (agent-assisted)