Contents

@posthog/mcp

1.7.0

Minor Changes

  • #5577 0358eb7 Thanks @lucasheriques! - Group tool calls into sessions by the client's own conversation id in _meta: ChatGPT's openai/session, Codex's sessionId, and VS Code's vscode.conversationId, each read only from the client its User-Agent or client name identifies. The client's id wins over a conversation handle and a transport session. ChatGPT gets no conversation_id argument and no handle, so its tool schemas and results stay unchanged. Every event from instrument() now records which source grouped it as $mcp_session_source. PostHogMCP.prepareToolList and prepareToolCall take the request's headers (and clientInfo), and captureToolCall takes requestMeta. (2026-11-23)

1.6.1

Patch Changes

  • #5836 02d707e Thanks @eli-r-ph! - PostHogMCP adds the configured serverBuild to captureAi() and captureAiImmediate() events, as it already does for capture() and captureImmediate(). With serverBuild set, an event whose properties cannot be read is now dropped by the client, as without serverBuild, instead of throwing from any of the four methods. (2026-11-21)

1.6.0

Minor Changes

  • #5779 3069723 Thanks @lucasheriques! - Support FastMCP with instrumentFastMCP(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 on extra.requestInfo.headers for identify and other callbacks. (2026-11-18)

1.5.0

Minor Changes

  • #5778 7d1b1a7 Thanks @lucasheriques! - Support Vercel's mcp-handler. Call instrument(server, posthog) inside the createMcpHandler callback, and wrap the exported route in the new withMcpSessionHeader to keep one $session_id and the client's name per conversation on the 2025-11-25 protocol. mcp-handler streams the initialize response, so the session token is minted at the fetch layer instead of inside the server. (2026-11-18)

1.4.0

Minor Changes

  • #5781 d07d87f Thanks @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 carry validation instead 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 6405dfd Thanks @eli-r-ph! - Add eventOptions to set posthog-node per-event options on MCP events, per call or from an instrument() callback. beforeSend sees and can change them, and an explicit process_person_profile wins over the anonymous default. (2026-11-17)

Patch Changes

1.2.3

Patch Changes

  • #5739 0a70d23 Thanks @lucasheriques! - instrumentMutator(posthog)(server) now returns the server's own type instead of unknown, so no type argument or cast is needed. Explicit instrumentMutator<McpServer>(posthog) calls and typed serverMutator hooks keep working. (2026-11-16)

  • #5739 0a70d23 Thanks @lucasheriques! - getMoreToolsResult() and sendFeedbackResult() are now typed so they can be returned from an MCP SDK tool handler (v1 and v2 CallToolResult) without a cast. (2026-11-16)

1.2.2

Patch Changes

  • #5732 5e5cb86 Thanks @lucasheriques! - Fix stateless servers on @modelcontextprotocol/server 2.0 to 2.2 that reuse one transport for every client: the session token minted at initialize now rides only that client's initialize response. Before, it stayed on the transport, so every later client's initialize failed 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.sessionId after the response. Host code that read it there should read the Mcp-Session-Id header the client replays instead. (2026-11-13)

1.2.1

Patch Changes

  • #5672 22f3f71 Thanks @lucasheriques! - fix(mcp): keep the thrown value on high-level McpServer tool calls, so $mcp_error_type and $mcp_error_status reflect what the tool threw. This covers MCP SDK v2, a thrown value that is not an Error, and servers built per request that share tool functions. For a thrown non-Error, $mcp_error_message and error grouping now describe the thrown value (for example 'UpstreamError' captured as exception with message: 'bad') instead of [object Object]. $mcp_error_type is now redacted like the message, including an errorType passed to captureToolCall. An error whose getters throw while it is captured is still recorded: a tool call falls back to the tool result, and other events record Unknown error instead of being dropped. (2026-11-12)
  • Updated dependencies [22f3f71]:

1.2.0

Minor Changes

  • #5671 4a30932 Thanks @lucasheriques! - A failed tool call now sets $mcp_error_status to the HTTP status behind it, read from the thrown error or its cause chain (status_code, statusCode or status, on the error or its response, as a fetch Response, 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 8f5e876 Thanks @DanielVisca! - Ignore non-string name/version values returned by the clientInfo option instead of recording them as the MCP client. (2026-11-12)

1.1.1

Patch Changes

  • #5654 a7c8003 Thanks @mkushner! - fix(mcp): keep additionalProperties: false on tool schemas when injecting context, llm_model and conversation_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 4d0681f Thanks @DanielVisca! - feat: add sessionId and clientInfo options so stateless per-request servers can supply the session id and client name for each request (2026-11-10)

