@posthog/mcp 0.7.0 → 0.9.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/LICENSE +2 -2
- package/README.md +51 -0
- 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/compatibility.d.ts.map +1 -1
- package/dist/extensions/constants.d.ts +2 -0
- package/dist/extensions/constants.d.ts.map +1 -1
- package/dist/extensions/constants.js +2 -0
- package/dist/extensions/constants.mjs +2 -0
- package/dist/extensions/context-parameters.d.ts.map +1 -1
- package/dist/extensions/conversation-id.d.ts.map +1 -1
- package/dist/extensions/event-types.d.ts.map +1 -1
- package/dist/extensions/exceptions.d.ts.map +1 -1
- package/dist/extensions/ids.d.ts.map +1 -1
- package/dist/extensions/instrument-highlevel.d.ts.map +1 -1
- package/dist/extensions/instrument-lowlevel.d.ts.map +1 -1
- package/dist/extensions/instrumentation.d.ts.map +1 -1
- package/dist/extensions/instrumentation.js +39 -3
- package/dist/extensions/instrumentation.mjs +41 -5
- package/dist/extensions/intent.d.ts.map +1 -1
- package/dist/extensions/internal.d.ts.map +1 -1
- package/dist/extensions/logger.d.ts.map +1 -1
- package/dist/extensions/mcp-payloads.d.ts.map +1 -1
- package/dist/extensions/mcp-sdk-compat.d.ts.map +1 -1
- package/dist/extensions/posthog-events.d.ts.map +1 -1
- package/dist/extensions/posthog-events.js +6 -0
- package/dist/extensions/posthog-events.mjs +6 -0
- package/dist/extensions/posthog-mcp.d.ts.map +1 -1
- package/dist/extensions/posthog-mcp.js +2 -0
- package/dist/extensions/posthog-mcp.mjs +2 -0
- package/dist/extensions/sanitization.d.ts.map +1 -1
- package/dist/extensions/session-token.d.ts +46 -0
- package/dist/extensions/session-token.d.ts.map +1 -0
- package/dist/extensions/session-token.js +122 -0
- package/dist/extensions/session-token.mjs +76 -0
- package/dist/extensions/session.d.ts +5 -4
- package/dist/extensions/session.d.ts.map +1 -1
- package/dist/extensions/session.js +25 -33
- package/dist/extensions/session.mjs +22 -27
- package/dist/extensions/sink.d.ts.map +1 -1
- package/dist/extensions/tools.d.ts.map +1 -1
- package/dist/extensions/tracing-helpers.d.ts.map +1 -1
- 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 +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -2
- package/dist/index.mjs +2 -1
- package/dist/types.d.ts +32 -2
- 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 +3 -3
- package/src/extensions/capture.ts +11 -3
- package/src/extensions/compatibility.ts +4 -3
- package/src/extensions/constants.ts +6 -3
- package/src/extensions/context-parameters.ts +4 -3
- package/src/extensions/conversation-id.ts +4 -3
- package/src/extensions/event-types.ts +4 -3
- package/src/extensions/exceptions.ts +4 -3
- package/src/extensions/ids.ts +4 -3
- package/src/extensions/instrument-highlevel.ts +4 -3
- package/src/extensions/instrument-lowlevel.ts +4 -3
- package/src/extensions/instrumentation.ts +85 -9
- package/src/extensions/intent.ts +4 -3
- package/src/extensions/internal.ts +4 -3
- package/src/extensions/logger.ts +4 -3
- package/src/extensions/mcp-payloads.ts +4 -3
- package/src/extensions/mcp-sdk-compat.ts +4 -3
- package/src/extensions/posthog-events.ts +19 -3
- package/src/extensions/posthog-mcp.ts +2 -0
- package/src/extensions/sanitization.ts +4 -3
- package/src/extensions/session-token.ts +168 -0
- package/src/extensions/session.ts +42 -40
- package/src/extensions/sink.ts +4 -3
- package/src/extensions/tools.ts +4 -3
- package/src/extensions/tracing-helpers.ts +4 -3
- package/src/extensions/truncation.ts +5 -3
- package/src/index.ts +14 -4
- package/src/types.ts +38 -5
- package/src/version.ts +1 -1
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAKA,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,GAAG,OAAO,CAAA;CACvB;AAED,MAAM,WAAW,cAAc;IAC7B,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,oBAAoB,CAAA;IAC7B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB;AAED,4FAA4F;AAC5F,MAAM,WAAW,YAAY;IAC3B;;;;;OAKG;IACH,OAAO,CAAC,SAAS,EAAE,gBAAgB,GAA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AAC,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.9.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.9.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.9.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.9.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.
|
|
31
|
+
"@posthog/core": "^1.40.1"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@babel/preset-env": "^7.27.1",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"jest": "29.7.0",
|
|
41
41
|
"zod": "^3.25.0",
|
|
42
42
|
"@posthog-tooling/tsconfig-base": "1.1.1",
|
|
43
|
-
"posthog-node": "^5.
|
|
43
|
+
"posthog-node": "^5.40.0"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"@modelcontextprotocol/sdk": ">=1.26.0",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
// Portions of this file are derived from
|
|
2
|
-
//
|
|
3
|
-
//
|
|
1
|
+
// Portions of this file are derived from agentcathq/agentcat-typescript-sdk
|
|
2
|
+
// (formerly MCPCat/mcpcat-typescript-sdk)
|
|
3
|
+
// Copyright (c) 2025 AgentCat, Inc. (formerly MCPcat)
|
|
4
|
+
// Licensed under the MIT License: https://github.com/agentcathq/agentcat-typescript-sdk/blob/main/LICENSE
|
|
4
5
|
|
|
5
6
|
import type { MCPServerLike, McpEvent } from '../types'
|
|
6
7
|
import { MCPAnalyticsEventType } from './event-types'
|
|
@@ -61,7 +62,14 @@ export function captureEvent(server: MCPServerLike, eventInput: McpEvent): Promi
|
|
|
61
62
|
userIntent: eventInput.userIntent,
|
|
62
63
|
userIntentSource: eventInput.userIntentSource,
|
|
63
64
|
isError: eventInput.isError,
|
|
65
|
+
// Two consumers of the same failure: `error` is the full thrown value that
|
|
66
|
+
// fans out into the separate `$exception` event (stacktrace, error-tracking
|
|
67
|
+
// grouping), while `errorType` is a coarse category kept on this tool-call
|
|
68
|
+
// event so the dashboard can break failures down by reason without joining
|
|
69
|
+
// to `$exception`. The error message is derived from `error` onto this event
|
|
70
|
+
// downstream in posthog-events.ts.
|
|
64
71
|
error: eventInput.error,
|
|
72
|
+
errorType: eventInput.errorType,
|
|
65
73
|
conversationId: eventInput.conversationId,
|
|
66
74
|
properties: eventInput.properties,
|
|
67
75
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
// Portions of this file are derived from
|
|
2
|
-
//
|
|
3
|
-
//
|
|
1
|
+
// Portions of this file are derived from agentcathq/agentcat-typescript-sdk
|
|
2
|
+
// (formerly MCPCat/mcpcat-typescript-sdk)
|
|
3
|
+
// Copyright (c) 2025 AgentCat, Inc. (formerly MCPcat)
|
|
4
|
+
// Licensed under the MIT License: https://github.com/agentcathq/agentcat-typescript-sdk/blob/main/LICENSE
|
|
4
5
|
|
|
5
6
|
import type { HighLevelMCPServerLike, MCPServerLike } from '../types'
|
|
6
7
|
import { log } from './logger'
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
// Portions of this file are derived from
|
|
2
|
-
//
|
|
3
|
-
//
|
|
1
|
+
// Portions of this file are derived from agentcathq/agentcat-typescript-sdk
|
|
2
|
+
// (formerly MCPCat/mcpcat-typescript-sdk)
|
|
3
|
+
// Copyright (c) 2025 AgentCat, Inc. (formerly MCPcat)
|
|
4
|
+
// Licensed under the MIT License: https://github.com/agentcathq/agentcat-typescript-sdk/blob/main/LICENSE
|
|
4
5
|
|
|
5
6
|
export const INACTIVITY_TIMEOUT_IN_MINUTES = 30
|
|
6
7
|
|
|
@@ -40,6 +41,8 @@ export const PostHogMCPAnalyticsProperty = {
|
|
|
40
41
|
ClientVersion: '$mcp_client_version',
|
|
41
42
|
ConversationId: '$mcp_conversation_id',
|
|
42
43
|
DurationMs: '$mcp_duration_ms',
|
|
44
|
+
ErrorMessage: '$mcp_error_message',
|
|
45
|
+
ErrorType: '$mcp_error_type',
|
|
43
46
|
IsError: '$mcp_is_error',
|
|
44
47
|
Intent: '$mcp_intent',
|
|
45
48
|
IntentSource: '$mcp_intent_source',
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
// Portions of this file are derived from
|
|
2
|
-
//
|
|
3
|
-
//
|
|
1
|
+
// Portions of this file are derived from agentcathq/agentcat-typescript-sdk
|
|
2
|
+
// (formerly MCPCat/mcpcat-typescript-sdk)
|
|
3
|
+
// Copyright (c) 2025 AgentCat, Inc. (formerly MCPcat)
|
|
4
|
+
// Licensed under the MIT License: https://github.com/agentcathq/agentcat-typescript-sdk/blob/main/LICENSE
|
|
4
5
|
|
|
5
6
|
import type { MCPAnalyticsOptions } from '../types'
|
|
6
7
|
import { DEFAULT_CONTEXT_PARAMETER_DESCRIPTION } from './constants'
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
// Portions of this file are derived from
|
|
2
|
-
//
|
|
3
|
-
//
|
|
1
|
+
// Portions of this file are derived from agentcathq/agentcat-typescript-sdk
|
|
2
|
+
// (formerly MCPCat/mcpcat-typescript-sdk)
|
|
3
|
+
// Copyright (c) 2025 AgentCat, Inc. (formerly MCPcat)
|
|
4
|
+
// Licensed under the MIT License: https://github.com/agentcathq/agentcat-typescript-sdk/blob/main/LICENSE
|
|
4
5
|
|
|
5
6
|
import { uuidv7 } from '@posthog/core'
|
|
6
7
|
import { DEFAULT_CONVERSATION_ID_DESCRIPTION } from './constants'
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
// Portions of this file are derived from
|
|
2
|
-
//
|
|
3
|
-
//
|
|
1
|
+
// Portions of this file are derived from agentcathq/agentcat-typescript-sdk
|
|
2
|
+
// (formerly MCPCat/mcpcat-typescript-sdk)
|
|
3
|
+
// Copyright (c) 2025 AgentCat, Inc. (formerly MCPcat)
|
|
4
|
+
// Licensed under the MIT License: https://github.com/agentcathq/agentcat-typescript-sdk/blob/main/LICENSE
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Internal SDK event vocabulary.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
// Portions of this file are derived from
|
|
2
|
-
//
|
|
3
|
-
//
|
|
1
|
+
// Portions of this file are derived from agentcathq/agentcat-typescript-sdk
|
|
2
|
+
// (formerly MCPCat/mcpcat-typescript-sdk)
|
|
3
|
+
// Copyright (c) 2025 AgentCat, Inc. (formerly MCPcat)
|
|
4
|
+
// Licensed under the MIT License: https://github.com/agentcathq/agentcat-typescript-sdk/blob/main/LICENSE
|
|
4
5
|
|
|
5
6
|
import { ErrorTracking as CoreErrorTracking } from '@posthog/core'
|
|
6
7
|
|
package/src/extensions/ids.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
// Portions of this file are derived from
|
|
2
|
-
//
|
|
3
|
-
//
|
|
1
|
+
// Portions of this file are derived from agentcathq/agentcat-typescript-sdk
|
|
2
|
+
// (formerly MCPCat/mcpcat-typescript-sdk)
|
|
3
|
+
// Copyright (c) 2025 AgentCat, Inc. (formerly MCPcat)
|
|
4
|
+
// Licensed under the MIT License: https://github.com/agentcathq/agentcat-typescript-sdk/blob/main/LICENSE
|
|
4
5
|
|
|
5
6
|
import { uuidv7 } from '@posthog/core'
|
|
6
7
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
// Portions of this file are derived from
|
|
2
|
-
//
|
|
3
|
-
//
|
|
1
|
+
// Portions of this file are derived from agentcathq/agentcat-typescript-sdk
|
|
2
|
+
// (formerly MCPCat/mcpcat-typescript-sdk)
|
|
3
|
+
// Copyright (c) 2025 AgentCat, Inc. (formerly MCPcat)
|
|
4
|
+
// Licensed under the MIT License: https://github.com/agentcathq/agentcat-typescript-sdk/blob/main/LICENSE
|
|
4
5
|
|
|
5
6
|
import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js'
|
|
6
7
|
import type { CompatibleRequestHandlerExtra, HighLevelMCPServerLike, MCPServerLike, RegisteredTool } from '../types'
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
// Portions of this file are derived from
|
|
2
|
-
//
|
|
3
|
-
//
|
|
1
|
+
// Portions of this file are derived from agentcathq/agentcat-typescript-sdk
|
|
2
|
+
// (formerly MCPCat/mcpcat-typescript-sdk)
|
|
3
|
+
// Copyright (c) 2025 AgentCat, Inc. (formerly MCPcat)
|
|
4
|
+
// Licensed under the MIT License: https://github.com/agentcathq/agentcat-typescript-sdk/blob/main/LICENSE
|
|
4
5
|
|
|
5
6
|
import { CallToolRequestSchema } from '@modelcontextprotocol/sdk/types.js'
|
|
6
7
|
import type { CompatibleRequestHandlerExtra, MCPRequestLike, MCPServerLike } from '../types'
|
|
@@ -1,9 +1,17 @@
|
|
|
1
|
-
// Portions of this file are derived from
|
|
2
|
-
//
|
|
3
|
-
//
|
|
1
|
+
// Portions of this file are derived from agentcathq/agentcat-typescript-sdk
|
|
2
|
+
// (formerly MCPCat/mcpcat-typescript-sdk)
|
|
3
|
+
// Copyright (c) 2025 AgentCat, Inc. (formerly MCPcat)
|
|
4
|
+
// Licensed under the MIT License: https://github.com/agentcathq/agentcat-typescript-sdk/blob/main/LICENSE
|
|
4
5
|
|
|
5
6
|
import type { ListToolsResult } from '@modelcontextprotocol/sdk/types.js'
|
|
6
|
-
import type {
|
|
7
|
+
import type {
|
|
8
|
+
CompatibleRequestHandlerExtra,
|
|
9
|
+
MCPAnalyticsData,
|
|
10
|
+
MCPRequestLike,
|
|
11
|
+
MCPServerLike,
|
|
12
|
+
McpEvent,
|
|
13
|
+
ServerClientInfoLike,
|
|
14
|
+
} from '../types'
|
|
7
15
|
import { addContextParameterToTools, getContextDescription, isContextEnabled } from './context-parameters'
|
|
8
16
|
import {
|
|
9
17
|
addConversationIdToTools,
|
|
@@ -17,11 +25,12 @@ import { captureEvent } from './capture'
|
|
|
17
25
|
import { MCPAnalyticsEventType } from './event-types'
|
|
18
26
|
import { captureException } from './exceptions'
|
|
19
27
|
import { resolveToolCallIntent, setEventIntent, setExplicitContextIntent } from './intent'
|
|
20
|
-
import { getServerTrackingData, handleIdentify } from './internal'
|
|
28
|
+
import { getServerTrackingData, handleIdentify, setServerTrackingData } from './internal'
|
|
21
29
|
import { log } from './logger'
|
|
22
30
|
import { buildCapturedMcpParameters } from './mcp-payloads'
|
|
23
31
|
import { getLiteralValue, getObjectShape } from './mcp-sdk-compat'
|
|
24
|
-
import {
|
|
32
|
+
import { getSessionId, newSessionId } from './session'
|
|
33
|
+
import { encodeSessionId, readMcpSessionHeader, writeSessionIdToTransport } from './session-token'
|
|
25
34
|
import { getReportMissingToolDescriptor, resolveMissingCapabilityToolName } from './tools'
|
|
26
35
|
import { applyResolvedMetadata, isToolResultError } from './tracing-helpers'
|
|
27
36
|
|
|
@@ -129,7 +138,7 @@ async function prepareToolCallEvent(
|
|
|
129
138
|
eventType: MCPAnalyticsEventType
|
|
130
139
|
): Promise<McpEvent | null> {
|
|
131
140
|
try {
|
|
132
|
-
const sessionId =
|
|
141
|
+
const sessionId = getSessionId(server, extra)
|
|
133
142
|
await handleIdentify(server, data, sessionId, request, extra)
|
|
134
143
|
|
|
135
144
|
const toolName = request.params?.name
|
|
@@ -283,7 +292,7 @@ export async function handleListToolsRequest(
|
|
|
283
292
|
const data = getServerTrackingData(server)
|
|
284
293
|
const startTime = new Date()
|
|
285
294
|
const event: McpEvent = {
|
|
286
|
-
sessionId:
|
|
295
|
+
sessionId: getSessionId(server, extra),
|
|
287
296
|
parameters: buildCapturedMcpParameters(request),
|
|
288
297
|
eventType: MCPAnalyticsEventType.mcpToolsList,
|
|
289
298
|
timestamp: startTime,
|
|
@@ -410,6 +419,71 @@ export function cacheToolCategories(cache: Map<string, string>, tools: ListTools
|
|
|
410
419
|
|
|
411
420
|
// --- initialize -----------------------------------------------------------
|
|
412
421
|
|
|
422
|
+
/**
|
|
423
|
+
* Stateless servers never issue a session id, so sessions fragment and the
|
|
424
|
+
* client name/version is lost after `initialize`. Fix: mint the
|
|
425
|
+
* `Mcp-Session-Id` response header as a token carrying both. Clients replay
|
|
426
|
+
* the header on every request, so any pod recovers them with no server-side
|
|
427
|
+
* store (decoded in `getSessionId`).
|
|
428
|
+
*
|
|
429
|
+
* The header only reaches the wire when response headers are built after the
|
|
430
|
+
* handler runs — StreamableHTTP with `enableJsonResponse: true`. SSE flushes
|
|
431
|
+
* headers first; those servers set the header themselves with the exported
|
|
432
|
+
* `encodeSessionId`, and this mint is a harmless no-op.
|
|
433
|
+
*/
|
|
434
|
+
function mintStatelessSessionOnInitialize(
|
|
435
|
+
server: MCPServerLike,
|
|
436
|
+
data: MCPAnalyticsData,
|
|
437
|
+
request: MCPRequestLike,
|
|
438
|
+
extra: CompatibleRequestHandlerExtra | undefined
|
|
439
|
+
): void {
|
|
440
|
+
try {
|
|
441
|
+
const headers = extra?.requestInfo?.headers
|
|
442
|
+
if (!headers || typeof headers !== 'object') {
|
|
443
|
+
return // not an HTTP transport (stdio/in-memory) — nothing to mint into
|
|
444
|
+
}
|
|
445
|
+
if (readMcpSessionHeader(headers)) {
|
|
446
|
+
return // client already replays a session id (ours or the transport's)
|
|
447
|
+
}
|
|
448
|
+
const transport = server.transport
|
|
449
|
+
if (!transport || extra?.sessionId || transport.sessionId) {
|
|
450
|
+
return // stateful transports manage their own session id — leave it alone
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
const sessionId = newSessionId()
|
|
454
|
+
const clientInfo = readInitializeClientInfo(request)
|
|
455
|
+
const token = encodeSessionId({ sessionId, clientName: clientInfo?.name, clientVersion: clientInfo?.version })
|
|
456
|
+
if (!writeSessionIdToTransport(transport, token)) {
|
|
457
|
+
return // transport can't carry a response session id — keep generated behavior
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
data.sessionId = sessionId
|
|
461
|
+
data.sessionSource = 'token'
|
|
462
|
+
data.sessionInfo.clientName = clientInfo?.name
|
|
463
|
+
data.sessionInfo.clientVersion = clientInfo?.version
|
|
464
|
+
data.lastActivity = new Date()
|
|
465
|
+
setServerTrackingData(server, data)
|
|
466
|
+
} catch (error) {
|
|
467
|
+
log(`Warning: PostHog MCP analytics failed to mint a stateless session id - ${error}`)
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* Read the client name/version off the `initialize` request body — the SDK
|
|
473
|
+
* hasn't stored it yet (`getClientVersion()`) when our patch runs.
|
|
474
|
+
*/
|
|
475
|
+
function readInitializeClientInfo(request: MCPRequestLike): ServerClientInfoLike | undefined {
|
|
476
|
+
const clientInfo = request.params?.clientInfo
|
|
477
|
+
if (!clientInfo || typeof clientInfo !== 'object') {
|
|
478
|
+
return undefined
|
|
479
|
+
}
|
|
480
|
+
const { name, version } = clientInfo as Record<string, unknown>
|
|
481
|
+
return {
|
|
482
|
+
name: typeof name === 'string' ? name : undefined,
|
|
483
|
+
version: typeof version === 'string' ? version : undefined,
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
|
|
413
487
|
/**
|
|
414
488
|
* Captures the connection handshake (and resolves identity) on `initialize`
|
|
415
489
|
* before the original handler runs.
|
|
@@ -428,7 +502,9 @@ export async function handleInitializeRequest(
|
|
|
428
502
|
return await originalInitializeHandler(request, extra)
|
|
429
503
|
}
|
|
430
504
|
|
|
431
|
-
|
|
505
|
+
// Mint first so the `$mcp_initialize` event below already carries the minted id.
|
|
506
|
+
mintStatelessSessionOnInitialize(server, data, request, extra)
|
|
507
|
+
const sessionId = getSessionId(server, extra)
|
|
432
508
|
await handleIdentify(server, data, sessionId, request, extra)
|
|
433
509
|
|
|
434
510
|
const event: McpEvent = {
|
package/src/extensions/intent.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
// Portions of this file are derived from
|
|
2
|
-
//
|
|
3
|
-
//
|
|
1
|
+
// Portions of this file are derived from agentcathq/agentcat-typescript-sdk
|
|
2
|
+
// (formerly MCPCat/mcpcat-typescript-sdk)
|
|
3
|
+
// Copyright (c) 2025 AgentCat, Inc. (formerly MCPcat)
|
|
4
|
+
// Licensed under the MIT License: https://github.com/agentcathq/agentcat-typescript-sdk/blob/main/LICENSE
|
|
4
5
|
|
|
5
6
|
import type {
|
|
6
7
|
CompatibleRequestHandlerExtra,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
// Portions of this file are derived from
|
|
2
|
-
//
|
|
3
|
-
//
|
|
1
|
+
// Portions of this file are derived from agentcathq/agentcat-typescript-sdk
|
|
2
|
+
// (formerly MCPCat/mcpcat-typescript-sdk)
|
|
3
|
+
// Copyright (c) 2025 AgentCat, Inc. (formerly MCPcat)
|
|
4
|
+
// Licensed under the MIT License: https://github.com/agentcathq/agentcat-typescript-sdk/blob/main/LICENSE
|
|
4
5
|
|
|
5
6
|
import type {
|
|
6
7
|
CompatibleRequestHandlerExtra,
|
package/src/extensions/logger.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
// Portions of this file are derived from
|
|
2
|
-
//
|
|
3
|
-
//
|
|
1
|
+
// Portions of this file are derived from agentcathq/agentcat-typescript-sdk
|
|
2
|
+
// (formerly MCPCat/mcpcat-typescript-sdk)
|
|
3
|
+
// Copyright (c) 2025 AgentCat, Inc. (formerly MCPcat)
|
|
4
|
+
// Licensed under the MIT License: https://github.com/agentcathq/agentcat-typescript-sdk/blob/main/LICENSE
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* STDIO-safe logger.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
// Portions of this file are derived from
|
|
2
|
-
//
|
|
3
|
-
//
|
|
1
|
+
// Portions of this file are derived from agentcathq/agentcat-typescript-sdk
|
|
2
|
+
// (formerly MCPCat/mcpcat-typescript-sdk)
|
|
3
|
+
// Copyright (c) 2025 AgentCat, Inc. (formerly MCPcat)
|
|
4
|
+
// Licensed under the MIT License: https://github.com/agentcathq/agentcat-typescript-sdk/blob/main/LICENSE
|
|
4
5
|
|
|
5
6
|
const CONTEXT_ARGUMENT_NAME = 'context'
|
|
6
7
|
const REDACTED_VALUE = '[redacted]'
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
// Portions of this file are derived from
|
|
2
|
-
//
|
|
3
|
-
//
|
|
1
|
+
// Portions of this file are derived from agentcathq/agentcat-typescript-sdk
|
|
2
|
+
// (formerly MCPCat/mcpcat-typescript-sdk)
|
|
3
|
+
// Copyright (c) 2025 AgentCat, Inc. (formerly MCPcat)
|
|
4
|
+
// Licensed under the MIT License: https://github.com/agentcathq/agentcat-typescript-sdk/blob/main/LICENSE
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* MCP SDK Compatibility Helpers
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
// Portions of this file are derived from
|
|
2
|
-
//
|
|
3
|
-
//
|
|
1
|
+
// Portions of this file are derived from agentcathq/agentcat-typescript-sdk
|
|
2
|
+
// (formerly MCPCat/mcpcat-typescript-sdk)
|
|
3
|
+
// Copyright (c) 2025 AgentCat, Inc. (formerly MCPcat)
|
|
4
|
+
// Licensed under the MIT License: https://github.com/agentcathq/agentcat-typescript-sdk/blob/main/LICENSE
|
|
4
5
|
|
|
5
6
|
import type { Event } from '../types'
|
|
6
7
|
import { POSTHOG_MCP_ANALYTICS_SOURCE, PostHogMCPAnalyticsEvent, PostHogMCPAnalyticsProperty } from './constants'
|
|
@@ -160,6 +161,21 @@ function addCommonEventProperties(event: Event, properties: Record<string, unkno
|
|
|
160
161
|
properties[PostHogMCPAnalyticsProperty.IsError] = event.isError
|
|
161
162
|
}
|
|
162
163
|
|
|
164
|
+
if (event.isError) {
|
|
165
|
+
// Surface the failure reason directly on the primary event so the dashboard
|
|
166
|
+
// can break errors down by cause without joining to the `$exception` sibling
|
|
167
|
+
// (which can be disabled, and isn't emitted when no error value is passed).
|
|
168
|
+
const firstException = event.error?.$exception_list?.[0]
|
|
169
|
+
const errorType = event.errorType ?? firstException?.type
|
|
170
|
+
if (errorType) {
|
|
171
|
+
properties[PostHogMCPAnalyticsProperty.ErrorType] = errorType
|
|
172
|
+
}
|
|
173
|
+
if (firstException?.value) {
|
|
174
|
+
// Already bounded to MAX_ERROR_MESSAGE_LENGTH by `truncateExceptionList`.
|
|
175
|
+
properties[PostHogMCPAnalyticsProperty.ErrorMessage] = firstException.value
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
163
179
|
if (event.parameters !== undefined) {
|
|
164
180
|
properties[PostHogMCPAnalyticsProperty.Parameters] = event.parameters
|
|
165
181
|
}
|
|
@@ -99,6 +99,7 @@ export class PostHogMCP extends PostHog {
|
|
|
99
99
|
event.response = data.response
|
|
100
100
|
event.duration = data.durationMs
|
|
101
101
|
event.isError = data.isError
|
|
102
|
+
event.errorType = data.errorType
|
|
102
103
|
applyIntent(event, data.intent, data.intentSource)
|
|
103
104
|
if (data.isError) {
|
|
104
105
|
event.error = captureException(data.error ?? `Tool ${data.toolName} returned an error`)
|
|
@@ -130,6 +131,7 @@ export class PostHogMCP extends PostHog {
|
|
|
130
131
|
event.response = data.response
|
|
131
132
|
event.duration = data.durationMs
|
|
132
133
|
event.isError = data.isError
|
|
134
|
+
event.errorType = data.errorType
|
|
133
135
|
if (data.isError) {
|
|
134
136
|
event.error = captureException(data.error ?? 'tools/list failed')
|
|
135
137
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
// Portions of this file are derived from
|
|
2
|
-
//
|
|
3
|
-
//
|
|
1
|
+
// Portions of this file are derived from agentcathq/agentcat-typescript-sdk
|
|
2
|
+
// (formerly MCPCat/mcpcat-typescript-sdk)
|
|
3
|
+
// Copyright (c) 2025 AgentCat, Inc. (formerly MCPcat)
|
|
4
|
+
// Licensed under the MIT License: https://github.com/agentcathq/agentcat-typescript-sdk/blob/main/LICENSE
|
|
4
5
|
|
|
5
6
|
import type { Event, McpEvent } from '../types'
|
|
6
7
|
import { sanitizeCapturedValue } from './mcp-payloads'
|