@posthog/mcp 0.6.0 → 0.8.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.
- package/dist/extensions/capture.d.ts.map +1 -1
- package/dist/extensions/capture.js +1 -0
- package/dist/extensions/capture.mjs +1 -0
- package/dist/extensions/constants.d.ts +3 -3
- package/dist/extensions/constants.d.ts.map +1 -1
- package/dist/extensions/constants.js +3 -3
- package/dist/extensions/constants.mjs +3 -3
- package/dist/extensions/lib-identity.d.ts +19 -0
- package/dist/extensions/lib-identity.d.ts.map +1 -0
- package/dist/extensions/lib-identity.js +41 -0
- package/dist/extensions/lib-identity.mjs +7 -0
- package/dist/extensions/posthog-events.d.ts.map +1 -1
- package/dist/extensions/posthog-events.js +6 -8
- package/dist/extensions/posthog-events.mjs +7 -9
- package/dist/extensions/posthog-mcp.d.ts.map +1 -1
- package/dist/extensions/posthog-mcp.js +5 -3
- package/dist/extensions/posthog-mcp.mjs +5 -3
- package/dist/extensions/truncation.d.ts.map +1 -1
- package/dist/extensions/truncation.js +1 -0
- package/dist/extensions/truncation.mjs +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.mjs +2 -0
- package/dist/types.d.ts +16 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.mjs +1 -1
- package/package.json +4 -4
- package/src/extensions/capture.ts +7 -0
- package/src/extensions/constants.ts +7 -6
- package/src/extensions/lib-identity.ts +25 -0
- package/src/extensions/posthog-events.ts +16 -20
- package/src/extensions/posthog-mcp.ts +5 -2
- package/src/extensions/truncation.ts +1 -0
- package/src/index.ts +6 -0
- package/src/types.ts +16 -0
- package/src/version.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capture.d.ts","sourceRoot":"","sources":["../../src/extensions/capture.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAMvD;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"capture.d.ts","sourceRoot":"","sources":["../../src/extensions/capture.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAMvD;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,SAAS,CA2DnG"}
|
|
@@ -64,6 +64,7 @@ function captureEvent(server, eventInput) {
|
|
|
64
64
|
userIntentSource: eventInput.userIntentSource,
|
|
65
65
|
isError: eventInput.isError,
|
|
66
66
|
error: eventInput.error,
|
|
67
|
+
errorType: eventInput.errorType,
|
|
67
68
|
conversationId: eventInput.conversationId,
|
|
68
69
|
properties: eventInput.properties
|
|
69
70
|
};
|
|
@@ -36,6 +36,7 @@ function captureEvent(server, eventInput) {
|
|
|
36
36
|
userIntentSource: eventInput.userIntentSource,
|
|
37
37
|
isError: eventInput.isError,
|
|
38
38
|
error: eventInput.error,
|
|
39
|
+
errorType: eventInput.errorType,
|
|
39
40
|
conversationId: eventInput.conversationId,
|
|
40
41
|
properties: eventInput.properties
|
|
41
42
|
};
|
|
@@ -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 = "
|
|
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";
|
|
@@ -22,12 +22,12 @@ export declare const PostHogMCPAnalyticsProperty: {
|
|
|
22
22
|
readonly ClientVersion: "$mcp_client_version";
|
|
23
23
|
readonly ConversationId: "$mcp_conversation_id";
|
|
24
24
|
readonly DurationMs: "$mcp_duration_ms";
|
|
25
|
+
readonly ErrorMessage: "$mcp_error_message";
|
|
26
|
+
readonly ErrorType: "$mcp_error_type";
|
|
25
27
|
readonly IsError: "$mcp_is_error";
|
|
26
28
|
readonly Intent: "$mcp_intent";
|
|
27
29
|
readonly IntentSource: "$mcp_intent_source";
|
|
28
30
|
readonly ListedToolNames: "$mcp_listed_tool_names";
|
|
29
|
-
readonly McpLib: "$mcp_lib";
|
|
30
|
-
readonly McpLibVersion: "$mcp_lib_version";
|
|
31
31
|
readonly Parameters: "$mcp_parameters";
|
|
32
32
|
readonly ResourceName: "$mcp_resource_name";
|
|
33
33
|
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;
|
|
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;;;;;;;;;;;;;;;;;;;;;CAqB9B,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 = '
|
|
39
|
+
const POSTHOG_MCP_LIB_NAME = 'posthog-node-mcp';
|
|
40
40
|
const PostHogMCPAnalyticsEvent = {
|
|
41
41
|
Custom: '$mcp_custom',
|
|
42
42
|
Exception: '$exception',
|
|
@@ -55,12 +55,12 @@ const PostHogMCPAnalyticsProperty = {
|
|
|
55
55
|
ClientVersion: '$mcp_client_version',
|
|
56
56
|
ConversationId: '$mcp_conversation_id',
|
|
57
57
|
DurationMs: '$mcp_duration_ms',
|
|
58
|
+
ErrorMessage: '$mcp_error_message',
|
|
59
|
+
ErrorType: '$mcp_error_type',
|
|
58
60
|
IsError: '$mcp_is_error',
|
|
59
61
|
Intent: '$mcp_intent',
|
|
60
62
|
IntentSource: '$mcp_intent_source',
|
|
61
63
|
ListedToolNames: '$mcp_listed_tool_names',
|
|
62
|
-
McpLib: '$mcp_lib',
|
|
63
|
-
McpLibVersion: '$mcp_lib_version',
|
|
64
64
|
Parameters: '$mcp_parameters',
|
|
65
65
|
ResourceName: '$mcp_resource_name',
|
|
66
66
|
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 = '
|
|
5
|
+
const POSTHOG_MCP_LIB_NAME = 'posthog-node-mcp';
|
|
6
6
|
const PostHogMCPAnalyticsEvent = {
|
|
7
7
|
Custom: '$mcp_custom',
|
|
8
8
|
Exception: '$exception',
|
|
@@ -21,12 +21,12 @@ const PostHogMCPAnalyticsProperty = {
|
|
|
21
21
|
ClientVersion: '$mcp_client_version',
|
|
22
22
|
ConversationId: '$mcp_conversation_id',
|
|
23
23
|
DurationMs: '$mcp_duration_ms',
|
|
24
|
+
ErrorMessage: '$mcp_error_message',
|
|
25
|
+
ErrorType: '$mcp_error_type',
|
|
24
26
|
IsError: '$mcp_is_error',
|
|
25
27
|
Intent: '$mcp_intent',
|
|
26
28
|
IntentSource: '$mcp_intent_source',
|
|
27
29
|
ListedToolNames: '$mcp_listed_tool_names',
|
|
28
|
-
McpLib: '$mcp_lib',
|
|
29
|
-
McpLibVersion: '$mcp_lib_version',
|
|
30
30
|
Parameters: '$mcp_parameters',
|
|
31
31
|
ResourceName: '$mcp_resource_name',
|
|
32
32
|
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;
|
|
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,10 +98,15 @@ 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;
|
|
104
|
+
if (event.isError) {
|
|
105
|
+
const firstException = event.error?.$exception_list?.[0];
|
|
106
|
+
const errorType = event.errorType ?? firstException?.type;
|
|
107
|
+
if (errorType) properties[external_constants_js_namespaceObject.PostHogMCPAnalyticsProperty.ErrorType] = errorType;
|
|
108
|
+
if (firstException?.value) properties[external_constants_js_namespaceObject.PostHogMCPAnalyticsProperty.ErrorMessage] = firstException.value;
|
|
109
|
+
}
|
|
105
110
|
if (void 0 !== event.parameters) properties[external_constants_js_namespaceObject.PostHogMCPAnalyticsProperty.Parameters] = event.parameters;
|
|
106
111
|
if (void 0 !== event.response) properties[external_constants_js_namespaceObject.PostHogMCPAnalyticsProperty.Response] = event.response;
|
|
107
112
|
if (event.identifyActorData && Object.keys(event.identifyActorData).length > 0) properties.$set = {
|
|
@@ -111,12 +116,6 @@ function addCommonEventProperties(event, properties) {
|
|
|
111
116
|
function addCustomEventProperties(event, properties) {
|
|
112
117
|
if (event.properties) for (const [key, value] of Object.entries(event.properties))properties[key] = value;
|
|
113
118
|
}
|
|
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
119
|
function buildExceptionEvent(event) {
|
|
121
120
|
const distinctId = getDistinctId(event);
|
|
122
121
|
const timestamp = getTimestamp(event);
|
|
@@ -136,7 +135,6 @@ function buildExceptionEvent(event) {
|
|
|
136
135
|
if (event.serverVersion) properties[external_constants_js_namespaceObject.PostHogMCPAnalyticsProperty.ServerVersion] = event.serverVersion;
|
|
137
136
|
if (event.clientName) properties[external_constants_js_namespaceObject.PostHogMCPAnalyticsProperty.ClientName] = event.clientName;
|
|
138
137
|
if (event.clientVersion) properties[external_constants_js_namespaceObject.PostHogMCPAnalyticsProperty.ClientVersion] = event.clientVersion;
|
|
139
|
-
addMcpLibProperties(event, properties);
|
|
140
138
|
addCustomEventProperties(event, properties);
|
|
141
139
|
return {
|
|
142
140
|
event: external_constants_js_namespaceObject.PostHogMCPAnalyticsEvent.Exception,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { POSTHOG_MCP_ANALYTICS_SOURCE,
|
|
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,10 +70,15 @@ 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;
|
|
76
|
+
if (event.isError) {
|
|
77
|
+
const firstException = event.error?.$exception_list?.[0];
|
|
78
|
+
const errorType = event.errorType ?? firstException?.type;
|
|
79
|
+
if (errorType) properties[PostHogMCPAnalyticsProperty.ErrorType] = errorType;
|
|
80
|
+
if (firstException?.value) properties[PostHogMCPAnalyticsProperty.ErrorMessage] = firstException.value;
|
|
81
|
+
}
|
|
77
82
|
if (void 0 !== event.parameters) properties[PostHogMCPAnalyticsProperty.Parameters] = event.parameters;
|
|
78
83
|
if (void 0 !== event.response) properties[PostHogMCPAnalyticsProperty.Response] = event.response;
|
|
79
84
|
if (event.identifyActorData && Object.keys(event.identifyActorData).length > 0) properties.$set = {
|
|
@@ -83,12 +88,6 @@ function addCommonEventProperties(event, properties) {
|
|
|
83
88
|
function addCustomEventProperties(event, properties) {
|
|
84
89
|
if (event.properties) for (const [key, value] of Object.entries(event.properties))properties[key] = value;
|
|
85
90
|
}
|
|
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
91
|
function buildExceptionEvent(event) {
|
|
93
92
|
const distinctId = getDistinctId(event);
|
|
94
93
|
const timestamp = getTimestamp(event);
|
|
@@ -108,7 +107,6 @@ function buildExceptionEvent(event) {
|
|
|
108
107
|
if (event.serverVersion) properties[PostHogMCPAnalyticsProperty.ServerVersion] = event.serverVersion;
|
|
109
108
|
if (event.clientName) properties[PostHogMCPAnalyticsProperty.ClientName] = event.clientName;
|
|
110
109
|
if (event.clientVersion) properties[PostHogMCPAnalyticsProperty.ClientVersion] = event.clientVersion;
|
|
111
|
-
addMcpLibProperties(event, properties);
|
|
112
110
|
addCustomEventProperties(event, properties);
|
|
113
111
|
return {
|
|
114
112
|
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;
|
|
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;AAE3D,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;AAQ7B;;;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;IAO3D,8FAA8F;IAC9F,eAAe,CAAC,IAAI,EAAE,mBAAmB,GAAG,IAAI;IAiBhD,iEAAiE;IACjE,iBAAiB,CAAC,IAAI,EAAE,qBAAqB,GAAG,IAAI;IAUpD;;;;;OAKG;IACH,gBAAgB,CAAC,IAAI,EAAE,oBAAoB,GAAG,IAAI;IAclD;;;;;;;;;;;;;;;;;;;;;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,EAAE,4BAA4B,GAAG,IAAI;CAkBnE"}
|
|
@@ -27,10 +27,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);
|
|
@@ -50,6 +51,7 @@ class PostHogMCP extends external_posthog_node_namespaceObject.PostHog {
|
|
|
50
51
|
event.response = data.response;
|
|
51
52
|
event.duration = data.durationMs;
|
|
52
53
|
event.isError = data.isError;
|
|
54
|
+
event.errorType = data.errorType;
|
|
53
55
|
applyIntent(event, data.intent, data.intentSource);
|
|
54
56
|
if (data.isError) event.error = (0, external_exceptions_js_namespaceObject.captureException)(data.error ?? `Tool ${data.toolName} returned an error`);
|
|
55
57
|
this.#emit(event);
|
|
@@ -70,6 +72,7 @@ class PostHogMCP extends external_posthog_node_namespaceObject.PostHog {
|
|
|
70
72
|
event.response = data.response;
|
|
71
73
|
event.duration = data.durationMs;
|
|
72
74
|
event.isError = data.isError;
|
|
75
|
+
event.errorType = data.errorType;
|
|
73
76
|
if (data.isError) event.error = (0, external_exceptions_js_namespaceObject.captureException)(data.error ?? 'tools/list failed');
|
|
74
77
|
this.#emit(event);
|
|
75
78
|
}
|
|
@@ -113,8 +116,7 @@ function baseEvent(eventType, common) {
|
|
|
113
116
|
sessionId: common.sessionId,
|
|
114
117
|
timestamp: common.timestamp ?? new Date(),
|
|
115
118
|
properties: common.properties,
|
|
116
|
-
groups: common.groups
|
|
117
|
-
sdkVersion: external_version_js_namespaceObject.version
|
|
119
|
+
groups: common.groups
|
|
118
120
|
};
|
|
119
121
|
if (common.distinctId) event.identifyActorGivenId = common.distinctId;
|
|
120
122
|
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);
|
|
@@ -22,6 +23,7 @@ class PostHogMCP extends PostHog {
|
|
|
22
23
|
event.response = data.response;
|
|
23
24
|
event.duration = data.durationMs;
|
|
24
25
|
event.isError = data.isError;
|
|
26
|
+
event.errorType = data.errorType;
|
|
25
27
|
applyIntent(event, data.intent, data.intentSource);
|
|
26
28
|
if (data.isError) event.error = captureException(data.error ?? `Tool ${data.toolName} returned an error`);
|
|
27
29
|
this.#emit(event);
|
|
@@ -42,6 +44,7 @@ class PostHogMCP extends PostHog {
|
|
|
42
44
|
event.response = data.response;
|
|
43
45
|
event.duration = data.durationMs;
|
|
44
46
|
event.isError = data.isError;
|
|
47
|
+
event.errorType = data.errorType;
|
|
45
48
|
if (data.isError) event.error = captureException(data.error ?? 'tools/list failed');
|
|
46
49
|
this.#emit(event);
|
|
47
50
|
}
|
|
@@ -85,8 +88,7 @@ function baseEvent(eventType, common) {
|
|
|
85
88
|
sessionId: common.sessionId,
|
|
86
89
|
timestamp: common.timestamp ?? new Date(),
|
|
87
90
|
properties: common.properties,
|
|
88
|
-
groups: common.groups
|
|
89
|
-
sdkVersion: version
|
|
91
|
+
groups: common.groups
|
|
90
92
|
};
|
|
91
93
|
if (common.distinctId) event.identifyActorGivenId = common.distinctId;
|
|
92
94
|
if (common.setProperties && Object.keys(common.setProperties).length > 0) event.identifyActorData = common.setProperties;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"truncation.d.ts","sourceRoot":"","sources":["../../src/extensions/truncation.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAmB,KAAK,EAAc,QAAQ,EAAE,MAAM,UAAU,CAAA;AAG5E,eAAO,MAAM,SAAS,KAAK,CAAA;AAC3B,eAAO,MAAM,WAAW,MAAM,CAAA;AAC9B,eAAO,MAAM,iBAAiB,QAAS,CAAA;AACvC,eAAO,MAAM,eAAe,SAAU,CAAA;AAgBtC;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CACvB,KAAK,EAAE,OAAO,EACd,KAAK,GAAE,MAAkB,EACzB,UAAU,GAAE,MAAoB,EAChC,eAAe,GAAE,MAA0B,GAC1C,OAAO,CAGT;AAkXD;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,KAAK,GAAG,QAAQ,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"truncation.d.ts","sourceRoot":"","sources":["../../src/extensions/truncation.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAmB,KAAK,EAAc,QAAQ,EAAE,MAAM,UAAU,CAAA;AAG5E,eAAO,MAAM,SAAS,KAAK,CAAA;AAC3B,eAAO,MAAM,WAAW,MAAM,CAAA;AAC9B,eAAO,MAAM,iBAAiB,QAAS,CAAA;AACvC,eAAO,MAAM,eAAe,SAAU,CAAA;AAgBtC;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CACvB,KAAK,EAAE,OAAO,EACd,KAAK,GAAE,MAAkB,EACzB,UAAU,GAAE,MAAoB,EAChC,eAAe,GAAE,MAA0B,GAC1C,OAAO,CAGT;AAkXD;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,KAAK,GAAG,QAAQ,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAoCrE"}
|
|
@@ -250,6 +250,7 @@ function truncateEvent(event) {
|
|
|
250
250
|
result.serverVersion = truncateString(result.serverVersion, MAX_METADATA_LENGTH);
|
|
251
251
|
result.clientName = truncateString(result.clientName, MAX_METADATA_LENGTH);
|
|
252
252
|
result.clientVersion = truncateString(result.clientVersion, MAX_METADATA_LENGTH);
|
|
253
|
+
result.errorType = truncateString(result.errorType, MAX_METADATA_LENGTH);
|
|
253
254
|
if (null != result.error && 'object' == typeof result.error) result.error = truncateExceptionList(result.error);
|
|
254
255
|
result.response = truncateResponseContent(result.response);
|
|
255
256
|
if (null != result.parameters) result.parameters = normalize(result.parameters);
|
|
@@ -217,6 +217,7 @@ function truncateEvent(event) {
|
|
|
217
217
|
result.serverVersion = truncateString(result.serverVersion, MAX_METADATA_LENGTH);
|
|
218
218
|
result.clientName = truncateString(result.clientName, MAX_METADATA_LENGTH);
|
|
219
219
|
result.clientVersion = truncateString(result.clientVersion, MAX_METADATA_LENGTH);
|
|
220
|
+
result.errorType = truncateString(result.errorType, MAX_METADATA_LENGTH);
|
|
220
221
|
if (null != result.error && 'object' == typeof result.error) result.error = truncateExceptionList(result.error);
|
|
221
222
|
result.response = truncateResponseContent(result.response);
|
|
222
223
|
if (null != result.parameters) result.parameters = normalize(result.parameters);
|
package/dist/index.d.ts.map
CHANGED
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"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,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/types.d.ts
CHANGED
|
@@ -114,6 +114,13 @@ export interface Event {
|
|
|
114
114
|
conversationId?: string;
|
|
115
115
|
duration?: number;
|
|
116
116
|
error?: ErrorProperties | null;
|
|
117
|
+
/**
|
|
118
|
+
* Coarse failure category → `$mcp_error_type`. An explicit, low-cardinality
|
|
119
|
+
* label the host can supply (e.g. `validation`, `permission`, `timeout`).
|
|
120
|
+
* When omitted on an errored call, it falls back to the thrown error's type
|
|
121
|
+
* (the `$exception_list` entry's `type`).
|
|
122
|
+
*/
|
|
123
|
+
errorType?: string;
|
|
117
124
|
eventId?: string;
|
|
118
125
|
eventType: MCPAnalyticsEventType;
|
|
119
126
|
groups?: Record<string, string>;
|
|
@@ -286,6 +293,13 @@ export interface ToolCallCaptureData extends McpCaptureCommon {
|
|
|
286
293
|
* synthesized from the tool name.
|
|
287
294
|
*/
|
|
288
295
|
error?: unknown;
|
|
296
|
+
/**
|
|
297
|
+
* Coarse failure category → `$mcp_error_type` (e.g. `validation`,
|
|
298
|
+
* `permission`, `timeout`, `rate_limited`). A low-cardinality label that lets
|
|
299
|
+
* the dashboard break failures down by reason without joining to `$exception`.
|
|
300
|
+
* When omitted on an error, the SDK falls back to the thrown error's type.
|
|
301
|
+
*/
|
|
302
|
+
errorType?: string;
|
|
289
303
|
}
|
|
290
304
|
/** Payload for {@link PostHogMCP.captureInitialize}. Emits `$mcp_initialize`. */
|
|
291
305
|
export interface InitializeCaptureData extends McpCaptureCommon {
|
|
@@ -317,6 +331,8 @@ export interface ToolsListCaptureData extends McpCaptureCommon {
|
|
|
317
331
|
isError?: boolean;
|
|
318
332
|
/** The thrown value when `isError` is true → fans out an `$exception` sibling. */
|
|
319
333
|
error?: unknown;
|
|
334
|
+
/** Coarse failure category → `$mcp_error_type`. Falls back to the thrown error's type. */
|
|
335
|
+
errorType?: string;
|
|
320
336
|
}
|
|
321
337
|
/** Options for {@link PostHogMCP.prepareToolList}. */
|
|
322
338
|
export interface PrepareToolListOptions {
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAA;AACxE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAClD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAA;AACrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAC1D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAA;AACtE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AACrD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAEnD,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAEhD,+FAA+F;AAC/F,MAAM,MAAM,eAAe,GAAG,aAAa,CAAC,eAAe,CAAA;AAC3D,qEAAqE;AACrE,MAAM,MAAM,UAAU,GAAG,aAAa,CAAC,UAAU,CAAA;AAEjD,MAAM,WAAW,oBAAoB;IACnC,SAAS,CAAC,EAAE,UAAU,CAAA;IACtB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,CAAC,GAAG,EAAE,MAAM,GA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,OAAO,GAAG,0BAA0B,CAAA;IAC9C;;;;OAIG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;CACxB;AAED;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,sEAAsE;IACtE,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,4EAA4E;IAC5E,YAAY,CAAC,EAAE,wBAAwB,CAAA;IACvC,uEAAuE;IACvE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC9B,6DAA6D;IAC7D,mBAAmB,EAAE,OAAO,CAAA;CAC7B;AAED,gGAAgG;AAChG,MAAM,WAAW,4BAA6B,SAAQ,gBAAgB;IACpE;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,2EAA2E;IAC3E,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB"}
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "0.
|
|
1
|
+
export declare const version = "0.8.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.
|
|
29
|
+
const version = '0.8.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.
|
|
1
|
+
const version = '0.8.0';
|
|
2
2
|
export { version };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@posthog/mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"bugs": {
|
|
5
5
|
"url": "https://github.com/PostHog/posthog-js/issues"
|
|
6
6
|
},
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"module": "dist/index.mjs",
|
|
29
29
|
"types": "dist/index.d.ts",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@posthog/core": "^1.39.
|
|
31
|
+
"@posthog/core": "^1.39.6"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@babel/preset-env": "^7.27.1",
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"@types/node": "^20.0.0",
|
|
40
40
|
"jest": "29.7.0",
|
|
41
41
|
"zod": "^3.25.0",
|
|
42
|
-
"
|
|
43
|
-
"posthog-
|
|
42
|
+
"posthog-node": "^5.39.4",
|
|
43
|
+
"@posthog-tooling/tsconfig-base": "1.1.1"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"@modelcontextprotocol/sdk": ">=1.26.0",
|
|
@@ -61,7 +61,14 @@ export function captureEvent(server: MCPServerLike, eventInput: McpEvent): Promi
|
|
|
61
61
|
userIntent: eventInput.userIntent,
|
|
62
62
|
userIntentSource: eventInput.userIntentSource,
|
|
63
63
|
isError: eventInput.isError,
|
|
64
|
+
// Two consumers of the same failure: `error` is the full thrown value that
|
|
65
|
+
// fans out into the separate `$exception` event (stacktrace, error-tracking
|
|
66
|
+
// grouping), while `errorType` is a coarse category kept on this tool-call
|
|
67
|
+
// event so the dashboard can break failures down by reason without joining
|
|
68
|
+
// to `$exception`. The error message is derived from `error` onto this event
|
|
69
|
+
// downstream in posthog-events.ts.
|
|
64
70
|
error: eventInput.error,
|
|
71
|
+
errorType: eventInput.errorType,
|
|
65
72
|
conversationId: eventInput.conversationId,
|
|
66
73
|
properties: eventInput.properties,
|
|
67
74
|
}
|
|
@@ -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
|
-
//
|
|
15
|
-
// (posthog-node
|
|
16
|
-
//
|
|
17
|
-
|
|
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.
|
|
@@ -39,12 +40,12 @@ export const PostHogMCPAnalyticsProperty = {
|
|
|
39
40
|
ClientVersion: '$mcp_client_version',
|
|
40
41
|
ConversationId: '$mcp_conversation_id',
|
|
41
42
|
DurationMs: '$mcp_duration_ms',
|
|
43
|
+
ErrorMessage: '$mcp_error_message',
|
|
44
|
+
ErrorType: '$mcp_error_type',
|
|
42
45
|
IsError: '$mcp_is_error',
|
|
43
46
|
Intent: '$mcp_intent',
|
|
44
47
|
IntentSource: '$mcp_intent_source',
|
|
45
48
|
ListedToolNames: '$mcp_listed_tool_names',
|
|
46
|
-
McpLib: '$mcp_lib',
|
|
47
|
-
McpLibVersion: '$mcp_lib_version',
|
|
48
49
|
Parameters: '$mcp_parameters',
|
|
49
50
|
ResourceName: '$mcp_resource_name',
|
|
50
51
|
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
|
}
|
|
@@ -166,6 +160,21 @@ function addCommonEventProperties(event: Event, properties: Record<string, unkno
|
|
|
166
160
|
properties[PostHogMCPAnalyticsProperty.IsError] = event.isError
|
|
167
161
|
}
|
|
168
162
|
|
|
163
|
+
if (event.isError) {
|
|
164
|
+
// Surface the failure reason directly on the primary event so the dashboard
|
|
165
|
+
// can break errors down by cause without joining to the `$exception` sibling
|
|
166
|
+
// (which can be disabled, and isn't emitted when no error value is passed).
|
|
167
|
+
const firstException = event.error?.$exception_list?.[0]
|
|
168
|
+
const errorType = event.errorType ?? firstException?.type
|
|
169
|
+
if (errorType) {
|
|
170
|
+
properties[PostHogMCPAnalyticsProperty.ErrorType] = errorType
|
|
171
|
+
}
|
|
172
|
+
if (firstException?.value) {
|
|
173
|
+
// Already bounded to MAX_ERROR_MESSAGE_LENGTH by `truncateExceptionList`.
|
|
174
|
+
properties[PostHogMCPAnalyticsProperty.ErrorMessage] = firstException.value
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
169
178
|
if (event.parameters !== undefined) {
|
|
170
179
|
properties[PostHogMCPAnalyticsProperty.Parameters] = event.parameters
|
|
171
180
|
}
|
|
@@ -187,18 +196,6 @@ function addCustomEventProperties(event: Event, properties: Record<string, unkno
|
|
|
187
196
|
}
|
|
188
197
|
}
|
|
189
198
|
|
|
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
199
|
function buildExceptionEvent(event: Event): PostHogCaptureEvent {
|
|
203
200
|
const distinctId = getDistinctId(event)
|
|
204
201
|
const timestamp = getTimestamp(event)
|
|
@@ -239,7 +236,6 @@ function buildExceptionEvent(event: Event): PostHogCaptureEvent {
|
|
|
239
236
|
if (event.clientVersion) {
|
|
240
237
|
properties[PostHogMCPAnalyticsProperty.ClientVersion] = event.clientVersion
|
|
241
238
|
}
|
|
242
|
-
addMcpLibProperties(event, properties)
|
|
243
239
|
|
|
244
240
|
addCustomEventProperties(event, properties)
|
|
245
241
|
|
|
@@ -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). */
|
|
@@ -97,6 +99,7 @@ export class PostHogMCP extends PostHog {
|
|
|
97
99
|
event.response = data.response
|
|
98
100
|
event.duration = data.durationMs
|
|
99
101
|
event.isError = data.isError
|
|
102
|
+
event.errorType = data.errorType
|
|
100
103
|
applyIntent(event, data.intent, data.intentSource)
|
|
101
104
|
if (data.isError) {
|
|
102
105
|
event.error = captureException(data.error ?? `Tool ${data.toolName} returned an error`)
|
|
@@ -128,6 +131,7 @@ export class PostHogMCP extends PostHog {
|
|
|
128
131
|
event.response = data.response
|
|
129
132
|
event.duration = data.durationMs
|
|
130
133
|
event.isError = data.isError
|
|
134
|
+
event.errorType = data.errorType
|
|
131
135
|
if (data.isError) {
|
|
132
136
|
event.error = captureException(data.error ?? 'tools/list failed')
|
|
133
137
|
}
|
|
@@ -242,7 +246,6 @@ function baseEvent(eventType: MCPAnalyticsEventType, common: McpCaptureCommon):
|
|
|
242
246
|
timestamp: common.timestamp ?? new Date(),
|
|
243
247
|
properties: common.properties,
|
|
244
248
|
groups: common.groups,
|
|
245
|
-
sdkVersion: version,
|
|
246
249
|
}
|
|
247
250
|
if (common.distinctId) {
|
|
248
251
|
event.identifyActorGivenId = common.distinctId
|
|
@@ -429,6 +429,7 @@ export function truncateEvent<T extends Event | McpEvent>(event: T): T {
|
|
|
429
429
|
result.serverVersion = truncateString(result.serverVersion, MAX_METADATA_LENGTH)
|
|
430
430
|
result.clientName = truncateString(result.clientName, MAX_METADATA_LENGTH)
|
|
431
431
|
result.clientVersion = truncateString(result.clientVersion, MAX_METADATA_LENGTH)
|
|
432
|
+
result.errorType = truncateString(result.errorType, MAX_METADATA_LENGTH)
|
|
432
433
|
|
|
433
434
|
// Error field limits — operate on the core `$exception_list` shape
|
|
434
435
|
if (result.error != null && typeof result.error === 'object') {
|
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/types.ts
CHANGED
|
@@ -136,6 +136,13 @@ export interface Event {
|
|
|
136
136
|
conversationId?: string
|
|
137
137
|
duration?: number
|
|
138
138
|
error?: ErrorProperties | null
|
|
139
|
+
/**
|
|
140
|
+
* Coarse failure category → `$mcp_error_type`. An explicit, low-cardinality
|
|
141
|
+
* label the host can supply (e.g. `validation`, `permission`, `timeout`).
|
|
142
|
+
* When omitted on an errored call, it falls back to the thrown error's type
|
|
143
|
+
* (the `$exception_list` entry's `type`).
|
|
144
|
+
*/
|
|
145
|
+
errorType?: string
|
|
139
146
|
eventId?: string
|
|
140
147
|
eventType: MCPAnalyticsEventType
|
|
141
148
|
groups?: Record<string, string>
|
|
@@ -317,6 +324,13 @@ export interface ToolCallCaptureData extends McpCaptureCommon {
|
|
|
317
324
|
* synthesized from the tool name.
|
|
318
325
|
*/
|
|
319
326
|
error?: unknown
|
|
327
|
+
/**
|
|
328
|
+
* Coarse failure category → `$mcp_error_type` (e.g. `validation`,
|
|
329
|
+
* `permission`, `timeout`, `rate_limited`). A low-cardinality label that lets
|
|
330
|
+
* the dashboard break failures down by reason without joining to `$exception`.
|
|
331
|
+
* When omitted on an error, the SDK falls back to the thrown error's type.
|
|
332
|
+
*/
|
|
333
|
+
errorType?: string
|
|
320
334
|
}
|
|
321
335
|
|
|
322
336
|
/** Payload for {@link PostHogMCP.captureInitialize}. Emits `$mcp_initialize`. */
|
|
@@ -350,6 +364,8 @@ export interface ToolsListCaptureData extends McpCaptureCommon {
|
|
|
350
364
|
isError?: boolean
|
|
351
365
|
/** The thrown value when `isError` is true → fans out an `$exception` sibling. */
|
|
352
366
|
error?: unknown
|
|
367
|
+
/** Coarse failure category → `$mcp_error_type`. Falls back to the thrown error's type. */
|
|
368
|
+
errorType?: string
|
|
353
369
|
}
|
|
354
370
|
|
|
355
371
|
/** Options for {@link PostHogMCP.prepareToolList}. */
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '0.
|
|
1
|
+
export const version = '0.8.0'
|