Patch Changes

1.0.1

Patch Changes

  • #5607 fac34e4 Thanks @lucasheriques! - Fix intent and payload capture bugs: a long digit run no longer drops $mcp_intent with 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]:

1.0.0

Major Changes

  • #5584 650e968 Thanks @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 2a08e91 Thanks @lucasheriques! - Aligned with the MCP analytics spec: a call to a tool the server never registered now emits $mcp_unknown_tool instead of a failed $mcp_tool_call, llm_model is advertised as optional, the get_more_tools and send_feedback annotations now declare that they record data, and the injected context argument 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, resolveOriginalTool returning undefined now 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. PostHogMCP capture methods called without a sessionId now send a fresh $session_id per 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

0.25.1

Patch Changes

  • #5573 88dbf08 Thanks @lucasheriques! - Reworded the descriptions of the injected conversation_id and llm_model arguments and the get_more_tools and send_feedback virtual 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 68336df Thanks @gesh! - Add a sendToolsListEvent option. It is on by default. Set it to false to stop sending $mcp_tools_list. (2026-10-28)

0.24.0

Minor Changes

  • #5401 8faad6a Thanks @gesh! - Add a sendInitializeEvent option. It is on by default. Set it to false to stop sending $mcp_initialize. (2026-10-28)

0.23.0

Minor Changes

  • #5306 19b9b54 Thanks @gesh! - Stop sending standalone $identify events, so insights, funnels, or cohorts built on MCP $identify stop receiving new data. The identify callback still sets distinct_id, $set and $groups on every event. (2026-10-19)

0.22.3

Patch Changes

  • #5224 ec9080a Thanks @gesh! - Set $mcp_interface to mcp on events from MCP servers. (2026-10-09)

0.22.2

Patch Changes

  • #5162 3132998 Thanks @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]:

0.22.1

Patch Changes

0.22.0

Minor Changes

  • #5165 3394548 Thanks @OrbitingBucket! - Strip SDK-owned analytics arguments on fresh low-level server instances through resolveOriginalTool. (2026-10-05)

0.21.4

Patch Changes

  • #5161 9e42cc2 Thanks @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 80b9e5f Thanks @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

0.21.1

Patch Changes

  • #5157 e2a3e3d Thanks @gesh! - Add the configured server build to custom events captured through PostHogMCP. (2026-09-30)

0.21.0

Minor Changes

0.20.0

Minor Changes

  • #5130 4d58499 Thanks @gesh! - Record declared input aliases in automatic MCP instrumentation. (2026-09-28)

0.19.0

Minor Changes

  • #5117 51699b4 Thanks @pauldambra! - Record which declared parameter aliases a tool call relied on as $mcp_input_aliases_used, from a server-owned inputAliases map. (2026-09-28)

  • #5048 466da07 Thanks @pauldambra! - Record safe tool input field names for automatic and custom MCP servers. Unknown names are [redacted] by default; shouldRecordInputKey replaces that rule. (2026-09-28)

0.18.1

Patch Changes

  • #5112 74295fd Thanks @gesh! - Keep MCP conversation sessions consistent across user messages. (2026-09-25)

0.18.0

Minor Changes

  • #5074 7133bdb Thanks @gesh! - Add conversation and session correlation helpers for custom MCP dispatchers. (2026-09-23)

0.17.0

Minor Changes

  • #4924 be40430 Thanks @lucasheriques! - Enable model capture and conversation correlation by default. Advertised tool schemas gain an llm_model argument (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 b4f58eb Thanks @gesh! - Use conversation IDs for get_more_tools and send_feedback calls handled by fresh server instances. (2026-09-17)

0.16.3

Patch Changes

  • #4967 916e163 Thanks @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 the missingCapabilityToolName option if your catalogue uses the name. (2026-09-16)

0.16.2

Patch Changes

  • #4953 2a6ddb9 Thanks @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 with collectFeedback: { toolName } if your catalogue uses the name. (2026-09-15)

0.16.1

Patch Changes

  • #4915 a5c1182 Thanks @gesh! - Harden feedback validation, error handling, and tool-name collision routing. (2026-09-14)

0.16.0

