@posthog/mcp
1.7.0
Minor Changes
- #5577
0358eb7Thanks @lucasheriques! - Group tool calls into sessions by the client's own conversation id in_meta: ChatGPT'sopenai/session, Codex'ssessionId, and VS Code'svscode.conversationId, each read only from the client itsUser-Agentor client name identifies. The client's id wins over a conversation handle and a transport session. ChatGPT gets noconversation_idargument and no handle, so its tool schemas and results stay unchanged. Every event frominstrument()now records which source grouped it as$mcp_session_source.PostHogMCP.prepareToolListandprepareToolCalltake the request'sheaders(andclientInfo), andcaptureToolCalltakesrequestMeta. (2026-11-23)
1.6.1
Patch Changes
- #5836
02d707eThanks @eli-r-ph! -PostHogMCPadds the configuredserverBuildtocaptureAi()andcaptureAiImmediate()events, as it already does forcapture()andcaptureImmediate(). WithserverBuildset, an event whose properties cannot be read is now dropped by the client, as withoutserverBuild, instead of throwing from any of the four methods. (2026-11-21)
1.6.0
Minor Changes
- #5779
3069723Thanks @lucasheriques! - Support FastMCP withinstrumentFastMCP(fastmcp, posthog, options). FastMCP builds a server per session (per request when stateless) behind a private factory, so this hooks the module's session class and instruments each one before it connects. FastMCP's HTTP layer drops request headers, so the adapter puts them back onextra.requestInfo.headersforidentifyand other callbacks. (2026-11-18)
1.5.0
Minor Changes
- #5778
7d1b1a7Thanks @lucasheriques! - Support Vercel'smcp-handler. Callinstrument(server, posthog)inside thecreateMcpHandlercallback, and wrap the exported route in the newwithMcpSessionHeaderto keep one$session_idand the client's name per conversation on the2025-11-25protocol. mcp-handler streams theinitializeresponse, so the session token is minted at the fetch layer instead of inside the server. (2026-11-18)
1.4.0
Minor Changes
- #5781
d07d87fThanks @lucasheriques! - Classify client-caused failures as$mcp_error_type: "validation". A tool call whose arguments failed the tool's input schema, a call to a disabled tool, a tool that rejected its arguments with JSON-RPC-32602, and a read of an unknown resource now carryvalidationinstead of the thrown error's type, so dashboards can tell an agent's mistake from a server bug. Output-schema failures and malformed tool results, which also use-32602, keep the thrown type. Every failure still sends its$exception, as before. (2026-11-18)
1.3.0
Minor Changes
- #5407
6405dfdThanks @eli-r-ph! - AddeventOptionsto set posthog-node per-event options on MCP events, per call or from aninstrument()callback.beforeSendsees and can change them, and an explicitprocess_person_profilewins over the anonymous default. (2026-11-17)
Patch Changes
-
#5407
6405dfdThanks @eli-r-ph! - Genkit spans and@posthog/mcpevents with no user distinct id set theprocess_person_profile: falseevent option on posthog-node 6.x.x, so a registered or contextprocess_person_profile: trueoption no longer creates a person for each trace or session. Genkit also counts an empty or whitespace-only distinct id as missing. (2026-11-17) -
#5407
6405dfdThanks @eli-r-ph! - Export the table of per-event options and the event properties posthog-node 5.x.x reads instead, so posthog-node,@posthog/aiand@posthog/mcpshare one copy. (2026-11-17) -
#5407
6405dfdThanks @eli-r-ph! - Accepts posthog-node 6.x.x as a peer dependency. (2026-11-17) -
Updated dependencies [
6405dfd,6405dfd,6405dfd,6405dfd,6405dfd,6405dfd,6405dfd,6405dfd,6405dfd,6405dfd,6405dfd,6405dfd,6405dfd,6405dfd,6405dfd,6405dfd,6405dfd,6405dfd,6405dfd,6405dfd,6405dfd,6405dfd]:- @posthog/core@1.69.0
- posthog-node@6.0.0
1.2.3
Patch Changes
-
#5739
0a70d23Thanks @lucasheriques! -instrumentMutator(posthog)(server)now returns the server's own type instead ofunknown, so no type argument or cast is needed. ExplicitinstrumentMutator<McpServer>(posthog)calls and typedserverMutatorhooks keep working. (2026-11-16) -
#5739
0a70d23Thanks @lucasheriques! -getMoreToolsResult()andsendFeedbackResult()are now typed so they can be returned from an MCP SDK tool handler (v1 and v2CallToolResult) without a cast. (2026-11-16)
1.2.2
Patch Changes
-
#5732
5e5cb86Thanks @lucasheriques! - Fix stateless servers on@modelcontextprotocol/server2.0 to 2.2 that reuse one transport for every client: the session token minted atinitializenow rides only that client'sinitializeresponse. Before, it stayed on the transport, so every later client'sinitializefailed with 400 "Server already initialized" and later responses handed the first client's token to other clients. Per-request and multi-pod stateless servers still get a stable session token.The token is no longer left on
transport.sessionIdafter the response. Host code that read it there should read theMcp-Session-Idheader the client replays instead. (2026-11-13)
1.2.1
Patch Changes
- #5672
22f3f71Thanks @lucasheriques! - fix(mcp): keep the thrown value on high-levelMcpServertool calls, so$mcp_error_typeand$mcp_error_statusreflect what the tool threw. This covers MCP SDK v2, a thrown value that is not anError, and servers built per request that share tool functions. For a thrown non-Error,$mcp_error_messageand error grouping now describe the thrown value (for example'UpstreamError' captured as exception with message: 'bad') instead of[object Object].$mcp_error_typeis now redacted like the message, including anerrorTypepassed tocaptureToolCall. An error whose getters throw while it is captured is still recorded: a tool call falls back to the tool result, and other events recordUnknown errorinstead of being dropped. (2026-11-12) - Updated dependencies [
22f3f71]:- @posthog/core@1.67.2
1.2.0
Minor Changes
- #5671
4a30932Thanks @lucasheriques! - A failed tool call now sets$mcp_error_statusto the HTTP status behind it, read from the thrown error or itscausechain (status_code,statusCodeorstatus, on the error or itsresponse, as a fetchResponse, axios and got carry it). Failures from an upstream API now group by status in MCP Analytics instead of landing in "unknown". (2026-11-12)
Patch Changes
- #5682
8f5e876Thanks @DanielVisca! - Ignore non-stringname/versionvalues returned by theclientInfooption instead of recording them as the MCP client. (2026-11-12)
1.1.1
Patch Changes
- #5654
a7c8003Thanks @mkushner! - fix(mcp): keepadditionalProperties: falseon tool schemas when injectingcontext,llm_modelandconversation_id. The injected keys are declared properties, so the schema stays valid and keeps the strictness the host advertised. (2026-11-11)
1.1.0
Minor Changes
- #5597
4d0681fThanks @DanielVisca! - feat: addsessionIdandclientInfooptions so stateless per-request servers can supply the session id and client name for each request (2026-11-10)
Patch Changes
- Updated dependencies [
fb313fe,fee9bee,fee9bee]:- posthog-node@5.65.0
- @posthog/core@1.66.0
1.0.1
Patch Changes
- #5607
fac34e4Thanks @lucasheriques! - Fix intent and payload capture bugs: a long digit run no longer drops$mcp_intentwith a stack overflow (card redaction is otherwise unchanged), captured tool arguments are limited before they are sanitized and credential-named arguments are not walked, and$mcp_feedback_<name>object extras redact identifiers in keys and numbers. A parsed__proto__argument is still dropped, as before. (2026-11-09) - Updated dependencies [
fac34e4,bfbaff7]:- @posthog/core@1.65.0
- posthog-node@5.64.0
1.0.0
Major Changes
- #5584
650e968Thanks @lucasheriques! - Release 1.0.0. The API and the$mcp_*events are now stable: a minor or patch release no longer renames or removes an event or property, changes its type, or changes which requests send an event, so your saved insights keep working across upgrades. New events and properties can still arrive in minor releases. Upgrading from 0.x needs no code change. (2026-11-06)
0.26.0
Minor Changes
- #5583
2a08e91Thanks @lucasheriques! - Aligned with the MCP analytics spec: a call to a tool the server never registered now emits$mcp_unknown_toolinstead of a failed$mcp_tool_call,llm_modelis advertised as optional, theget_more_toolsandsend_feedbackannotations now declare that they record data, and the injectedcontextargument has a shorter description. A server whose own dispatcher bypasses the MCP SDK's tool registry (such as@rekog/mcp-nest) keeps recording calls to unknown names as failed tool calls, since the SDK cannot tell whether such a tool exists. On a low-level server,resolveOriginalToolreturningundefinednow marks a failing call as an unknown tool, so return a tool for every name your server serves. Strings cut to a property limit (such as 256 characters for names and 2,048 for intent and error text) now stop exactly at the limit,...included, instead of 3 characters past it.PostHogMCPcapture methods called without asessionIdnow send a fresh$session_idper call, and anonymous calls use it as their distinct id instead of the shared"anonymous". This changes your published tool definitions; if your server is listed in the ChatGPT or Claude directories, those platforms may re-review the updated tools. (2026-11-06)
0.25.2
Patch Changes
- #5545
28fe8c0Thanks @onmax! - Parse Node stack frames for functions namedasyncwithout a leading parenthesis in the filename. (2026-11-06) - Updated dependencies [
28fe8c0]:- @posthog/core@1.64.1
- posthog-node@5.63.1
0.25.1
Patch Changes
- #5573
88dbf08Thanks @lucasheriques! - Reworded the descriptions of the injectedconversation_idandllm_modelarguments and theget_more_toolsandsend_feedbackvirtual tools so they describe the field instead of instructing the model. This changes your published tool definitions; if your server is listed in the ChatGPT or Claude directories, those platforms may re-review the updated tools. (2026-11-05)
0.25.0
Minor Changes
- #5404
68336dfThanks @gesh! - Add asendToolsListEventoption. It is on by default. Set it tofalseto stop sending$mcp_tools_list. (2026-10-28)
0.24.0
Minor Changes
- #5401
8faad6aThanks @gesh! - Add asendInitializeEventoption. It is on by default. Set it tofalseto stop sending$mcp_initialize. (2026-10-28)
0.23.0
Minor Changes
- #5306
19b9b54Thanks @gesh! - Stop sending standalone$identifyevents, so insights, funnels, or cohorts built on MCP$identifystop receiving new data. Theidentifycallback still setsdistinct_id,$setand$groupson every event. (2026-10-19)
0.22.3
Patch Changes
0.22.2
Patch Changes
- #5162
3132998Thanks @pauldambra! - Sanitize each tool response once instead of twice, and replace image, audio and binary blocks before the scan, so tool calls with large results cost less CPU. Redact PostHog tokens that URL field decoding exposes. (2026-10-07) - Updated dependencies [
3132998]:- @posthog/core@1.57.2
0.22.1
Patch Changes
- #5191
6cd5496Thanks @gesh! - Capture WebMCP tool intent and model metadata by default. (2026-10-06) - Updated dependencies [
6cd5496]:- @posthog/core@1.57.0
0.22.0
Minor Changes
- #5165
3394548Thanks @OrbitingBucket! - Strip SDK-owned analytics arguments on fresh low-level server instances throughresolveOriginalTool. (2026-10-05)
0.21.4
Patch Changes
- #5161
9e42cc2Thanks @pauldambra! - Make oversized events cheaper to truncate. The depth reduction now starts at the first depth that removes anything, so shallow payloads such as rows of data no longer normalize and measure the whole event again for each depth that changes nothing. (2026-10-02)
0.21.3
Patch Changes
- #5186
80b9e5fThanks @lucasheriques! - Sanitize only the part of a long string that the captured event can keep, so a tool call returning megabytes of HTML or text no longer blocks the event loop while it is scanned. A 10 MB HTML response now costs about 5 ms to capture instead of 2.7 s. The captured event does not change. (2026-10-02)
0.21.2
Patch Changes
- #5160
1ed05cfThanks @pauldambra! - Stop copying the full tool list into$mcp_responseon$mcp_tools_listevents, so instrumented servers answertools/listfaster. (2026-09-30) - Updated dependencies [
2d2560a]:
0.21.1
Patch Changes
- #5157
e2a3e3dThanks @gesh! - Add the configured server build to custom events captured throughPostHogMCP. (2026-09-30)
0.21.0
Minor Changes
0.20.0
Minor Changes
- #5130
4d58499Thanks @gesh! - Record declared input aliases in automatic MCP instrumentation. (2026-09-28)
0.19.0
Minor Changes
-
#5117
51699b4Thanks @pauldambra! - Record which declared parameter aliases a tool call relied on as$mcp_input_aliases_used, from a server-ownedinputAliasesmap. (2026-09-28) -
#5048
466da07Thanks @pauldambra! - Record safe tool input field names for automatic and custom MCP servers. Unknown names are[redacted]by default;shouldRecordInputKeyreplaces that rule. (2026-09-28)
0.18.1
Patch Changes
- #5112
74295fdThanks @gesh! - Keep MCP conversation sessions consistent across user messages. (2026-09-25)
0.18.0
Minor Changes
- #5074
7133bdbThanks @gesh! - Add conversation and session correlation helpers for custom MCP dispatchers. (2026-09-23)
0.17.0
Minor Changes
- #4924
be40430Thanks @lucasheriques! - Enable model capture and conversation correlation by default. Advertised tool schemas gain anllm_modelargument (never enforced at dispatch) and eligible tool results gain a conversation handle;instrument(server, posthog, { captureModel: false, enableConversationId: false })restores the previous shape. Fresh low-level instances now read both arguments under the ADR-0011 rule instead of staying silent. (2026-09-17)
0.16.4
Patch Changes
- #5009
b4f58ebThanks @gesh! - Use conversation IDs forget_more_toolsandsend_feedbackcalls handled by fresh server instances. (2026-09-17)
0.16.3
Patch Changes
- #4967
916e163Thanks @gesh! - Inject the get_more_tools tool only on the first tools/list page, so a paginated catalogue's concatenated listing carries it once instead of once per page. A real first-page tool with the same name still wins (warning logged); a real tool on a later page is shadowed, with a warning when a client fetches that page — rename the SDK's tool with themissingCapabilityToolNameoption if your catalogue uses the name. (2026-09-16)
0.16.2
Patch Changes
- #4953
2a6ddb9Thanks @gesh! - Inject the send_feedback tool only on the first tools/list page (the request with no cursor), so a paginated catalogue's concatenated listing carries it once instead of once per page. A real first-page tool with the same name still wins: the SDK warns, skips injection, and forwards its calls. A real tool that only appears on a later page is not detected — the SDK logs a warning when a client fetches that page; rename the SDK's tool withcollectFeedback: { toolName }if your catalogue uses the name. (2026-09-15)
0.16.1
Patch Changes
- #4915
a5c1182Thanks @gesh! - Harden feedback validation, error handling, and tool-name collision routing. (2026-09-14)
0.16.0
Minor Changes
- #4870
cc6373bThanks @gesh! - Add thesend_feedbackvirtual tool (newcollectFeedbackoption): an honest, general agent-feedback channel with missing capabilities as the priority category. Every call emits a new$mcp_feedbackevent with$mcp_feedback_typeand the other$mcp_feedback_*properties. Hosts can rename the tool, replace its description, declareextraProperties(captured as$mcp_feedback_<key>), and route reports to a real backend viaonFeedback(instrument()path) orprepareToolCall().feedbackReport+captureFeedback()+sendFeedbackResult()(custom-dispatcher path).reportMissing/get_more_tools/$mcp_missing_capabilityare unchanged; new integrations should enable onlycollectFeedback. (2026-09-11)
0.15.0
Minor Changes
- #4830
39420d8Thanks @lucasheriques! - Capture resource discovery and reads from instrumented MCP servers. URL credential redaction (userinfo, credential-named query and fragment parameters) now applies to every captured string, including existing$mcp_tool_callparameters, responses, and error messages, so URLs already flowing through tool-call data will show%5Bredacted%5Dvalues after upgrading. (2026-09-10)
0.14.1
Patch Changes
- #4798
4358915Thanks @posthog! - fix(error-tracking): collapse repeated frame cycles in parsed stack traces to reduce grouping differences caused by recursion depth, while preserving distinct throw locations (2026-09-09) - Updated dependencies [
4358915]:- @posthog/core@1.51.1
- posthog-node@5.51.8
0.14.0
Minor Changes
- #4829
6724f10Thanks @lucasheriques! - Capture model identity from recognized client metadata before falling back to the injectedllm_modelargument. (2026-09-08)
0.13.1
Patch Changes
-
#4783
6e9f931Thanks @gesh! - Reduce personal data in$mcp_intent, which is agent-narrated free text and could previously carry personal data a model read aloud.- Automatically redact structured personal identifiers — email addresses, phone numbers, IPv4/IPv6 addresses, Luhn-valid card numbers, and US SSNs — from
$mcp_intentbefore it is captured. Redaction is always on, scoped to the intent only (structured toolargumentsand results are untouched, since the same shapes are often legitimate data there), and best-effort for those well-defined shapes rather than free-form names or addresses. Identifiers grouped with Unicode spaces, dots, or slashes (as produced by copy-paste) and SSNs with space/dot separators are recognized. The email pattern uses bounded quantifiers so a pathological intent cannot cause quadratic-time backtracking. - Strengthen the default injected
contextprompt so agents are less likely to write personal data in the first place: the privacy rule is now explicit and lists the identifiers to avoid, and it tells the agent to refer to people and accounts by role ('a user', 'the customer') rather than by identity.
context: falseandbeforeSendremain the ways to drop the field entirely. (2026-09-07) - Automatically redact structured personal identifiers — email addresses, phone numbers, IPv4/IPv6 addresses, Luhn-valid card numbers, and US SSNs — from
-
Updated dependencies [
74ca945]:- posthog-node@5.51.7
- @posthog/core@1.50.6
0.13.0
Minor Changes
- #4735
cbadf11Thanks @lucasheriques! - Add self-reported model capture to thePostHogMCPcustom-dispatcher path. The preparation helpers preserve application-owned fields and work across stateless server replicas when given the original tool descriptor. Tool calls and missing-capability reports can record the model properties. (2026-09-03)
Patch Changes
- Updated dependencies [
dbbb58e]:- @posthog/core@1.50.3
0.12.0
Minor Changes
- #4633
5a652e9Thanks @DanielVisca! - Add opt-incaptureModeloption: injects a requiredllm_modelparameter into every tool — including theget_more_toolsvirtual tool — so the calling agent self-reports the model it runs as, captured as$mcp_llm_modelwith$mcp_llm_model_source = "self_reported". Stripping the argument before the handler runs and capturing the property both require confirmed SDK ownership of the parameter: a customer-declaredllm_modelis never stolen or captured, and a low-levelServerthat builds a fresh instance per request records nothing (see the README). An honest"unknown"from the agent is dropped rather than recorded. (2026-08-27)
Patch Changes
- Updated dependencies [
74ff567,dfc3b59]:- @posthog/core@1.49.1
- posthog-node@5.51.4
0.11.7
Patch Changes
- #4542
0fe77e8Thanks @gesh! - Return conversation IDs as data-only tool output to avoid prompt-injection warnings from clients with stale schemas. (2026-08-18)
0.11.6
Patch Changes
- #4515
5698fd5Thanks @gesh! - Attribute$mcp_tool_calland$mcp_initializeto the client that made the request. Both stamped client identity after awaiting theidentifycallback, so a handshake arriving on the same server instance meanwhile could rename the event;$mcp_initializeadditionally read the previously handshaked client rather than the one in its own request body. (2026-08-13)
0.11.5
Patch Changes
-
#4504
48b1a0cThanks @gesh! - Resolveidentifyontools/list, so listings attribute to a person instead of falling back to the session id. (2026-08-13) -
#4502
bc2ec32Thanks @gesh! - Capture$mcp_intenton servers that build a fresh instance per request, where thecontextargument was previously discarded.The SDK records the agent's answer to its injected
contextparameter only when it can confirm the parameter is one it injected — a fact learned while servingtools/listand cached on the server instance. Where the next request builds a new instance, that instance never served a listing, so the intent of every call was thrown away. The trigger is instance lifetime, not statelessness: a server that is stateless at the transport but keeps one long-lived server object was never affected, and a per-request instance on MCP SDK v1 was affected just as much as on v2.Reading the argument and removing it are now separate decisions. Stripping still requires positive ownership and fails closed, because deleting an argument the application declared costs the customer their tool call. Reading costs at worst a mislabelled property, so it now happens whenever ownership cannot be resolved.
The trade-off: on such a server, a
contextparameter the application declared itself is recorded as$mcp_intent. Setcontext: falseto disable injection and capture together, or drop the property inbeforeSend. (2026-08-13) -
#4514
245afe6Thanks @gesh! - Preserve thetools/listresponse envelope, so instrumenting a paginated tool catalogue no longer hides its later pages.The listing wrapper rebuilt the response as
{ tools }, discarding every other field the application's handler had set — on both SDK majors. Most visiblynextCursor: a client stops enumerating when the cursor is absent, so tools on later pages became undiscoverable the momentinstrument()was applied, with no error on either side. The wrapper now spreads the response and replaces onlytools, which also preserves the 2026-07-28 caching directivesttlMs/cacheScopeand result_meta.$mcp_tools_listcaptures the response as sent, envelope included. (2026-08-13) -
Updated dependencies [
c9086de]:- @posthog/core@1.48.0
- posthog-node@5.49.0
0.11.4
Patch Changes
-
#4482
9dd5e6cThanks @gesh! - Keep the conversation-id prompt-back out of$mcp_error_message.With
enableConversationIdon, a[SERVER]: Reuse conversation_id=…block is appended to a tool result so the agent echoes the handle back on later calls. The captured error was read from that already-appended result, so a failed call reported"intentional failure [SERVER]: Reuse conversation_id=019f…"— a fresh uuid inside the error message on every call, which splits one recurring failure into a new error group each time it happens.The error is now read from the result as the tool produced it, before the handle is written in. It bites hardest on MCP SDK v2, where a thrown error is flattened into an
isErrorresult before the SDK hands it to us, so that result is the only description of the failure available. The agent still receives the prompt-back on failed calls — that is when it matters most, since otherwise the retry starts a new conversation and the failure and its fix land in different sessions. (2026-08-10) -
#4466
fe3ea18Thanks @gesh! - GateMcp-Session-Idminting on the protocol revision the request declares.The 2026-07-28 revision removed protocol-level sessions: a server must not mint or echo
Mcp-Session-Idunder it. Until now that held only by accident — the mint hangs off theinitializehandler and 2026-07-28 has no handshake — so compliance depended on an SDK routing detail rather than on anything the SDK checks.The era is now resolved per request, from the version an
initializebody declares or, failing that, from the same fallback chain that resolves client identity. Nothing branches on which SDK major is installed: one v2 server serves both revisions, request by request. An unknown version counts as legacy, so a v1 client that declares nothing keeps the session header it has always had. (2026-08-10)
0.11.3
Patch Changes
-
#4465
9ffdb00Thanks @gesh! - Record the protocol version for 2025-11-25 traffic served by a per-request server.That revision carries the negotiated version at the
initializehandshake, so an MCP SDK v2 server built per HTTP request has no way to know it: the instance handling a latertools/callnever saw the handshake, and a legacy-era request carries no_metaenvelope for the identity chain to read. Those events went out with no$mcp_protocol_version.The chain gains the one carrier that era does have — the
MCP-Protocol-Versionrequest header, which 2025-11-25 requires a client to send on every request afterinitialize. It is read after the protocol-level envelope andparams._metaand before the server's own accessors, so a modern-era request still prefers the value the protocol gives it, and no era is branched on. (2026-08-10)
0.11.2
Patch Changes
-
#4463
b8e5d06Thanks @gesh! - Resolve client name, version and protocol version through a fallback chain, so events from an MCP SDK v2 server carry them.MCP SDK v2 lifts the reserved
io.modelcontextprotocol/*keys —clientInfo,protocolVersion,clientCapabilities— out ofparams._metawhile parsing a request, and puts them on the request envelope. We only readparams._meta, which is empty by the time a handler runs, so$mcp_client_name,$mcp_client_versionand$mcp_protocol_versionwent missing on exactly the modern-era traffic that carries them per request rather than atinitialize.Identity is now resolved field by field through three sources in order: the v2 request envelope, then
params._meta, then the server's owngetClientVersion()and (v2-only)getNegotiatedProtocolVersion(). A chain rather than a branch, because the same v2 server serves 2025-era requests routinely — era is a per-request property, never a module constant — and because a field one source cannot answer may still be known to the next. (2026-08-10) -
#4464
8b5165eThanks @gesh! - Install and type-check cleanly on a project that has only MCP SDK v2.@modelcontextprotocol/sdk(v1) was a required peer, so installing@posthog/mcpinto a project built on@modelcontextprotocol/server(v2) pulled the entire v1 SDK in as an auto-installed peer — 87 packages where 1 was wanted — and tooling that walks the dependency tree reported it as missing when it was absent. Both majors are now declared and both are optional, which is what the code has always assumed: no@modelcontextprotocol/*package is imported at runtime, and server shapes are detected structurally.Making the peer optional exposed a second half of the same problem. The published type declarations still imported
CallToolResultandListToolsResultfrom@modelcontextprotocol/sdk/types.js, so a consumer without the v1 SDK hitTS2307on an install that otherwise worked — fine at runtime, broken undertscwithoutskipLibCheck. Those MCP wire shapes are now declared structurally intypes.tstoo.The shapes we read are open-ended, so a value typed by either SDK assigns to them. What the package hands back is typed precisely and stays assignable to the SDK's own
CallToolResult, sogetMoreToolsResult()can still be returned straight from a tool callback. (2026-08-10)
0.11.1
Patch Changes
-
#4462
2fc1211Thanks @gesh! - Instrument high-levelMcpServerinstances from MCP TypeScript SDK v2, and read request headers from either SDK major.The compatibility gate required
typeof server.tool === 'function'. SDK v2 dropped the deprecatedtool()in favour ofregisterTool(), so every v2 high-level server failed the check — and sinceinstrument()catches compatibility failures and returns a working-looking handle, it failed silently: no throw, no warning at the call site, and no$mcp_*events at all. The gate now accepts either registration method, and every shape question it asks is answered by a structural probe in the newdetect.tsrather than by a version or protocol constant.Opening the gate is also what first sends v2-shaped request context to header reads, so both halves ship together. The SDK's own reads go through a new
getRequestHeaders(extra), which takes headers from v2'sctx.http.req(a WHATWGRequest, whose headers only answer to.get()) as well as v1'sextra.requestInfo.headers, and returns a plain lowercase-keyed object either way. It is duck-typed on.entriesrather thaninstanceof Headers, so aHeadersfrom another realm — workerd and other edge runtimes — is read correctly.getRequestHeadersis exported, becauseidentify,intentFallback,eventPropertiesandbeforeSendstill receive the SDK'sextraunchanged — we deliberately do not synthesise a v1requestInfoon v2, as a partially faked shape is worse than an absent one. Hosts reading headers in a callback migrate in one line:1import { getRequestHeaders } from '@posthog/mcp' 2 3identify: async (request, extra) => { 4 const auth = getRequestHeaders(extra)?.['authorization'] 5 // ... 6} 7``` (2026-08-10)
0.11.0
Minor Changes
-
#4419
e3be62fThanks @lucasheriques! - Capture the calling client's User-Agent and vendor client header on every auto-captured MCP event, as$mcp_client_user_agentand$mcp_vendor_client.MCP's own
clientInfocan't tell a vendor's products apart — Anthropic reportsclientInfo.name = "claude-code"from the CLI, the Agent SDK, the VS Code extension and the desktop app alike, so$mcp_client_namecollapses them into one bucket. The surface is only visible in the User-Agent parenthetical (claude-code/2.1.0 (cli)vs(sdk-ts)vs(claude-vscode)), so capturing it is what lets you see which of your integrations traffic actually comes from.Automatic on HTTP transports (
instrument()reads the headers per request); stdio and in-memory servers, which have no headers, are unchanged. On thePostHogMCPcustom-dispatcher path, passclientUserAgent/vendorClienton your capture calls. Both values are recorded raw — PostHog resolves them to friendly product labels at query time, so labels keep improving without an SDK upgrade. (2026-08-07)
0.10.9
Patch Changes
-
#4461
f457521Thanks @gesh! - Wrap request handlers registered with a method string, and stop breaking three-argument registrations. MCP TypeScript SDK v2 callssetRequestHandler('tools/call', handler)where v1 passed a Zod schema, soinstrument()could not name those registrations and left them unwrapped — a handler bound afterinstrument()silently replaced the analytics wrapper, and no$mcp_tool_callor$mcp_tools_listwas captured. Frameworks that attach handlers post-construction, such as@rekog/mcp-nest, do exactly this on every request.The patched
setRequestHandlernow also forwards every argument it is given. v2's three-argument form for custom methods —setRequestHandler(method, { params, result }, handler)— previously lost its handler and threwsetRequestHandler: handler is required, taking down the host server rather than just instrumentation. (2026-08-07) -
#4450
69e47bdThanks @gesh! - Register the synthetictools/callfallback by writing into the server's handler map instead of callingsetRequestHandler. Instrumenting a low-levelServerthat never declared atoolscapability no longer fails withServer does not support toolsand leaves instrumentation half-applied — it now instruments cleanly, and answers a call for a tool no dispatcher claims withUnknown tool: <name>. This also removes the last runtime@modelcontextprotocol/sdkimport from the published bundle; the SDK is now referenced only as a type. (2026-08-07)
0.10.8
Patch Changes
-
#4433
c514a34Thanks @gesh! - Deliver theconversation_idsession handle on errored tool results, and inject it into the virtualget_more_toolstool. A first call that fails no longer sends the agent's retry into a different conversation, and a reported capability gap now groups with the work that hit it. (2026-08-06) -
#4428
7322893Thanks @gesh! - Use an agent-suppliedconversation_idas the session anchor, so tool calls in one conversation share a$session_idacross reconnects, restarts, and per-request server instances. Only a handle the SDK could have minted is accepted; a value the agent invented is replaced with a fresh one, so two callers cannot land in the same session by sending the same string. (2026-08-06) -
#4431
955df8dThanks @gesh! - Mirror theconversation_idsession handle intostructuredContentfor tools whose output schema declares_mcp_instructions. Clients that read structured results never saw the handle incontent, so correlation for those tools was zero. (2026-08-06) -
#4430
e6d9295Thanks @gesh! - Declare an optional_mcp_instructionsproperty on the output schema of tools that advertise one, whenenableConversationIdis on. Inert by itself — it is the schema declaration that makes a later change able to mirror the conversation handle intostructuredContentwithout failing client-side validation. (2026-08-06) -
Updated dependencies [
4751b33,64ba193]:- posthog-node@5.48.1
- @posthog/core@1.46.9
0.10.7
Patch Changes
- #4357
632049cThanks @marandaneto! - Prevent concurrent MCP requests from leaking identity and session attribution. (2026-08-04) - Updated dependencies [
facb4c1]:
0.10.6
Patch Changes
- #4356
1eab19aThanks @marandaneto! - Preserve real missing-capability tools when their names collide with the configured virtual tool. Restore$mcp_tool_callanalytics for low-level servers that register their tool dispatcher after instrumentation. (2026-08-04)
0.10.5
Patch Changes
- #4359
d2f5041Thanks @marandaneto! - Isolate logger configuration per instrumented MCP server. (2026-08-04)
0.10.4
Patch Changes
- #4379
4d8df50Thanks @marandaneto! - Preserve tool-owned analytics arguments across event capture, low-level servers, and strict schemas. (2026-08-04)
0.10.3
Patch Changes
- #4355
57f371eThanks @marandaneto! - Preserve user-definedcontextandconversation_idtool arguments. (2026-08-03) - Updated dependencies [
7c3a9af]:- @posthog/core@1.46.2
- posthog-node@5.47.4
0.10.2
Patch Changes
- #4358
575c5e7Thanks @marandaneto! - Redact sensitive exception messages and large binary payload encodings from MCP analytics. (2026-07-31)
0.10.1
Patch Changes
- #4237
23ce761Thanks @gesh! - Read the MCP client name/version and protocol version from each request's_meta(io.modelcontextprotocol/clientInfoandio.modelcontextprotocol/protocolVersion), so$mcp_client_name,$mcp_client_version, and$mcp_protocol_versionkeep populating under the MCP 2026-07-28 stateless revision, which removes theinitializehandshake. Existing clients are unaffected — when_metais absent, the values from the session token /initializestill apply. (2026-07-27)
0.10.0
Minor Changes
-
#4210
e732595Thanks @gesh! - feat(mcp): capture the negotiated MCP protocol version as$mcp_protocol_versionThe SDK now stamps
$mcp_protocol_version— the MCP spec version negotiated atinitialize(read off the server's initialize response) — on the$mcp_initializeevent and on every subsequent event for the session (tool calls, listings, and the$exceptionsibling). It's persisted in per-server session info and, on stateless / multi-pod deployments, recovered on other pods from the session token, which now carries the client's requested version in a newpvfield. Use it to track MCP spec-revision adoption and to break event metrics (error rate, latency) down by spec version.SessionTokenPayloadgains an optionalprotocolVersion, andPostHogMCP.captureInitializeaccepts an optionalprotocolVersion. (2026-07-21) (2026-07-22)
0.9.1
Patch Changes
-
#4144
3c8e17eThanks @gesh! - fix(mcp): publish$identifyat most once per session instead of before every tool callOn stateless / multi-pod deployments the SDK rebuilds its per-server identity cache on every request, so the dedupe check saw an empty cache each time and emitted a standalone
$identifybefore every$mcp_tool_call. The SDK now publishes$identifyat most once per session — atinitialize, when a long-lived server first sees the identity, or when the identity materially changes. Every event still carriesdistinct_id/$set, so no person data is lost when a standalone$identifyis suppressed. (2026-07-15)
0.9.0
Minor Changes
-
#4123
c8d036eThanks @gesh! - feat(mcp): stable sessions and client metadata on stateless / multi-pod MCP serversOn stateless servers every request became its own session and
$mcp_client_name/$mcp_client_versionwere missing afterinitialize. The SDK now mints theMcp-Session-Idresponse header atinitializeas a token carrying the session id and client name/version; clients replay it on every request, so any pod recovers both with no server-side store. Auto-minting requiresenableJsonResponse: trueonStreamableHTTPServerTransport; SSE-mode servers can set the header at the HTTP layer with the new exports.New exports:
encodeSessionId,decodeSessionId,MCP_SESSION_HEADER,SessionTokenPayload,newSessionId. (2026-07-10)
0.8.0
Minor Changes
- #4032
93bbc4bThanks @lucasheriques! - Stamp$mcp_error_typeand$mcp_error_messageon$mcp_tool_call(and$mcp_tools_list) when a call fails. Previously the only failure signal on the primary event was the$mcp_is_errorboolean, so breaking failures down by reason meant joining to the$exceptionsibling (which can be disabled, and isn't emitted when no error value is passed).$mcp_error_typedefaults to the thrown error's type, andcaptureToolCall/captureToolsListaccept an explicit low-cardinalityerrorTypelabel (e.g.validation,permission,timeout,rate_limited) for hosts that classify their own failures. (2026-07-03)
0.7.0
Minor Changes
- #4025
5590094Thanks @gesh! - Stamp the standard PostHog$lib/$lib_version(valueposthog-node-mcp) on every event, so MCP events self-identify the same way every other PostHog SDK does. Both emit paths are covered:PostHogMCPoverrides its library id, andinstrument()applies it to the client you pass in. Note that posthog-node sets$libat the client level, so forinstrument()this relabels every event that client sends asposthog-node-mcp— pass a client dedicated to your MCP server's analytics. (2026-06-30)
0.6.0
Minor Changes
- #4022
d9e19e0Thanks @gesh! - Emit$mcp_lib(@posthog/mcp) and$mcp_lib_versionon every$mcp_*event (and the$exceptionsibling) so you can tell which analytics SDK release produced the data. The version was already resolved at runtime but never mapped to a property. Namespaced like@posthog/ai's$ai_librather than overriding$lib, which stays the transport SDK (posthog-node). (2026-06-30)
0.5.1
Patch Changes
- #4009
ae68de1Thanks @gesh! - Fix$mcp_client_namebeing dropped from every other captured event.getSessionInfocached the client identity but then overwrote the cache withundefinedon the next event, so consecutive tool calls alternated between carrying and lacking the client name (showing up as a large "other" slice in MCP analytics). The cached client name/version are now reused instead of refetched. (2026-06-29)
0.5.0
Minor Changes
- #3995
e86f61aThanks @lucasheriques! - AddinstrumentMutator(posthog, options?)— a point-free(server) => serverhelper for framework server-mutation hooks like@rekog/mcp-nest'sserverMutator. It instruments the server and returns it, soserverMutator: instrumentMutator(posthog)just works (no need to remember thatinstrument()returns the analytics handle, not the server). (2026-06-26)
0.4.4
Patch Changes
- #3896
606ef43Thanks @GauthierPLM! - Forward $groups as a first-class groups field from the MCP analytics sink so the group association is no longer dropped on $mcp_* events (fixes #3888). (2026-06-26) - Updated dependencies [
606ef43]:
0.4.3
Patch Changes
- #3993
fb43a92Thanks @gesh! - Instrument MCP request handlers through a singlesetRequestHandlerpatch instead of one per method. Internal refactor — no change to the analytics captured. (2026-06-26) - Updated dependencies [
6200888]:- @posthog/core@1.38.0
0.4.2
Patch Changes
- #3976
a29194fThanks @gesh! - Capture tool listings (and the injectedcontextparameter) on MCP servers that register theirtools/listhandler afterinstrument()runs — e.g.@rekog/mcp-nest, which hands a bare server toinstrument()and only then registers its handlers. (2026-06-25)
0.4.1
Patch Changes
-
#3936
06c23d8Thanks @lucasheriques! - Re-exportPostHog(and thePostHogOptionstype) from@posthog/mcp, so you can import the client andinstrumentfrom a single package:1import { PostHog, instrument } from "@posthog/mcp";posthog-noderemains a peer dependency (resolved from the host app's installed copy); this only unifies the import.PostHogMCPis also already accepted byinstrument()if you prefer a single client class. (2026-06-23)
0.4.0
Minor Changes
- #3883
ddd9e7eThanks @lucasheriques! - Bring thePostHogMCPcustom-dispatcher path up to the same$mcp_*events asinstrument()for intent, theget_more_toolsvirtual tool, and tool listings. Custom MCP servers (hono, edge, any setup without aServer/McpServerto wrap) can now emit those events too. (instrument()'s server-sideintentFallbackandenableConversationIdcallbacks aren't mirrored — a custom dispatcher owns its request loop and can do both inline.)prepareToolList(tools, { context, reportMissing })injects thecontextargument into tool input schemas and optionally appends theget_more_toolstool.prepareToolCall(name, args)returns{ intent, intentSource, args, isMissingCapability }— pulls the agent-supplied intent, strips the injectedcontextargument before your handler runs, and flagsget_more_toolscalls.captureToolCallnow acceptsintent/intentSource, emitting$mcp_intentand$mcp_intent_source.captureMissingCapability(...)emits$mcp_missing_capability, plus a standalonegetMoreToolsResult()for the canned response.captureToolsList(...)emits$mcp_tools_listwith the advertised tool names.setLoggeris now exported so custom servers can surface the SDK's internal warnings.- The missing-capability (
get_more_tools) tool name is now customizable viamissingCapabilityToolName(defaults toget_more_tools) on both paths: thePostHogMCPconstructor option and theinstrument()MCPAnalyticsOptions. Set once, it's used for both advertising the tool and detecting calls to it, so the name can't drift between injection and detection. (2026-06-18)
0.3.0
Minor Changes
- #3829
125dee2Thanks @DanielVisca! - Auto-capture$mcp_tool_categoryon$mcp_tool_callevents. The wrapping path (track()/instrument()) reads acategorydeclared on a tool's_metablock (cached fromtools/listand seeded from_registeredTools), andPostHogMCP.captureToolCallaccepts a first-classcategoryfield. Declaring_meta: { category: "Logs" }on a tool definition is all a server needs for every call to carry the category, enabling per-category dashboards in PostHog MCP analytics. (2026-06-16)
Patch Changes
- Updated dependencies [
b3ec845,a0553b3,c6c163a]:- @posthog/core@1.33.0
- posthog-node@5.38.0
0.2.1
Patch Changes
- #3837
29bf8e3Thanks @marandaneto! - Add missing bugs metadata to package manifests. (2026-06-15) - Updated dependencies [
29bf8e3]:- @posthog/core@1.32.4
- posthog-node@5.37.1
0.2.0
Minor Changes
- #3781
b732ecbThanks @lucasheriques! - AddPostHogMCP, aposthog-nodeclient subclass with first-class MCP analytics for servers that have noServer/McpServerto wrap (e.g. custom hono/HTTP dispatchers). It extendsPostHog— socapture,identify,flush,shutdown, and feature flags all work unchanged — and addscaptureToolCall/captureInitialize, which build the canonical$mcp_*events and run them through the same sanitize → truncate →$exceptionfan-out pipeline asinstrument()before handing them to the inheritedcapture()(so the client's ownbeforeSendapplies). The caller passesdistinctId/sessionId/groups/propertiesper call.$session_idis now omitted from events when no session is supplied (previously always set), so stateless captures don't bucket into a non-existent Session Replay session. (2026-06-11)
0.1.28
Patch Changes
- Updated dependencies []:
- @posthog/core@1.32.3
- posthog-node@5.36.17
0.1.27
Patch Changes
- Updated dependencies [
25822ac]:- @posthog/core@1.32.2
- posthog-node@5.36.16
0.1.26
Patch Changes
- Updated dependencies []:
- @posthog/core@1.32.1
- posthog-node@5.36.15
0.1.25
Patch Changes
- Updated dependencies [
612f97a]:- @posthog/core@1.32.0
- posthog-node@5.36.14
0.1.24
Patch Changes
- Updated dependencies []:
- @posthog/core@1.31.4
- posthog-node@5.36.13
0.1.23
Patch Changes
- Updated dependencies []:
- @posthog/core@1.31.3
- posthog-node@5.36.12
0.1.22
Patch Changes
- Updated dependencies []:
- @posthog/core@1.31.2
- posthog-node@5.36.11
0.1.21
Patch Changes
- Updated dependencies []:
- @posthog/core@1.31.1
- posthog-node@5.36.10
0.1.20
Patch Changes
- Updated dependencies [
0c2acb9]:- @posthog/core@1.31.0
- posthog-node@5.36.9
0.1.19
Patch Changes
- Updated dependencies []:
- @posthog/core@1.30.14
- posthog-node@5.36.8
0.1.18
Patch Changes
- Updated dependencies [
7820929]:- posthog-node@5.36.7
- @posthog/core@1.30.13
0.1.17
Patch Changes
- Updated dependencies []:
- @posthog/core@1.30.12
- posthog-node@5.36.6
0.1.16
Patch Changes
- #3772
e243ea4Thanks @lucasheriques! - First release of@posthog/mcpfrom the posthog-js monorepo. Instrument an MCP server with a singleinstrument(server, posthog)call to auto-capture tool calls, tool listings, initialize, identity, and exceptions to PostHog. BYOposthog-nodeclient;beforeSendhook;identify({ distinctId, properties, groups });$mcp_missing_capability; anonymous sessions sent with$process_person_profile: false. (2026-06-08)
0.1.15
Patch Changes
- Updated dependencies []:
- @posthog/core@1.30.11
- posthog-node@5.36.5
0.1.14
Patch Changes
- Updated dependencies []:
- @posthog/core@1.30.10
0.1.13
Patch Changes
- Updated dependencies []:
- @posthog/core@1.30.9
0.1.12
Patch Changes
- Updated dependencies []:
- @posthog/core@1.30.8
0.1.11
Patch Changes
- Updated dependencies []:
- @posthog/core@1.30.7
0.1.10
Patch Changes
- Updated dependencies []:
- @posthog/core@1.30.6
0.1.9
Patch Changes
- Updated dependencies []:
- @posthog/core@1.30.5
0.1.8
Patch Changes
- Updated dependencies []:
- @posthog/core@1.30.4
0.1.7
Patch Changes
- Updated dependencies []:
- @posthog/core@1.30.3
0.1.6
Patch Changes
- Updated dependencies []:
- @posthog/core@1.30.2
0.1.5
Patch Changes
- Updated dependencies []:
- @posthog/core@1.30.1
0.1.4
Patch Changes
- Updated dependencies [
3d4a76f]:- @posthog/core@1.30.0
0.1.3
Patch Changes
- Updated dependencies []:
- @posthog/core@1.29.15
0.1.2
Patch Changes
- Updated dependencies [
d9ad199]:- @posthog/core@1.29.14
0.1.1
Patch Changes
- Updated dependencies [
7b84b75]:- @posthog/core@1.29.13