@posthog/mcp 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,7 +2,7 @@ export declare const INACTIVITY_TIMEOUT_IN_MINUTES = 30;
2
2
  export declare const DEFAULT_CONTEXT_PARAMETER_DESCRIPTION = "Explain why you are calling this tool and how it fits into the user's overall goal. This parameter is used for analytics and user intent tracking. YOU MUST provide 15-25 words (count carefully). NEVER use first person ('I', 'we', 'you') - maintain third-person perspective. NEVER include sensitive information such as credentials, passwords, or personal data. Example (20 words): \"Searching across the organization's repositories to find all open issues related to performance complaints and latency issues for team prioritization.\"";
3
3
  export declare const DEFAULT_CONVERSATION_ID_DESCRIPTION = "Echo the conversation_id from the server's previous response. The server provides it on the first call \u2014 never invent one, and do not issue parallel tool calls until you have it.";
4
4
  export declare const POSTHOG_MCP_ANALYTICS_SOURCE = "posthog_mcp_analytics";
5
- export declare const POSTHOG_MCP_LIB_NAME = "@posthog/mcp";
5
+ export declare const POSTHOG_MCP_LIB_NAME = "posthog-node-mcp";
6
6
  export declare const PostHogMCPAnalyticsEvent: {
7
7
  readonly Custom: "$mcp_custom";
8
8
  readonly Exception: "$exception";
@@ -26,8 +26,6 @@ export declare const PostHogMCPAnalyticsProperty: {
26
26
  readonly Intent: "$mcp_intent";
27
27
  readonly IntentSource: "$mcp_intent_source";
28
28
  readonly ListedToolNames: "$mcp_listed_tool_names";
29
- readonly McpLib: "$mcp_lib";
30
- readonly McpLibVersion: "$mcp_lib_version";
31
29
  readonly Parameters: "$mcp_parameters";
32
30
  readonly ResourceName: "$mcp_resource_name";
33
31
  readonly Response: "$mcp_response";
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/extensions/constants.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,6BAA6B,KAAK,CAAA;AAE/C,eAAO,MAAM,qCAAqC,2hBAAyhB,CAAA;AAE3kB,eAAO,MAAM,mCAAmC,4LACsI,CAAA;AAEtL,eAAO,MAAM,4BAA4B,0BAA0B,CAAA;AAKnE,eAAO,MAAM,oBAAoB,iBAAiB,CAAA;AAIlD,eAAO,MAAM,wBAAwB;;;;;;;;;;;;CAY3B,CAAA;AAEV,MAAM,MAAM,wBAAwB,GAAG,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,OAAO,wBAAwB,CAAC,CAAA;AAE/G,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;CAqB9B,CAAA;AAEV,MAAM,MAAM,2BAA2B,GAAG,CAAC,OAAO,2BAA2B,CAAC,CAAC,MAAM,OAAO,2BAA2B,CAAC,CAAA"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/extensions/constants.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,6BAA6B,KAAK,CAAA;AAE/C,eAAO,MAAM,qCAAqC,2hBAAyhB,CAAA;AAE3kB,eAAO,MAAM,mCAAmC,4LACsI,CAAA;AAEtL,eAAO,MAAM,4BAA4B,0BAA0B,CAAA;AAMnE,eAAO,MAAM,oBAAoB,qBAAqB,CAAA;AAItD,eAAO,MAAM,wBAAwB;;;;;;;;;;;;CAY3B,CAAA;AAEV,MAAM,MAAM,wBAAwB,GAAG,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,OAAO,wBAAwB,CAAC,CAAA;AAE/G,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;CAmB9B,CAAA;AAEV,MAAM,MAAM,2BAA2B,GAAG,CAAC,OAAO,2BAA2B,CAAC,CAAC,MAAM,OAAO,2BAA2B,CAAC,CAAA"}
@@ -36,7 +36,7 @@ const INACTIVITY_TIMEOUT_IN_MINUTES = 30;
36
36
  const DEFAULT_CONTEXT_PARAMETER_DESCRIPTION = "Explain why you are calling this tool and how it fits into the user's overall goal. This parameter is used for analytics and user intent tracking. YOU MUST provide 15-25 words (count carefully). NEVER use first person ('I', 'we', 'you') - maintain third-person perspective. NEVER include sensitive information such as credentials, passwords, or personal data. Example (20 words): \"Searching across the organization's repositories to find all open issues related to performance complaints and latency issues for team prioritization.\"";
37
37
  const DEFAULT_CONVERSATION_ID_DESCRIPTION = "Echo the conversation_id from the server's previous response. The server provides it on the first call \u2014 never invent one, and do not issue parallel tool calls until you have it.";
38
38
  const POSTHOG_MCP_ANALYTICS_SOURCE = 'posthog_mcp_analytics';
39
- const POSTHOG_MCP_LIB_NAME = '@posthog/mcp';
39
+ const POSTHOG_MCP_LIB_NAME = 'posthog-node-mcp';
40
40
  const PostHogMCPAnalyticsEvent = {
41
41
  Custom: '$mcp_custom',
42
42
  Exception: '$exception',
@@ -59,8 +59,6 @@ const PostHogMCPAnalyticsProperty = {
59
59
  Intent: '$mcp_intent',
60
60
  IntentSource: '$mcp_intent_source',
61
61
  ListedToolNames: '$mcp_listed_tool_names',
62
- McpLib: '$mcp_lib',
63
- McpLibVersion: '$mcp_lib_version',
64
62
  Parameters: '$mcp_parameters',
65
63
  ResourceName: '$mcp_resource_name',
66
64
  Response: '$mcp_response',
@@ -2,7 +2,7 @@ const INACTIVITY_TIMEOUT_IN_MINUTES = 30;
2
2
  const DEFAULT_CONTEXT_PARAMETER_DESCRIPTION = "Explain why you are calling this tool and how it fits into the user's overall goal. This parameter is used for analytics and user intent tracking. YOU MUST provide 15-25 words (count carefully). NEVER use first person ('I', 'we', 'you') - maintain third-person perspective. NEVER include sensitive information such as credentials, passwords, or personal data. Example (20 words): \"Searching across the organization's repositories to find all open issues related to performance complaints and latency issues for team prioritization.\"";
3
3
  const DEFAULT_CONVERSATION_ID_DESCRIPTION = "Echo the conversation_id from the server's previous response. The server provides it on the first call \u2014 never invent one, and do not issue parallel tool calls until you have it.";
4
4
  const POSTHOG_MCP_ANALYTICS_SOURCE = 'posthog_mcp_analytics';
5
- const POSTHOG_MCP_LIB_NAME = '@posthog/mcp';
5
+ const POSTHOG_MCP_LIB_NAME = 'posthog-node-mcp';
6
6
  const PostHogMCPAnalyticsEvent = {
7
7
  Custom: '$mcp_custom',
8
8
  Exception: '$exception',
@@ -25,8 +25,6 @@ const PostHogMCPAnalyticsProperty = {
25
25
  Intent: '$mcp_intent',
26
26
  IntentSource: '$mcp_intent_source',
27
27
  ListedToolNames: '$mcp_listed_tool_names',
28
- McpLib: '$mcp_lib',
29
- McpLibVersion: '$mcp_lib_version',
30
28
  Parameters: '$mcp_parameters',
31
29
  ResourceName: '$mcp_resource_name',
32
30
  Response: '$mcp_response',
@@ -0,0 +1,19 @@
1
+ import type { PostHog } from 'posthog-node';
2
+ /**
3
+ * Make `client` report `@posthog/mcp`'s identity as the standard PostHog `$lib`
4
+ * / `$lib_version` on every event it sends.
5
+ *
6
+ * posthog-node stamps `$lib` / `$lib_version` from `getLibraryId()` /
7
+ * `getLibraryVersion()` and spreads them *last* when building the payload, so
8
+ * they can't be overridden per-event via the captured properties (nor via
9
+ * `before_send`, which runs earlier). Overriding the two methods is the only
10
+ * lever. Shared by {@link PostHogMCP} (which calls this in its constructor) and
11
+ * `instrument()` (which applies it to the host-supplied client) so both emit
12
+ * paths report identical lib metadata.
13
+ *
14
+ * Because `$lib` is a client-level property, this relabels *every* event the
15
+ * client sends as `posthog-node-mcp`, not just `$mcp_*` events — expected for a
16
+ * dedicated MCP-analytics client.
17
+ */
18
+ export declare function applyMcpLibIdentity(client: PostHog): void;
19
+ //# sourceMappingURL=lib-identity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lib-identity.d.ts","sourceRoot":"","sources":["../../src/extensions/lib-identity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAK3C;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAGzD"}
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ applyMcpLibIdentity: ()=>applyMcpLibIdentity
28
+ });
29
+ const external_version_js_namespaceObject = require("../version.js");
30
+ const external_constants_js_namespaceObject = require("./constants.js");
31
+ function applyMcpLibIdentity(client) {
32
+ client.getLibraryId = ()=>external_constants_js_namespaceObject.POSTHOG_MCP_LIB_NAME;
33
+ client.getLibraryVersion = ()=>external_version_js_namespaceObject.version;
34
+ }
35
+ exports.applyMcpLibIdentity = __webpack_exports__.applyMcpLibIdentity;
36
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
37
+ "applyMcpLibIdentity"
38
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
39
+ Object.defineProperty(exports, '__esModule', {
40
+ value: true
41
+ });
@@ -0,0 +1,7 @@
1
+ import { version } from "../version.mjs";
2
+ import { POSTHOG_MCP_LIB_NAME } from "./constants.mjs";
3
+ function applyMcpLibIdentity(client) {
4
+ client.getLibraryId = ()=>POSTHOG_MCP_LIB_NAME;
5
+ client.getLibraryVersion = ()=>version;
6
+ }
7
+ export { applyMcpLibIdentity };
@@ -1 +1 @@
1
- {"version":3,"file":"posthog-events.d.ts","sourceRoot":"","sources":["../../src/extensions/posthog-events.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AA8BrC,MAAM,WAAW,mBAAmB;IAClC,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,MAAM,CAAA;IACb,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACnC,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,SAAS,CAAA;CAChB;AAED,MAAM,WAAW,gCAAgC;IAC/C,2FAA2F;IAC3F,0BAA0B,CAAC,EAAE,OAAO,CAAA;CACrC;AAED,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,KAAK,EACZ,OAAO,GAAE,gCAAqC,GAC7C,mBAAmB,EAAE,CAQvB"}
1
+ {"version":3,"file":"posthog-events.d.ts","sourceRoot":"","sources":["../../src/extensions/posthog-events.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAyBrC,MAAM,WAAW,mBAAmB;IAClC,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,MAAM,CAAA;IACb,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACnC,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,SAAS,CAAA;CAChB;AAED,MAAM,WAAW,gCAAgC;IAC/C,2FAA2F;IAC3F,0BAA0B,CAAC,EAAE,OAAO,CAAA;CACrC;AAED,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,KAAK,EACZ,OAAO,GAAE,gCAAqC,GAC7C,mBAAmB,EAAE,CAQvB"}
@@ -98,7 +98,6 @@ function addCommonEventProperties(event, properties) {
98
98
  if (event.serverVersion) properties[external_constants_js_namespaceObject.PostHogMCPAnalyticsProperty.ServerVersion] = event.serverVersion;
99
99
  if (event.clientName) properties[external_constants_js_namespaceObject.PostHogMCPAnalyticsProperty.ClientName] = event.clientName;
100
100
  if (event.clientVersion) properties[external_constants_js_namespaceObject.PostHogMCPAnalyticsProperty.ClientVersion] = event.clientVersion;
101
- addMcpLibProperties(event, properties);
102
101
  if (event.userIntent) properties[external_constants_js_namespaceObject.PostHogMCPAnalyticsProperty.Intent] = event.userIntent;
103
102
  if (event.userIntentSource) properties[external_constants_js_namespaceObject.PostHogMCPAnalyticsProperty.IntentSource] = event.userIntentSource;
104
103
  if (void 0 !== event.isError) properties[external_constants_js_namespaceObject.PostHogMCPAnalyticsProperty.IsError] = event.isError;
@@ -111,12 +110,6 @@ function addCommonEventProperties(event, properties) {
111
110
  function addCustomEventProperties(event, properties) {
112
111
  if (event.properties) for (const [key, value] of Object.entries(event.properties))properties[key] = value;
113
112
  }
114
- function addMcpLibProperties(event, properties) {
115
- if (event.sdkVersion) {
116
- properties[external_constants_js_namespaceObject.PostHogMCPAnalyticsProperty.McpLib] = external_constants_js_namespaceObject.POSTHOG_MCP_LIB_NAME;
117
- properties[external_constants_js_namespaceObject.PostHogMCPAnalyticsProperty.McpLibVersion] = event.sdkVersion;
118
- }
119
- }
120
113
  function buildExceptionEvent(event) {
121
114
  const distinctId = getDistinctId(event);
122
115
  const timestamp = getTimestamp(event);
@@ -136,7 +129,6 @@ function buildExceptionEvent(event) {
136
129
  if (event.serverVersion) properties[external_constants_js_namespaceObject.PostHogMCPAnalyticsProperty.ServerVersion] = event.serverVersion;
137
130
  if (event.clientName) properties[external_constants_js_namespaceObject.PostHogMCPAnalyticsProperty.ClientName] = event.clientName;
138
131
  if (event.clientVersion) properties[external_constants_js_namespaceObject.PostHogMCPAnalyticsProperty.ClientVersion] = event.clientVersion;
139
- addMcpLibProperties(event, properties);
140
132
  addCustomEventProperties(event, properties);
141
133
  return {
142
134
  event: external_constants_js_namespaceObject.PostHogMCPAnalyticsEvent.Exception,
@@ -1,4 +1,4 @@
1
- import { POSTHOG_MCP_ANALYTICS_SOURCE, POSTHOG_MCP_LIB_NAME, PostHogMCPAnalyticsEvent, PostHogMCPAnalyticsProperty } from "./constants.mjs";
1
+ import { POSTHOG_MCP_ANALYTICS_SOURCE, PostHogMCPAnalyticsEvent, PostHogMCPAnalyticsProperty } from "./constants.mjs";
2
2
  import { MCPAnalyticsEventType } from "./event-types.mjs";
3
3
  const BUILT_IN_EVENT_NAME_BY_TYPE = {
4
4
  [MCPAnalyticsEventType.custom]: PostHogMCPAnalyticsEvent.Custom,
@@ -70,7 +70,6 @@ function addCommonEventProperties(event, properties) {
70
70
  if (event.serverVersion) properties[PostHogMCPAnalyticsProperty.ServerVersion] = event.serverVersion;
71
71
  if (event.clientName) properties[PostHogMCPAnalyticsProperty.ClientName] = event.clientName;
72
72
  if (event.clientVersion) properties[PostHogMCPAnalyticsProperty.ClientVersion] = event.clientVersion;
73
- addMcpLibProperties(event, properties);
74
73
  if (event.userIntent) properties[PostHogMCPAnalyticsProperty.Intent] = event.userIntent;
75
74
  if (event.userIntentSource) properties[PostHogMCPAnalyticsProperty.IntentSource] = event.userIntentSource;
76
75
  if (void 0 !== event.isError) properties[PostHogMCPAnalyticsProperty.IsError] = event.isError;
@@ -83,12 +82,6 @@ function addCommonEventProperties(event, properties) {
83
82
  function addCustomEventProperties(event, properties) {
84
83
  if (event.properties) for (const [key, value] of Object.entries(event.properties))properties[key] = value;
85
84
  }
86
- function addMcpLibProperties(event, properties) {
87
- if (event.sdkVersion) {
88
- properties[PostHogMCPAnalyticsProperty.McpLib] = POSTHOG_MCP_LIB_NAME;
89
- properties[PostHogMCPAnalyticsProperty.McpLibVersion] = event.sdkVersion;
90
- }
91
- }
92
85
  function buildExceptionEvent(event) {
93
86
  const distinctId = getDistinctId(event);
94
87
  const timestamp = getTimestamp(event);
@@ -108,7 +101,6 @@ function buildExceptionEvent(event) {
108
101
  if (event.serverVersion) properties[PostHogMCPAnalyticsProperty.ServerVersion] = event.serverVersion;
109
102
  if (event.clientName) properties[PostHogMCPAnalyticsProperty.ClientName] = event.clientName;
110
103
  if (event.clientVersion) properties[PostHogMCPAnalyticsProperty.ClientVersion] = event.clientVersion;
111
- addMcpLibProperties(event, properties);
112
104
  addCustomEventProperties(event, properties);
113
105
  return {
114
106
  event: PostHogMCPAnalyticsEvent.Exception,
@@ -1 +1 @@
1
- {"version":3,"file":"posthog-mcp.d.ts","sourceRoot":"","sources":["../../src/extensions/posthog-mcp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,cAAc,CAAA;AAG3D,OAAO,KAAK,EACV,qBAAqB,EAIrB,4BAA4B,EAC5B,gBAAgB,EAChB,sBAAsB,EACtB,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,UAAU,CAAA;AACjB,OAAO,EAIL,KAAK,qBAAqB,EAC3B,MAAM,sBAAsB,CAAA;AAO7B;;;GAGG;AACH,MAAM,WAAW,iBAAkB,SAAQ,cAAc;IACvD;;;;;OAKG;IACH,yBAAyB,CAAC,EAAE,MAAM,CAAA;CACnC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,qBAAa,UAAW,SAAQ,OAAO;;gBAWzB,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,iBAAsB;IAK3D,8FAA8F;IAC9F,eAAe,CAAC,IAAI,EAAE,mBAAmB,GAAG,IAAI;IAgBhD,iEAAiE;IACjE,iBAAiB,CAAC,IAAI,EAAE,qBAAqB,GAAG,IAAI;IAUpD;;;;;OAKG;IACH,gBAAgB,CAAC,IAAI,EAAE,oBAAoB,GAAG,IAAI;IAalD;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,eAAe,CAAC,KAAK,SAAS,qBAAqB,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,OAAO,GAAE,sBAA2B,GAAG,KAAK,EAAE;IAYnH;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,gBAAgB;IAW/E;;;;OAIG;IACH,wBAAwB,CAAC,IAAI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,10 @@ __webpack_require__.d(__webpack_exports__, {
27
27
  PostHogMCP: ()=>PostHogMCP
28
28
  });
29
29
  const external_posthog_node_namespaceObject = require("posthog-node");
30
- const external_version_js_namespaceObject = require("../version.js");
31
30
  const external_context_parameters_js_namespaceObject = require("./context-parameters.js");
32
31
  const external_event_types_js_namespaceObject = require("./event-types.js");
33
32
  const external_exceptions_js_namespaceObject = require("./exceptions.js");
33
+ const external_lib_identity_js_namespaceObject = require("./lib-identity.js");
34
34
  const external_logger_js_namespaceObject = require("./logger.js");
35
35
  const external_sink_js_namespaceObject = require("./sink.js");
36
36
  const external_tools_js_namespaceObject = require("./tools.js");
@@ -40,6 +40,7 @@ class PostHogMCP extends external_posthog_node_namespaceObject.PostHog {
40
40
  constructor(apiKey, options = {}){
41
41
  super(apiKey, options), this.#sink = new external_sink_js_namespaceObject.McpEventSink(this);
42
42
  this.#missingCapabilityToolName = options.missingCapabilityToolName ?? external_tools_js_namespaceObject.GET_MORE_TOOLS_NAME;
43
+ (0, external_lib_identity_js_namespaceObject.applyMcpLibIdentity)(this);
43
44
  }
44
45
  captureToolCall(data) {
45
46
  const event = baseEvent(external_event_types_js_namespaceObject.MCPAnalyticsEventType.mcpToolsCall, data);
@@ -113,8 +114,7 @@ function baseEvent(eventType, common) {
113
114
  sessionId: common.sessionId,
114
115
  timestamp: common.timestamp ?? new Date(),
115
116
  properties: common.properties,
116
- groups: common.groups,
117
- sdkVersion: external_version_js_namespaceObject.version
117
+ groups: common.groups
118
118
  };
119
119
  if (common.distinctId) event.identifyActorGivenId = common.distinctId;
120
120
  if (common.setProperties && Object.keys(common.setProperties).length > 0) event.identifyActorData = common.setProperties;
@@ -1,8 +1,8 @@
1
1
  import { PostHog } from "posthog-node";
2
- import { version } from "../version.mjs";
3
2
  import { addContextParameterToTools, getContextDescription, isContextEnabled } from "./context-parameters.mjs";
4
3
  import { MCPAnalyticsEventType } from "./event-types.mjs";
5
4
  import { captureException } from "./exceptions.mjs";
5
+ import { applyMcpLibIdentity } from "./lib-identity.mjs";
6
6
  import { log } from "./logger.mjs";
7
7
  import { McpEventSink } from "./sink.mjs";
8
8
  import { GET_MORE_TOOLS_NAME, getReportMissingToolDescriptor } from "./tools.mjs";
@@ -12,6 +12,7 @@ class PostHogMCP extends PostHog {
12
12
  constructor(apiKey, options = {}){
13
13
  super(apiKey, options), this.#sink = new McpEventSink(this);
14
14
  this.#missingCapabilityToolName = options.missingCapabilityToolName ?? GET_MORE_TOOLS_NAME;
15
+ applyMcpLibIdentity(this);
15
16
  }
16
17
  captureToolCall(data) {
17
18
  const event = baseEvent(MCPAnalyticsEventType.mcpToolsCall, data);
@@ -85,8 +86,7 @@ function baseEvent(eventType, common) {
85
86
  sessionId: common.sessionId,
86
87
  timestamp: common.timestamp ?? new Date(),
87
88
  properties: common.properties,
88
- groups: common.groups,
89
- sdkVersion: version
89
+ groups: common.groups
90
90
  };
91
91
  if (common.distinctId) event.identifyActorGivenId = common.distinctId;
92
92
  if (common.setProperties && Object.keys(common.setProperties).length > 0) event.identifyActorData = common.setProperties;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAO3C,OAAO,EAAE,6BAA6B,EAAgC,MAAM,sBAAsB,CAAA;AAGlG,OAAO,KAAK,EAGV,YAAY,EAEZ,mBAAmB,EAGpB,MAAM,SAAS,CAAA;AAEhB;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,iBAAS,UAAU,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,GAAE,mBAAwB,GAAG,YAAY,CA6BtG;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,iBAAS,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,CAAC,MAAM,EAAE,OAAO,KAAK,OAAO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AAC,EAAE,mBAAmB,GAAG,CAAC,MAAM,EAAE,OAAO,KAAK,OAAO,CAKjH;AAmFD,OAAO,EAAE,6BAA6B,EAAE,CAAA;AACxC,OAAO,EACL,4BAA4B,EAC5B,wBAAwB,EACxB,2BAA2B,GAC5B,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,UAAU,EAAE,KAAK,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAC7E,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAI/C,OAAO,EAAE,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,cAAc,CAAA;AAC3D,YAAY,EACV,YAAY,EACZ,gBAAgB,EAChB,qBAAqB,EACrB,YAAY,EACZ,gBAAgB,EAChB,0BAA0B,EAC1B,wBAAwB,EACxB,mBAAmB,EACnB,4BAA4B,EAC5B,gBAAgB,EAChB,sBAAsB,EACtB,mBAAmB,EACnB,oBAAoB,EACpB,YAAY,GACb,MAAM,SAAS,CAAA;AAChB,MAAM,MAAM,gBAAgB,GAAG,mBAAmB,CAAC,UAAU,CAAC,CAAA;AAC9D,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,CAAA"}
package/dist/index.js CHANGED
@@ -41,6 +41,7 @@ const event_types_js_namespaceObject = require("./extensions/event-types.js");
41
41
  const internal_js_namespaceObject = require("./extensions/internal.js");
42
42
  const logger_js_namespaceObject = require("./extensions/logger.js");
43
43
  const capture_js_namespaceObject = require("./extensions/capture.js");
44
+ const lib_identity_js_namespaceObject = require("./extensions/lib-identity.js");
44
45
  const session_js_namespaceObject = require("./extensions/session.js");
45
46
  const instrument_lowlevel_js_namespaceObject = require("./extensions/instrument-lowlevel.js");
46
47
  const instrument_highlevel_js_namespaceObject = require("./extensions/instrument-highlevel.js");
@@ -58,6 +59,7 @@ function instrument(server, posthog, options = {}) {
58
59
  (0, logger_js_namespaceObject.log)('instrument() - Server already instrumented, skipping initialization');
59
60
  return createAnalyticsHandle(lowLevelServer);
60
61
  }
62
+ if (posthog) (0, lib_identity_js_namespaceObject.applyMcpLibIdentity)(posthog);
61
63
  const sink = posthog ? new sink_js_namespaceObject.McpEventSink(posthog) : void 0;
62
64
  const mcpAnalyticsData = buildTrackingData(lowLevelServer, options, sink);
63
65
  (0, internal_js_namespaceObject.setServerTrackingData)(lowLevelServer, mcpAnalyticsData);
package/dist/index.mjs CHANGED
@@ -4,6 +4,7 @@ import { MCPAnalyticsEventType } from "./extensions/event-types.mjs";
4
4
  import { IdentityCache, getServerTrackingData, setServerTrackingData } from "./extensions/internal.mjs";
5
5
  import { log, setLogger } from "./extensions/logger.mjs";
6
6
  import { captureEvent } from "./extensions/capture.mjs";
7
+ import { applyMcpLibIdentity } from "./extensions/lib-identity.mjs";
7
8
  import { deriveSessionIdFromMCPSession, getSessionInfo, newSessionId } from "./extensions/session.mjs";
8
9
  import { instrumentLowLevelServer } from "./extensions/instrument-lowlevel.mjs";
9
10
  import { instrumentHighLevelServer } from "./extensions/instrument-highlevel.mjs";
@@ -21,6 +22,7 @@ function instrument(server, posthog, options = {}) {
21
22
  log('instrument() - Server already instrumented, skipping initialization');
22
23
  return createAnalyticsHandle(lowLevelServer);
23
24
  }
25
+ if (posthog) applyMcpLibIdentity(posthog);
24
26
  const sink = posthog ? new McpEventSink(posthog) : void 0;
25
27
  const mcpAnalyticsData = buildTrackingData(lowLevelServer, options, sink);
26
28
  setServerTrackingData(lowLevelServer, mcpAnalyticsData);
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const version = "0.6.0";
1
+ export declare const version = "0.7.0";
2
2
  //# sourceMappingURL=version.d.ts.map
package/dist/version.js CHANGED
@@ -26,7 +26,7 @@ __webpack_require__.r(__webpack_exports__);
26
26
  __webpack_require__.d(__webpack_exports__, {
27
27
  version: ()=>version
28
28
  });
29
- const version = '0.6.0';
29
+ const version = '0.7.0';
30
30
  exports.version = __webpack_exports__.version;
31
31
  for(var __webpack_i__ in __webpack_exports__)if (-1 === [
32
32
  "version"
package/dist/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- const version = '0.6.0';
1
+ const version = '0.7.0';
2
2
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@posthog/mcp",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "bugs": {
5
5
  "url": "https://github.com/PostHog/posthog-js/issues"
6
6
  },
@@ -11,10 +11,11 @@ export const DEFAULT_CONVERSATION_ID_DESCRIPTION =
11
11
 
12
12
  export const POSTHOG_MCP_ANALYTICS_SOURCE = 'posthog_mcp_analytics'
13
13
 
14
- // Identifies the SDK that produced an `$mcp_*` event. Distinct from `$lib`
15
- // (posthog-node, the transport that actually sends the event) — this names the
16
- // higher-level analytics layer, mirroring `@posthog/ai`'s `$ai_lib`.
17
- export const POSTHOG_MCP_LIB_NAME = '@posthog/mcp'
14
+ // The `$lib` identity stamped on every event @posthog/mcp sends. posthog-node
15
+ // would otherwise report itself (`posthog-node`, the transport SDK); we override
16
+ // `getLibraryId()` so MCP events self-identify the same way every other PostHog
17
+ // SDK does. See `applyMcpLibIdentity` in `./lib-identity`.
18
+ export const POSTHOG_MCP_LIB_NAME = 'posthog-node-mcp'
18
19
 
19
20
  // All PostHog-owned event names start with `$` per the PostHog convention.
20
21
  // Non-`$` names would be treated as customer-defined events and confuse the schema.
@@ -43,8 +44,6 @@ export const PostHogMCPAnalyticsProperty = {
43
44
  Intent: '$mcp_intent',
44
45
  IntentSource: '$mcp_intent_source',
45
46
  ListedToolNames: '$mcp_listed_tool_names',
46
- McpLib: '$mcp_lib',
47
- McpLibVersion: '$mcp_lib_version',
48
47
  Parameters: '$mcp_parameters',
49
48
  ResourceName: '$mcp_resource_name',
50
49
  Response: '$mcp_response',
@@ -0,0 +1,25 @@
1
+ import type { PostHog } from 'posthog-node'
2
+
3
+ import { version } from '../version'
4
+ import { POSTHOG_MCP_LIB_NAME } from './constants'
5
+
6
+ /**
7
+ * Make `client` report `@posthog/mcp`'s identity as the standard PostHog `$lib`
8
+ * / `$lib_version` on every event it sends.
9
+ *
10
+ * posthog-node stamps `$lib` / `$lib_version` from `getLibraryId()` /
11
+ * `getLibraryVersion()` and spreads them *last* when building the payload, so
12
+ * they can't be overridden per-event via the captured properties (nor via
13
+ * `before_send`, which runs earlier). Overriding the two methods is the only
14
+ * lever. Shared by {@link PostHogMCP} (which calls this in its constructor) and
15
+ * `instrument()` (which applies it to the host-supplied client) so both emit
16
+ * paths report identical lib metadata.
17
+ *
18
+ * Because `$lib` is a client-level property, this relabels *every* event the
19
+ * client sends as `posthog-node-mcp`, not just `$mcp_*` events — expected for a
20
+ * dedicated MCP-analytics client.
21
+ */
22
+ export function applyMcpLibIdentity(client: PostHog): void {
23
+ client.getLibraryId = () => POSTHOG_MCP_LIB_NAME
24
+ client.getLibraryVersion = () => version
25
+ }
@@ -3,12 +3,7 @@
3
3
  // Licensed under the MIT License: https://github.com/MCPCat/mcpcat-typescript-sdk/blob/main/LICENSE
4
4
 
5
5
  import type { Event } from '../types'
6
- import {
7
- POSTHOG_MCP_ANALYTICS_SOURCE,
8
- POSTHOG_MCP_LIB_NAME,
9
- PostHogMCPAnalyticsEvent,
10
- PostHogMCPAnalyticsProperty,
11
- } from './constants'
6
+ import { POSTHOG_MCP_ANALYTICS_SOURCE, PostHogMCPAnalyticsEvent, PostHogMCPAnalyticsProperty } from './constants'
12
7
  import { MCPAnalyticsEventType } from './event-types'
13
8
 
14
9
  const BUILT_IN_EVENT_NAME_BY_TYPE = {
@@ -155,7 +150,6 @@ function addCommonEventProperties(event: Event, properties: Record<string, unkno
155
150
  if (event.clientVersion) {
156
151
  properties[PostHogMCPAnalyticsProperty.ClientVersion] = event.clientVersion
157
152
  }
158
- addMcpLibProperties(event, properties)
159
153
  if (event.userIntent) {
160
154
  properties[PostHogMCPAnalyticsProperty.Intent] = event.userIntent
161
155
  }
@@ -187,18 +181,6 @@ function addCustomEventProperties(event: Event, properties: Record<string, unkno
187
181
  }
188
182
  }
189
183
 
190
- /**
191
- * Stamps the `@posthog/mcp` SDK identity (`$mcp_lib` / `$mcp_lib_version`) onto
192
- * the event. Shared by the regular and `$exception` builders so both report
193
- * which analytics SDK release produced the event.
194
- */
195
- function addMcpLibProperties(event: Event, properties: Record<string, unknown>): void {
196
- if (event.sdkVersion) {
197
- properties[PostHogMCPAnalyticsProperty.McpLib] = POSTHOG_MCP_LIB_NAME
198
- properties[PostHogMCPAnalyticsProperty.McpLibVersion] = event.sdkVersion
199
- }
200
- }
201
-
202
184
  function buildExceptionEvent(event: Event): PostHogCaptureEvent {
203
185
  const distinctId = getDistinctId(event)
204
186
  const timestamp = getTimestamp(event)
@@ -239,7 +221,6 @@ function buildExceptionEvent(event: Event): PostHogCaptureEvent {
239
221
  if (event.clientVersion) {
240
222
  properties[PostHogMCPAnalyticsProperty.ClientVersion] = event.clientVersion
241
223
  }
242
- addMcpLibProperties(event, properties)
243
224
 
244
225
  addCustomEventProperties(event, properties)
245
226
 
@@ -1,6 +1,5 @@
1
1
  import { PostHog, type PostHogOptions } from 'posthog-node'
2
2
 
3
- import { version } from '../version'
4
3
  import type {
5
4
  InitializeCaptureData,
6
5
  JsonRecord,
@@ -20,6 +19,7 @@ import {
20
19
  } from './context-parameters'
21
20
  import { MCPAnalyticsEventType } from './event-types'
22
21
  import { captureException } from './exceptions'
22
+ import { applyMcpLibIdentity } from './lib-identity'
23
23
  import { log } from './logger'
24
24
  import { McpEventSink } from './sink'
25
25
  import { GET_MORE_TOOLS_NAME, getReportMissingToolDescriptor } from './tools'
@@ -85,6 +85,8 @@ export class PostHogMCP extends PostHog {
85
85
  constructor(apiKey: string, options: PostHogMCPOptions = {}) {
86
86
  super(apiKey, options)
87
87
  this.#missingCapabilityToolName = options.missingCapabilityToolName ?? GET_MORE_TOOLS_NAME
88
+ // Report `$lib: 'posthog-node-mcp'` instead of the inherited `posthog-node`.
89
+ applyMcpLibIdentity(this)
88
90
  }
89
91
 
90
92
  /** Capture a tool invocation. Emits `$mcp_tool_call` (+ an `$exception` sibling on error). */
@@ -242,7 +244,6 @@ function baseEvent(eventType: MCPAnalyticsEventType, common: McpCaptureCommon):
242
244
  timestamp: common.timestamp ?? new Date(),
243
245
  properties: common.properties,
244
246
  groups: common.groups,
245
- sdkVersion: version,
246
247
  }
247
248
  if (common.distinctId) {
248
249
  event.identifyActorGivenId = common.distinctId
package/src/index.ts CHANGED
@@ -9,6 +9,7 @@ import { MCPAnalyticsEventType } from './extensions/event-types'
9
9
  import { IdentityCache, getServerTrackingData, setServerTrackingData } from './extensions/internal'
10
10
  import { log, setLogger } from './extensions/logger'
11
11
  import { captureEvent } from './extensions/capture'
12
+ import { applyMcpLibIdentity } from './extensions/lib-identity'
12
13
  import { deriveSessionIdFromMCPSession, getSessionInfo, newSessionId } from './extensions/session'
13
14
  import { instrumentLowLevelServer } from './extensions/instrument-lowlevel'
14
15
  import { instrumentHighLevelServer } from './extensions/instrument-highlevel'
@@ -65,6 +66,11 @@ function instrument(server: unknown, posthog: PostHog, options: MCPAnalyticsOpti
65
66
  return createAnalyticsHandle(lowLevelServer)
66
67
  }
67
68
 
69
+ if (posthog) {
70
+ // Report `$lib: 'posthog-node-mcp'` on this client's events instead of the
71
+ // inherited `posthog-node`. Relabels every event the client sends.
72
+ applyMcpLibIdentity(posthog)
73
+ }
68
74
  const sink = posthog ? new McpEventSink(posthog) : undefined
69
75
  const mcpAnalyticsData = buildTrackingData(lowLevelServer, options, sink)
70
76
 
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '0.6.0'
1
+ export const version = '0.7.0'