Minor Changes

  • #4870 cc6373b Thanks @gesh! - Add the send_feedback virtual tool (new collectFeedback option): an honest, general agent-feedback channel with missing capabilities as the priority category. Every call emits a new $mcp_feedback event with $mcp_feedback_type and the other $mcp_feedback_* properties. Hosts can rename the tool, replace its description, declare extraProperties (captured as $mcp_feedback_<key>), and route reports to a real backend via onFeedback (instrument() path) or prepareToolCall().feedbackReport + captureFeedback() + sendFeedbackResult() (custom-dispatcher path). reportMissing / get_more_tools / $mcp_missing_capability are unchanged; new integrations should enable only collectFeedback. (2026-09-11)

0.15.0

Minor Changes

  • #4830 39420d8 Thanks @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_call parameters, responses, and error messages, so URLs already flowing through tool-call data will show %5Bredacted%5D values after upgrading. (2026-09-10)

0.14.1

Patch Changes

  • #4798 4358915 Thanks @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]:

0.14.0

Minor Changes

  • #4829 6724f10 Thanks @lucasheriques! - Capture model identity from recognized client metadata before falling back to the injected llm_model argument. (2026-09-08)

0.13.1

Patch Changes

  • #4783 6e9f931 Thanks @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_intent before it is captured. Redaction is always on, scoped to the intent only (structured tool arguments and 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 context prompt 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: false and beforeSend remain the ways to drop the field entirely. (2026-09-07)

  • Updated dependencies [74ca945]:

0.13.0

Minor Changes

  • #4735 cbadf11 Thanks @lucasheriques! - Add self-reported model capture to the PostHogMCP custom-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

0.12.0

Minor Changes

  • #4633 5a652e9 Thanks @DanielVisca! - Add opt-in captureModel option: injects a required llm_model parameter into every tool — including the get_more_tools virtual tool — so the calling agent self-reports the model it runs as, captured as $mcp_llm_model with $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-declared llm_model is never stolen or captured, and a low-level Server that 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

0.11.7

Patch Changes

  • #4542 0fe77e8 Thanks @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 5698fd5 Thanks @gesh! - Attribute $mcp_tool_call and $mcp_initialize to the client that made the request. Both stamped client identity after awaiting the identify callback, so a handshake arriving on the same server instance meanwhile could rename the event; $mcp_initialize additionally read the previously handshaked client rather than the one in its own request body. (2026-08-13)

0.11.5

Patch Changes

  • #4504 48b1a0c Thanks @gesh! - Resolve identify on tools/list, so listings attribute to a person instead of falling back to the session id. (2026-08-13)

  • #4502 bc2ec32 Thanks @gesh! - Capture $mcp_intent on servers that build a fresh instance per request, where the context argument was previously discarded.

    The SDK records the agent's answer to its injected context parameter only when it can confirm the parameter is one it injected — a fact learned while serving tools/list and 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 context parameter the application declared itself is recorded as $mcp_intent. Set context: false to disable injection and capture together, or drop the property in beforeSend. (2026-08-13)

  • #4514 245afe6 Thanks @gesh! - Preserve the tools/list response 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 visibly nextCursor: a client stops enumerating when the cursor is absent, so tools on later pages became undiscoverable the moment instrument() was applied, with no error on either side. The wrapper now spreads the response and replaces only tools, which also preserves the 2026-07-28 caching directives ttlMs / cacheScope and result _meta. $mcp_tools_list captures the response as sent, envelope included. (2026-08-13)

  • Updated dependencies [c9086de]:

0.11.4

Patch Changes

  • #4482 9dd5e6c Thanks @gesh! - Keep the conversation-id prompt-back out of $mcp_error_message.

    With enableConversationId on, 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 isError result 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 fe3ea18 Thanks @gesh! - Gate Mcp-Session-Id minting 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-Id under it. Until now that held only by accident — the mint hangs off the initialize handler 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 initialize body 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 9ffdb00 Thanks @gesh! - Record the protocol version for 2025-11-25 traffic served by a per-request server.

    That revision carries the negotiated version at the initialize handshake, so an MCP SDK v2 server built per HTTP request has no way to know it: the instance handling a later tools/call never saw the handshake, and a legacy-era request carries no _meta envelope 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-Version request header, which 2025-11-25 requires a client to send on every request after initialize. It is read after the protocol-level envelope and params._meta and 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 b8e5d06 Thanks @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 of params._meta while parsing a request, and puts them on the request envelope. We only read params._meta, which is empty by the time a handler runs, so $mcp_client_name, $mcp_client_version and $mcp_protocol_version went missing on exactly the modern-era traffic that carries them per request rather than at initialize.

    Identity is now resolved field by field through three sources in order: the v2 request envelope, then params._meta, then the server's own getClientVersion() 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 8b5165e Thanks @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/mcp into 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 CallToolResult and ListToolsResult from @modelcontextprotocol/sdk/types.js, so a consumer without the v1 SDK hit TS2307 on an install that otherwise worked — fine at runtime, broken under tsc without skipLibCheck. Those MCP wire shapes are now declared structurally in types.ts too.

    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, so getMoreToolsResult() can still be returned straight from a tool callback. (2026-08-10)

