@posthog/mcp 0.11.5 → 0.11.6

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.
@@ -1 +1 @@
1
- {"version":3,"file":"instrumentation.d.ts","sourceRoot":"","sources":["../../src/extensions/instrumentation.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,2BAA2B,EAC3B,6BAA6B,EAC7B,uBAAuB,EACvB,gBAAgB,EAChB,cAAc,EACd,aAAa,EAId,MAAM,UAAU,CAAA;AAcjB,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AAIrD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AASxC;;;;;;GAMG;AAEH,KAAK,iBAAiB,GAAG,CAAC,OAAO,EAAE,cAAc,EAAE,KAAK,CAAC,EAAE,6BAA6B,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;AAE7G,2EAA2E;AAC3E,KAAK,YAAY,GAAG,CAAC,iBAAiB,EAAE,cAAc,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;AAE3E,UAAU,mBAAmB;IAC3B,MAAM,EAAE,aAAa,CAAA;IACrB,IAAI,EAAE,gBAAgB,CAAA;IACtB,OAAO,EAAE,cAAc,CAAA;IACvB,KAAK,CAAC,EAAE,6BAA6B,CAAA;IACrC,OAAO,EAAE,YAAY,CAAA;IACrB,2FAA2F;IAC3F,kBAAkB,CAAC,EAAE,2BAA2B,CAAA;IAChD;;;;OAIG;IACH,SAAS,CAAC,EAAE,qBAAqB,CAAA;IACjC;;;;OAIG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,MAAM,OAAO,CAAA;CAClC;AAED;;;;;;;GAOG;AACH,wBAAsB,eAAe,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC,CA8DnF;AAiOD;;;;GAIG;AACH,MAAM,MAAM,YAAY,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AAI,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAGtE;AAED,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAC1B,KAAK,EAAE,uBAAuB,CAAC,OAAO,CAAC,GAAG,SAAS,GAClD,IAAI,CAUN;AAuHD;;;GAGG;AACH,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE,aAAa,EACrB,yBAAyB,EAAE,iBAAiB,EAC5C,OAAO,EAAE,cAAc,EACvB,KAAK,EAAE,6BAA6B,GAAG,SAAS,EAChD,MAAM,EAAE,QAAQ,GACf,OAAO,CAAC,OAAO,CAAC,CA2ElB"}
@@ -99,8 +99,6 @@ async function prepareToolCallEvent(server, data, request, downstreamRequest, ex
99
99
  try {
100
100
  const sessionId = (0, external_session_js_namespaceObject.getSessionId)(server, extra, conversation.conversationId);
101
101
  const sessionInfo = (0, external_session_js_namespaceObject.getSessionInfo)(server, data, sessionId);
102
- const identity = await (0, external_internal_js_namespaceObject.handleIdentify)(server, data, sessionId, request, sessionInfo, extra, !!conversation.conversationId);
103
- const requestAttribution = (0, external_internal_js_namespaceObject.withIdentity)(sessionInfo, identity);
104
102
  const toolName = request.params?.name;
105
103
  const event = {
106
104
  sessionId,
@@ -114,6 +112,8 @@ async function prepareToolCallEvent(server, data, request, downstreamRequest, ex
114
112
  };
115
113
  (0, external_client_identity_js_namespaceObject.stampClientIdentity)(event, request, extra, server);
116
114
  (0, external_transport_identity_js_namespaceObject.stampTransportIdentity)(event, extra);
115
+ const identity = await (0, external_internal_js_namespaceObject.handleIdentify)(server, data, sessionId, request, sessionInfo, extra, !!conversation.conversationId);
116
+ const requestAttribution = (0, external_internal_js_namespaceObject.withIdentity)(sessionInfo, identity);
117
117
  await (0, external_tracing_helpers_js_namespaceObject.applyResolvedMetadata)(event, data, request, extra);
118
118
  (0, external_intent_js_namespaceObject.setEventIntent)(event, await (0, external_intent_js_namespaceObject.resolveToolCallIntent)(data, request, canCaptureContextIntent, extra));
119
119
  return {
@@ -395,8 +395,6 @@ async function handleInitializeRequest(server, originalInitializeHandler, reques
395
395
  clientName: initializeClientInfo?.name ?? sessionInfo.clientName,
396
396
  clientVersion: initializeClientInfo?.version ?? sessionInfo.clientVersion
397
397
  };
398
- const identity = await (0, external_internal_js_namespaceObject.handleIdentify)(server, data, sessionId, request, requestSessionInfo, extra);
399
- const requestAttribution = (0, external_internal_js_namespaceObject.withIdentity)(requestSessionInfo, identity);
400
398
  const event = {
401
399
  sessionId,
402
400
  resourceName: request.params?.name || 'Unknown Tool Name',
@@ -405,7 +403,11 @@ async function handleInitializeRequest(server, originalInitializeHandler, reques
405
403
  timestamp: new Date()
406
404
  };
407
405
  (0, external_client_identity_js_namespaceObject.stampClientIdentity)(event, request, extra, server);
406
+ if (initializeClientInfo?.name) event.clientName = initializeClientInfo.name;
407
+ if (initializeClientInfo?.version) event.clientVersion = initializeClientInfo.version;
408
408
  (0, external_transport_identity_js_namespaceObject.stampTransportIdentity)(event, extra);
409
+ const identity = await (0, external_internal_js_namespaceObject.handleIdentify)(server, data, sessionId, request, requestSessionInfo, extra);
410
+ const requestAttribution = (0, external_internal_js_namespaceObject.withIdentity)(requestSessionInfo, identity);
409
411
  await (0, external_tracing_helpers_js_namespaceObject.applyResolvedMetadata)(event, data, request, extra);
410
412
  const result = await originalInitializeHandler(request, extra);
411
413
  event.response = result;
@@ -63,8 +63,6 @@ async function prepareToolCallEvent(server, data, request, downstreamRequest, ex
63
63
  try {
64
64
  const sessionId = getSessionId(server, extra, conversation.conversationId);
65
65
  const sessionInfo = getSessionInfo(server, data, sessionId);
66
- const identity = await handleIdentify(server, data, sessionId, request, sessionInfo, extra, !!conversation.conversationId);
67
- const requestAttribution = withIdentity(sessionInfo, identity);
68
66
  const toolName = request.params?.name;
69
67
  const event = {
70
68
  sessionId,
@@ -78,6 +76,8 @@ async function prepareToolCallEvent(server, data, request, downstreamRequest, ex
78
76
  };
79
77
  stampClientIdentity(event, request, extra, server);
80
78
  stampTransportIdentity(event, extra);
79
+ const identity = await handleIdentify(server, data, sessionId, request, sessionInfo, extra, !!conversation.conversationId);
80
+ const requestAttribution = withIdentity(sessionInfo, identity);
81
81
  await applyResolvedMetadata(event, data, request, extra);
82
82
  setEventIntent(event, await resolveToolCallIntent(data, request, canCaptureContextIntent, extra));
83
83
  return {
@@ -359,8 +359,6 @@ async function handleInitializeRequest(server, originalInitializeHandler, reques
359
359
  clientName: initializeClientInfo?.name ?? sessionInfo.clientName,
360
360
  clientVersion: initializeClientInfo?.version ?? sessionInfo.clientVersion
361
361
  };
362
- const identity = await handleIdentify(server, data, sessionId, request, requestSessionInfo, extra);
363
- const requestAttribution = withIdentity(requestSessionInfo, identity);
364
362
  const event = {
365
363
  sessionId,
366
364
  resourceName: request.params?.name || 'Unknown Tool Name',
@@ -369,7 +367,11 @@ async function handleInitializeRequest(server, originalInitializeHandler, reques
369
367
  timestamp: new Date()
370
368
  };
371
369
  stampClientIdentity(event, request, extra, server);
370
+ if (initializeClientInfo?.name) event.clientName = initializeClientInfo.name;
371
+ if (initializeClientInfo?.version) event.clientVersion = initializeClientInfo.version;
372
372
  stampTransportIdentity(event, extra);
373
+ const identity = await handleIdentify(server, data, sessionId, request, requestSessionInfo, extra);
374
+ const requestAttribution = withIdentity(requestSessionInfo, identity);
373
375
  await applyResolvedMetadata(event, data, request, extra);
374
376
  const result = await originalInitializeHandler(request, extra);
375
377
  event.response = result;
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const version = "0.11.5";
1
+ export declare const version = "0.11.6";
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.11.5';
29
+ const version = '0.11.6';
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.11.5';
1
+ const version = '0.11.6';
2
2
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@posthog/mcp",
3
- "version": "0.11.5",
3
+ "version": "0.11.6",
4
4
  "bugs": {
5
5
  "url": "https://github.com/PostHog/posthog-js/issues"
6
6
  },
@@ -225,16 +225,6 @@ async function prepareToolCallEvent(
225
225
  // Snapshot token/client/protocol metadata synchronously, before identify or
226
226
  // metadata callbacks can yield and let another request replace shared state.
227
227
  const sessionInfo = getSessionInfo(server, data, sessionId)
228
- const identity = await handleIdentify(
229
- server,
230
- data,
231
- sessionId,
232
- request,
233
- sessionInfo,
234
- extra,
235
- !!conversation.conversationId
236
- )
237
- const requestAttribution = withIdentity(sessionInfo, identity)
238
228
 
239
229
  const toolName = request.params?.name
240
230
  const event: McpEvent = {
@@ -249,12 +239,28 @@ async function prepareToolCallEvent(
249
239
  }
250
240
  // Modern (stateless) clients carry client name/version + protocol version in
251
241
  // `_meta` on every request rather than at `initialize`; stamp them onto this
252
- // event now so concurrent requests can't cross-attribute it.
242
+ // event now so concurrent requests can't cross-attribute it. Stamped before
243
+ // the identify await below for the same reason the snapshot is: the chain's
244
+ // last link is the server's own `getClientVersion()`, which a concurrent
245
+ // `initialize` can replace while an identify callback is in flight — and
246
+ // `captureEvent` prefers a stamped value over `sessionInfo`, so a late stamp
247
+ // would win with the wrong client's name.
253
248
  stampClientIdentity(event, request, extra, server)
254
249
  // Which *surface* of the client made this call lives only in the request
255
250
  // headers (HTTP transports); `clientInfo` can't tell a vendor's products apart.
256
251
  stampTransportIdentity(event, extra)
257
252
 
253
+ const identity = await handleIdentify(
254
+ server,
255
+ data,
256
+ sessionId,
257
+ request,
258
+ sessionInfo,
259
+ extra,
260
+ !!conversation.conversationId
261
+ )
262
+ const requestAttribution = withIdentity(sessionInfo, identity)
263
+
258
264
  await applyResolvedMetadata(event, data, request, extra)
259
265
  setEventIntent(event, await resolveToolCallIntent(data, request, canCaptureContextIntent, extra))
260
266
  return { event, requestAttribution }
@@ -870,9 +876,6 @@ export async function handleInitializeRequest(
870
876
  clientName: initializeClientInfo?.name ?? sessionInfo.clientName,
871
877
  clientVersion: initializeClientInfo?.version ?? sessionInfo.clientVersion,
872
878
  }
873
- const identity = await handleIdentify(server, data, sessionId, request, requestSessionInfo, extra)
874
- const requestAttribution = withIdentity(requestSessionInfo, identity)
875
-
876
879
  const event: McpEvent = {
877
880
  sessionId,
878
881
  resourceName: request.params?.name || 'Unknown Tool Name',
@@ -880,12 +883,30 @@ export async function handleInitializeRequest(
880
883
  parameters: buildCapturedMcpParameters(request),
881
884
  timestamp: new Date(),
882
885
  }
883
- // Harmless for a legacy `initialize` (client info rides the body there, and the
884
- // negotiated protocol version below overrides any `_meta` one); picks up client
885
- // info if a client also sends it in `_meta`.
886
+ // Picks up client info if a client also sends it in `_meta` (the negotiated
887
+ // protocol version below overrides any `_meta` one). Stamped before the
888
+ // identify await for the same reason the snapshot is taken there: the chain's
889
+ // last link is the server's own `getClientVersion()`, which a concurrent
890
+ // `initialize` can replace while an identify callback is in flight.
886
891
  stampClientIdentity(event, request, extra, server)
892
+ // A legacy `initialize` carries its client in the request body, which is the
893
+ // one place the chain does not read. That body is this request's own answer,
894
+ // so it outranks the accessor — which on a server that already handshaked
895
+ // still names the *previous* client, because the SDK only records this one
896
+ // when its handler runs further below. Without this, the second and every
897
+ // later handshake on a shared instance reports the first client's name, since
898
+ // `captureEvent` prefers a stamped value over `requestSessionInfo`.
899
+ if (initializeClientInfo?.name) {
900
+ event.clientName = initializeClientInfo.name
901
+ }
902
+ if (initializeClientInfo?.version) {
903
+ event.clientVersion = initializeClientInfo.version
904
+ }
887
905
  stampTransportIdentity(event, extra)
888
906
 
907
+ const identity = await handleIdentify(server, data, sessionId, request, requestSessionInfo, extra)
908
+ const requestAttribution = withIdentity(requestSessionInfo, identity)
909
+
889
910
  await applyResolvedMetadata(event, data, request, extra)
890
911
 
891
912
  const result = await originalInitializeHandler(request, extra)
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '0.11.5'
1
+ export const version = '0.11.6'