0.11.1

Patch Changes

  • #4462 2fc1211 Thanks @gesh! - Instrument high-level McpServer instances 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 deprecated tool() in favour of registerTool(), so every v2 high-level server failed the check — and since instrument() 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 new detect.ts rather 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's ctx.http.req (a WHATWG Request, whose headers only answer to .get()) as well as v1's extra.requestInfo.headers, and returns a plain lowercase-keyed object either way. It is duck-typed on .entries rather than instanceof Headers, so a Headers from another realm — workerd and other edge runtimes — is read correctly.

    getRequestHeaders is exported, because identify, intentFallback, eventProperties and beforeSend still receive the SDK's extra unchanged — we deliberately do not synthesise a v1 requestInfo on 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 e3be62f Thanks @lucasheriques! - Capture the calling client's User-Agent and vendor client header on every auto-captured MCP event, as $mcp_client_user_agent and $mcp_vendor_client.

    MCP's own clientInfo can't tell a vendor's products apart — Anthropic reports clientInfo.name = "claude-code" from the CLI, the Agent SDK, the VS Code extension and the desktop app alike, so $mcp_client_name collapses 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 the PostHogMCP custom-dispatcher path, pass clientUserAgent / vendorClient on 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 f457521 Thanks @gesh! - Wrap request handlers registered with a method string, and stop breaking three-argument registrations. MCP TypeScript SDK v2 calls setRequestHandler('tools/call', handler) where v1 passed a Zod schema, so instrument() could not name those registrations and left them unwrapped — a handler bound after instrument() silently replaced the analytics wrapper, and no $mcp_tool_call or $mcp_tools_list was captured. Frameworks that attach handlers post-construction, such as @rekog/mcp-nest, do exactly this on every request.

    The patched setRequestHandler now 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 threw setRequestHandler: handler is required, taking down the host server rather than just instrumentation. (2026-08-07)

  • #4450 69e47bd Thanks @gesh! - Register the synthetic tools/call fallback by writing into the server's handler map instead of calling setRequestHandler. Instrumenting a low-level Server that never declared a tools capability no longer fails with Server does not support tools and leaves instrumentation half-applied — it now instruments cleanly, and answers a call for a tool no dispatcher claims with Unknown tool: <name>. This also removes the last runtime @modelcontextprotocol/sdk import from the published bundle; the SDK is now referenced only as a type. (2026-08-07)

0.10.8

Patch Changes

  • #4433 c514a34 Thanks @gesh! - Deliver the conversation_id session handle on errored tool results, and inject it into the virtual get_more_tools tool. 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 7322893 Thanks @gesh! - Use an agent-supplied conversation_id as the session anchor, so tool calls in one conversation share a $session_id across 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 955df8d Thanks @gesh! - Mirror the conversation_id session handle into structuredContent for tools whose output schema declares _mcp_instructions. Clients that read structured results never saw the handle in content, so correlation for those tools was zero. (2026-08-06)

  • #4430 e6d9295 Thanks @gesh! - Declare an optional _mcp_instructions property on the output schema of tools that advertise one, when enableConversationId is on. Inert by itself — it is the schema declaration that makes a later change able to mirror the conversation handle into structuredContent without failing client-side validation. (2026-08-06)

  • Updated dependencies [4751b33, 64ba193]:

0.10.7

Patch Changes

0.10.6

Patch Changes

  • #4356 1eab19a Thanks @marandaneto! - Preserve real missing-capability tools when their names collide with the configured virtual tool. Restore $mcp_tool_call analytics for low-level servers that register their tool dispatcher after instrumentation. (2026-08-04)

0.10.5

Patch Changes

0.10.4

Patch Changes

  • #4379 4d8df50 Thanks @marandaneto! - Preserve tool-owned analytics arguments across event capture, low-level servers, and strict schemas. (2026-08-04)

0.10.3

Patch Changes

0.10.2

Patch Changes

  • #4358 575c5e7 Thanks @marandaneto! - Redact sensitive exception messages and large binary payload encodings from MCP analytics. (2026-07-31)

0.10.1

Patch Changes

  • #4237 23ce761 Thanks @gesh! - Read the MCP client name/version and protocol version from each request's _meta (io.modelcontextprotocol/clientInfo and io.modelcontextprotocol/protocolVersion), so $mcp_client_name, $mcp_client_version, and $mcp_protocol_version keep populating under the MCP 2026-07-28 stateless revision, which removes the initialize handshake. Existing clients are unaffected — when _meta is absent, the values from the session token / initialize still apply. (2026-07-27)

0.10.0

Minor Changes

  • #4210 e732595 Thanks @gesh! - feat(mcp): capture the negotiated MCP protocol version as $mcp_protocol_version

    The SDK now stamps $mcp_protocol_version — the MCP spec version negotiated at initialize (read off the server's initialize response) — on the $mcp_initialize event and on every subsequent event for the session (tool calls, listings, and the $exception sibling). 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 new pv field. Use it to track MCP spec-revision adoption and to break event metrics (error rate, latency) down by spec version.

    SessionTokenPayload gains an optional protocolVersion, and PostHogMCP.captureInitialize accepts an optional protocolVersion. (2026-07-21) (2026-07-22)

0.9.1

Patch Changes

  • #4144 3c8e17e Thanks @gesh! - fix(mcp): publish $identify at most once per session instead of before every tool call

    On 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 $identify before every $mcp_tool_call. The SDK now publishes $identify at most once per session — at initialize, when a long-lived server first sees the identity, or when the identity materially changes. Every event still carries distinct_id/$set, so no person data is lost when a standalone $identify is suppressed. (2026-07-15)

0.9.0

Minor Changes

  • #4123 c8d036e Thanks @gesh! - feat(mcp): stable sessions and client metadata on stateless / multi-pod MCP servers

    On stateless servers every request became its own session and $mcp_client_name/$mcp_client_version were missing after initialize. The SDK now mints the Mcp-Session-Id response header at initialize as 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 requires enableJsonResponse: true on StreamableHTTPServerTransport; 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 93bbc4b Thanks @lucasheriques! - Stamp $mcp_error_type and $mcp_error_message on $mcp_tool_call (and $mcp_tools_list) when a call fails. Previously the only failure signal on the primary event was the $mcp_is_error boolean, so breaking failures down by reason meant joining to the $exception sibling (which can be disabled, and isn't emitted when no error value is passed). $mcp_error_type defaults to the thrown error's type, and captureToolCall/captureToolsList accept an explicit low-cardinality errorType label (e.g. validation, permission, timeout, rate_limited) for hosts that classify their own failures. (2026-07-03)

0.7.0

Minor Changes

  • #4025 5590094 Thanks @gesh! - Stamp the standard PostHog $lib / $lib_version (value posthog-node-mcp) on every event, so MCP events self-identify the same way every other PostHog SDK does. Both emit paths are covered: PostHogMCP overrides its library id, and instrument() applies it to the client you pass in. Note that posthog-node sets $lib at the client level, so for instrument() this relabels every event that client sends as posthog-node-mcp — pass a client dedicated to your MCP server's analytics. (2026-06-30)

0.6.0

Minor Changes

  • #4022 d9e19e0 Thanks @gesh! - Emit $mcp_lib (@posthog/mcp) and $mcp_lib_version on every $mcp_* event (and the $exception sibling) 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_lib rather than overriding $lib, which stays the transport SDK (posthog-node). (2026-06-30)

0.5.1

Patch Changes

  • #4009 ae68de1 Thanks @gesh! - Fix $mcp_client_name being dropped from every other captured event. getSessionInfo cached the client identity but then overwrote the cache with undefined on 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 e86f61a Thanks @lucasheriques! - Add instrumentMutator(posthog, options?) — a point-free (server) => server helper for framework server-mutation hooks like @rekog/mcp-nest's serverMutator. It instruments the server and returns it, so serverMutator: instrumentMutator(posthog) just works (no need to remember that instrument() returns the analytics handle, not the server). (2026-06-26)

0.4.4

Patch Changes

  • #3896 606ef43 Thanks @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 fb43a92 Thanks @gesh! - Instrument MCP request handlers through a single setRequestHandler patch instead of one per method. Internal refactor — no change to the analytics captured. (2026-06-26)
  • Updated dependencies [6200888]:

0.4.2

Patch Changes

  • #3976 a29194f Thanks @gesh! - Capture tool listings (and the injected context parameter) on MCP servers that register their tools/list handler after instrument() runs — e.g. @rekog/mcp-nest, which hands a bare server to instrument() and only then registers its handlers. (2026-06-25)

0.4.1

Patch Changes

  • #3936 06c23d8 Thanks @lucasheriques! - Re-export PostHog (and the PostHogOptions type) from @posthog/mcp, so you can import the client and instrument from a single package:

     1import { PostHog, instrument } from "@posthog/mcp";
    

    posthog-node remains a peer dependency (resolved from the host app's installed copy); this only unifies the import. PostHogMCP is also already accepted by instrument() if you prefer a single client class. (2026-06-23)

0.4.0

Minor Changes

  • #3883 ddd9e7e Thanks @lucasheriques! - Bring the PostHogMCP custom-dispatcher path up to the same $mcp_* events as instrument() for intent, the get_more_tools virtual tool, and tool listings. Custom MCP servers (hono, edge, any setup without a Server/McpServer to wrap) can now emit those events too. (instrument()'s server-side intentFallback and enableConversationId callbacks aren't mirrored — a custom dispatcher owns its request loop and can do both inline.)
    • prepareToolList(tools, { context, reportMissing }) injects the context argument into tool input schemas and optionally appends the get_more_tools tool.
    • prepareToolCall(name, args) returns { intent, intentSource, args, isMissingCapability } — pulls the agent-supplied intent, strips the injected context argument before your handler runs, and flags get_more_tools calls.
    • captureToolCall now accepts intent/intentSource, emitting $mcp_intent and $mcp_intent_source.
    • captureMissingCapability(...) emits $mcp_missing_capability, plus a standalone getMoreToolsResult() for the canned response.
    • captureToolsList(...) emits $mcp_tools_list with the advertised tool names.
    • setLogger is now exported so custom servers can surface the SDK's internal warnings.
    • The missing-capability (get_more_tools) tool name is now customizable via missingCapabilityToolName (defaults to get_more_tools) on both paths: the PostHogMCP constructor option and the instrument() 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 125dee2 Thanks @DanielVisca! - Auto-capture $mcp_tool_category on $mcp_tool_call events. The wrapping path (track()/instrument()) reads a category declared on a tool's _meta block (cached from tools/list and seeded from _registeredTools), and PostHogMCP.captureToolCall accepts a first-class category field. 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

0.2.1

Patch Changes

0.2.0

Minor Changes

  • #3781 b732ecb Thanks @lucasheriques! - Add PostHogMCP, a posthog-node client subclass with first-class MCP analytics for servers that have no Server/McpServer to wrap (e.g. custom hono/HTTP dispatchers). It extends PostHog — so capture, identify, flush, shutdown, and feature flags all work unchanged — and adds captureToolCall / captureInitialize, which build the canonical $mcp_* events and run them through the same sanitize → truncate → $exception fan-out pipeline as instrument() before handing them to the inherited capture() (so the client's own beforeSend applies). The caller passes distinctId/sessionId/groups/properties per call. $session_id is 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

0.1.27

Patch Changes

0.1.26

Patch Changes

0.1.25

Patch Changes

0.1.24

Patch Changes

0.1.23

Patch Changes

0.1.22

Patch Changes

0.1.21

Patch Changes

0.1.20

Patch Changes

0.1.19

Patch Changes

0.1.18

Patch Changes

0.1.17

Patch Changes

0.1.16

Patch Changes

  • #3772 e243ea4 Thanks @lucasheriques! - First release of @posthog/mcp from the posthog-js monorepo. Instrument an MCP server with a single instrument(server, posthog) call to auto-capture tool calls, tool listings, initialize, identity, and exceptions to PostHog. BYO posthog-node client; beforeSend hook; identify({ distinctId, properties, groups }); $mcp_missing_capability; anonymous sessions sent with $process_person_profile: false. (2026-06-08)

0.1.15

Patch Changes

0.1.14

Patch Changes

0.1.13

Patch Changes

0.1.12

Patch Changes

0.1.11

Patch Changes

0.1.10

Patch Changes

0.1.9

Patch Changes

0.1.8

Patch Changes

0.1.7

Patch Changes

0.1.6

Patch Changes

0.1.5

Patch Changes

0.1.4

Patch Changes

0.1.3

Patch Changes

0.1.2

Patch Changes

0.1.1

Patch Changes