@posthog/mcp 0.16.1 → 0.16.3

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/README.md CHANGED
@@ -282,6 +282,22 @@ when `tools/list` and `tools/call` reach different server replicas.
282
282
  both advertises both tools. Like `get_more_tools`, a real tool that already uses the configured name
283
283
  wins: the SDK warns, skips injection, and delegates calls to the real handler.
284
284
 
285
+ On a paginated catalogue (a `tools/list` response with a `nextCursor`), `instrument()` injects
286
+ its virtual tools (`send_feedback` and `get_more_tools`) on the first page only — the page every
287
+ client reads, including clients that never follow `nextCursor` — so a compliant client's
288
+ concatenated list carries each once. "First page" means a `tools/list` request with no cursor; an
289
+ empty string is a valid cursor, so `cursor: ""` is a continuation page. Hosts using
290
+ `prepareToolList()` directly own this rule themselves: pass `reportMissing: true` and
291
+ `collectFeedback: true` only for the first page.
292
+
293
+ Name collisions are detected on the first page only. A real tool named `send_feedback` (or
294
+ `get_more_tools`) on the first page wins: the SDK warns, skips injection, and forwards its calls. A
295
+ real tool that only appears on a **later** page is not detected up front — the SDK's virtual tool is
296
+ injected and intercepts calls to the name, so the real tool is shadowed and a concatenated listing
297
+ carries the name twice. The SDK logs a warning when a client fetches the colliding page, but the fix
298
+ is yours: rename the SDK's tools with `collectFeedback: { toolName: "..." }` and the
299
+ `missingCapabilityToolName` option.
300
+
285
301
  ### If you switched to `instrument(server.server)`
286
302
 
287
303
  Before v2 support landed, the compatibility gate rejected high-level v2 servers, and the usual
@@ -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,UAAU,EACV,gBAAgB,EAChB,cAAc,EACd,aAAa,EAId,MAAM,UAAU,CAAA;AAqBjB,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AAIrD,OAAO,KAAK,E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,aAAa,EACrB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,6BAA6B,GAAG,SAAS,EAChD,MAAM,EAAE,QAAQ,GACf,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC,CAoB9B;AAED;;;GAGG;AACH,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,aAAa,EACrB,wBAAwB,EAAE,iBAAiB,EAC3C,OAAO,EAAE,cAAc,EACvB,KAAK,EAAE,6BAA6B,GAAG,SAAS,EAChD,MAAM,EAAE,QAAQ,GACf,OAAO,CAAC,uBAAuB,CAAC,CAmElC;AAoID,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAC1B,KAAK,EAAE,uBAAuB,CAAC,OAAO,CAAC,GAAG,SAAS,GAClD,IAAI,CASN;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,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"}
@@ -372,30 +372,31 @@ async function getTracedToolsList(server, originalListToolsHandler, request, ext
372
372
  if (data) cacheToolAnalyticsParameterOwnership(data.toolAnalyticsParameterOwnership, tools);
373
373
  if (data && (0, external_context_parameters_js_namespaceObject.isContextEnabled)(data.options.context)) tools = (0, external_context_parameters_js_namespaceObject.addContextParameterToTools)(tools, (0, external_context_parameters_js_namespaceObject.getContextDescription)(data.options.context), data.logger);
374
374
  if (data) {
375
+ const isFirstPage = request.params?.cursor == null;
375
376
  const missingToolName = (0, external_tools_js_namespaceObject.resolveMissingCapabilityToolName)(data.options);
376
377
  if (data.options.reportMissing) {
377
378
  const alreadyPresent = tools.some((tool)=>tool?.name === missingToolName);
378
- if (alreadyPresent) data.logger(`Warning: Cannot inject missing-capability tool "${missingToolName}" because a real tool already uses that name. The real tool will not be intercepted.`);
379
- else {
379
+ if (isFirstPage && alreadyPresent) data.logger(`Warning: Cannot inject missing-capability tool "${missingToolName}" because a real tool already uses that name. The real tool will not be intercepted. To keep missing-capability reports, rename the SDK's tool with the missingCapabilityToolName option.`);
380
+ else if (isFirstPage) {
380
381
  const virtualTool = (0, external_tools_js_namespaceObject.getReportMissingToolDescriptor)(missingToolName);
381
382
  tools.push(virtualTool);
382
383
  cacheToolAnalyticsParameterOwnership(data.toolAnalyticsParameterOwnership, [
383
384
  virtualTool
384
385
  ]);
385
- }
386
+ } else if (alreadyPresent) data.logger(`Warning: A real tool "${missingToolName}" on a later tools/list page is shadowed by the SDK's missing-capability tool. Its calls will be intercepted. Rename the SDK's tool with the missingCapabilityToolName option to keep both.`);
386
387
  }
387
388
  const feedbackOptions = (0, external_feedback_js_namespaceObject.resolveCollectFeedbackOptions)(data.options.collectFeedback);
388
389
  if (feedbackOptions) {
389
390
  const feedbackToolName = feedbackOptions.toolName ?? external_feedback_js_namespaceObject.SEND_FEEDBACK_TOOL_NAME;
390
391
  const alreadyPresent = tools.some((tool)=>tool?.name === feedbackToolName);
391
- if (alreadyPresent) data.logger(`Warning: Cannot inject agent-feedback tool "${feedbackToolName}" because a real tool already uses that name. The real tool will not be intercepted.`);
392
- else {
392
+ if (isFirstPage && alreadyPresent) data.logger(`Warning: Cannot inject agent-feedback tool "${feedbackToolName}" because a real tool already uses that name. The real tool will not be intercepted. To collect feedback alongside it, rename the SDK's tool with collectFeedback: { toolName: "..." }.`);
393
+ else if (isFirstPage) {
393
394
  const virtualTool = (0, external_feedback_js_namespaceObject.getFeedbackToolDescriptor)(feedbackOptions);
394
395
  tools.push(virtualTool);
395
396
  cacheToolAnalyticsParameterOwnership(data.toolAnalyticsParameterOwnership, [
396
397
  virtualTool
397
398
  ]);
398
- }
399
+ } else if (alreadyPresent) data.logger(`Warning: A real tool "${feedbackToolName}" on a later tools/list page is shadowed by the SDK's agent-feedback tool. Its calls will be intercepted. Rename the SDK's tool with collectFeedback: { toolName: "..." } to keep both.`);
399
400
  }
400
401
  if ((0, external_model_parameters_js_namespaceObject.isCaptureModelEnabled)(data.options.captureModel)) tools = (0, external_model_parameters_js_namespaceObject.addModelParameterToTools)(tools, (0, external_model_parameters_js_namespaceObject.getModelDescription)(data.options.captureModel), data.logger);
401
402
  if (data.options.enableConversationId) {
@@ -330,30 +330,31 @@ async function getTracedToolsList(server, originalListToolsHandler, request, ext
330
330
  if (data) cacheToolAnalyticsParameterOwnership(data.toolAnalyticsParameterOwnership, tools);
331
331
  if (data && isContextEnabled(data.options.context)) tools = addContextParameterToTools(tools, getContextDescription(data.options.context), data.logger);
332
332
  if (data) {
333
+ const isFirstPage = request.params?.cursor == null;
333
334
  const missingToolName = resolveMissingCapabilityToolName(data.options);
334
335
  if (data.options.reportMissing) {
335
336
  const alreadyPresent = tools.some((tool)=>tool?.name === missingToolName);
336
- if (alreadyPresent) data.logger(`Warning: Cannot inject missing-capability tool "${missingToolName}" because a real tool already uses that name. The real tool will not be intercepted.`);
337
- else {
337
+ if (isFirstPage && alreadyPresent) data.logger(`Warning: Cannot inject missing-capability tool "${missingToolName}" because a real tool already uses that name. The real tool will not be intercepted. To keep missing-capability reports, rename the SDK's tool with the missingCapabilityToolName option.`);
338
+ else if (isFirstPage) {
338
339
  const virtualTool = getReportMissingToolDescriptor(missingToolName);
339
340
  tools.push(virtualTool);
340
341
  cacheToolAnalyticsParameterOwnership(data.toolAnalyticsParameterOwnership, [
341
342
  virtualTool
342
343
  ]);
343
- }
344
+ } else if (alreadyPresent) data.logger(`Warning: A real tool "${missingToolName}" on a later tools/list page is shadowed by the SDK's missing-capability tool. Its calls will be intercepted. Rename the SDK's tool with the missingCapabilityToolName option to keep both.`);
344
345
  }
345
346
  const feedbackOptions = resolveCollectFeedbackOptions(data.options.collectFeedback);
346
347
  if (feedbackOptions) {
347
348
  const feedbackToolName = feedbackOptions.toolName ?? SEND_FEEDBACK_TOOL_NAME;
348
349
  const alreadyPresent = tools.some((tool)=>tool?.name === feedbackToolName);
349
- if (alreadyPresent) data.logger(`Warning: Cannot inject agent-feedback tool "${feedbackToolName}" because a real tool already uses that name. The real tool will not be intercepted.`);
350
- else {
350
+ if (isFirstPage && alreadyPresent) data.logger(`Warning: Cannot inject agent-feedback tool "${feedbackToolName}" because a real tool already uses that name. The real tool will not be intercepted. To collect feedback alongside it, rename the SDK's tool with collectFeedback: { toolName: "..." }.`);
351
+ else if (isFirstPage) {
351
352
  const virtualTool = getFeedbackToolDescriptor(feedbackOptions);
352
353
  tools.push(virtualTool);
353
354
  cacheToolAnalyticsParameterOwnership(data.toolAnalyticsParameterOwnership, [
354
355
  virtualTool
355
356
  ]);
356
- }
357
+ } else if (alreadyPresent) data.logger(`Warning: A real tool "${feedbackToolName}" on a later tools/list page is shadowed by the SDK's agent-feedback tool. Its calls will be intercepted. Rename the SDK's tool with collectFeedback: { toolName: "..." } to keep both.`);
357
358
  }
358
359
  if (isCaptureModelEnabled(data.options.captureModel)) tools = addModelParameterToTools(tools, getModelDescription(data.options.captureModel), data.logger);
359
360
  if (data.options.enableConversationId) {
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const version = "0.16.1";
1
+ export declare const version = "0.16.3";
2
2
  //# sourceMappingURL=version.d.ts.map
package/dist/version.js CHANGED
@@ -27,7 +27,7 @@ var __webpack_require__ = {};
27
27
  })();
28
28
  var __webpack_exports__ = {};
29
29
  __webpack_require__.r(__webpack_exports__);
30
- const version = '0.16.1';
30
+ const version = '0.16.3';
31
31
  __webpack_require__.d(__webpack_exports__, {}, {
32
32
  version: version
33
33
  });
package/dist/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- const version = '0.16.1';
1
+ const version = '0.16.3';
2
2
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@posthog/mcp",
3
- "version": "0.16.1",
3
+ "version": "0.16.3",
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.53.3"
31
+ "@posthog/core": "^1.54.2"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@babel/preset-env": "^7.27.1",
@@ -53,7 +53,7 @@
53
53
  "@vitest/coverage-v8": "^1.6.1",
54
54
  "vitest": "^1.6.1",
55
55
  "@posthog-tooling/tsconfig-base": "1.1.1",
56
- "posthog-node": "^5.52.1"
56
+ "posthog-node": "^5.52.4"
57
57
  },
58
58
  "peerDependencies": {
59
59
  "@modelcontextprotocol/sdk": ">=1.26.0",
@@ -91,8 +91,8 @@
91
91
  "pretest:unit": "pnpm generate-version",
92
92
  "test:unit": "vitest run",
93
93
  "test:integration": "pnpm test:integration:sdk-v1 && pnpm test:integration:sdk-v2 && pnpm test:integration:nest-v1 && pnpm test:integration:nest-v2",
94
- "test:integration:sdk-v1": "node harness/dual-era/matrix.mjs --major v1 && node harness/dual-era/probe-late-handlers.mjs --major v1 && node harness/dual-era/probe-pagination.mjs --major v1 && node harness/dual-era/probe-mcp-apps.mjs --major v1",
95
- "test:integration:sdk-v2": "node harness/dual-era/matrix.mjs --major v2 && node harness/dual-era/probe-late-handlers.mjs --major v2 && node harness/dual-era/probe-first-call-error.mjs && node harness/dual-era/probe-pagination.mjs --major v2 && node harness/dual-era/probe-mcp-apps.mjs --major v2",
94
+ "test:integration:sdk-v1": "node harness/dual-era/matrix.mjs --major v1 && node harness/dual-era/probe-late-handlers.mjs --major v1 && node harness/dual-era/probe-pagination.mjs --major v1 && node harness/dual-era/probe-feedback.mjs --major v1 && node harness/dual-era/probe-mcp-apps.mjs --major v1",
95
+ "test:integration:sdk-v2": "node harness/dual-era/matrix.mjs --major v2 && node harness/dual-era/probe-late-handlers.mjs --major v2 && node harness/dual-era/probe-first-call-error.mjs && node harness/dual-era/probe-pagination.mjs --major v2 && node harness/dual-era/probe-feedback.mjs --major v2 && node harness/dual-era/probe-mcp-apps.mjs --major v2",
96
96
  "test:integration:nest-v1": "node harness/nest-v1/verify.mjs && LEVEL=low node harness/nest-v1/verify.mjs",
97
97
  "test:integration:nest-v2": "node harness/nest-v2/verify.mjs && LEVEL=low node harness/nest-v2/verify.mjs",
98
98
  "prebuild": "pnpm generate-version",
@@ -825,19 +825,32 @@ async function getTracedToolsList(
825
825
  }
826
826
 
827
827
  if (data) {
828
+ // A compliant client concatenates every page into one list, so only the
829
+ // first page — the one every client reads, including clients that never
830
+ // follow `nextCursor` — may carry a virtual tool. Presence, not
831
+ // truthiness: `cursor: ""` is a continuation page.
832
+ const isFirstPage = request.params?.cursor == null
833
+
828
834
  const missingToolName = resolveMissingCapabilityToolName(data.options)
829
835
  if (data.options.reportMissing) {
830
836
  const alreadyPresent = tools.some((tool) => tool?.name === missingToolName)
831
- if (alreadyPresent) {
837
+ if (isFirstPage && alreadyPresent) {
832
838
  data.logger(
833
- `Warning: Cannot inject missing-capability tool "${missingToolName}" because a real tool already uses that name. The real tool will not be intercepted.`
839
+ `Warning: Cannot inject missing-capability tool "${missingToolName}" because a real tool already uses that name. The real tool will not be intercepted. To keep missing-capability reports, rename the SDK's tool with the missingCapabilityToolName option.`
834
840
  )
835
- } else {
841
+ } else if (isFirstPage) {
836
842
  const virtualTool = getReportMissingToolDescriptor(missingToolName)
837
843
  tools.push(virtualTool)
838
844
  // Cached separately because the virtual tool is added after the listing
839
845
  // was cached, and its calls need ownership like any other tool's.
840
846
  cacheToolAnalyticsParameterOwnership(data.toolAnalyticsParameterOwnership, [virtualTool])
847
+ } else if (alreadyPresent) {
848
+ // Conflicts are only detected on the pages a client actually
849
+ // fetches; a real owner here is already shadowed by the first-page
850
+ // injection, so the host must rename the SDK's tool.
851
+ data.logger(
852
+ `Warning: A real tool "${missingToolName}" on a later tools/list page is shadowed by the SDK's missing-capability tool. Its calls will be intercepted. Rename the SDK's tool with the missingCapabilityToolName option to keep both.`
853
+ )
841
854
  }
842
855
  }
843
856
 
@@ -845,14 +858,21 @@ async function getTracedToolsList(
845
858
  if (feedbackOptions) {
846
859
  const feedbackToolName = feedbackOptions.toolName ?? SEND_FEEDBACK_TOOL_NAME
847
860
  const alreadyPresent = tools.some((tool) => tool?.name === feedbackToolName)
848
- if (alreadyPresent) {
861
+ if (isFirstPage && alreadyPresent) {
849
862
  data.logger(
850
- `Warning: Cannot inject agent-feedback tool "${feedbackToolName}" because a real tool already uses that name. The real tool will not be intercepted.`
863
+ `Warning: Cannot inject agent-feedback tool "${feedbackToolName}" because a real tool already uses that name. The real tool will not be intercepted. To collect feedback alongside it, rename the SDK's tool with collectFeedback: { toolName: "..." }.`
851
864
  )
852
- } else {
865
+ } else if (isFirstPage) {
853
866
  const virtualTool = getFeedbackToolDescriptor(feedbackOptions)
854
867
  tools.push(virtualTool)
855
868
  cacheToolAnalyticsParameterOwnership(data.toolAnalyticsParameterOwnership, [virtualTool])
869
+ } else if (alreadyPresent) {
870
+ // Conflicts are only detected on the pages a client actually
871
+ // fetches; a real owner here is already shadowed by the first-page
872
+ // injection, so the host must rename the SDK's tool.
873
+ data.logger(
874
+ `Warning: A real tool "${feedbackToolName}" on a later tools/list page is shadowed by the SDK's agent-feedback tool. Its calls will be intercepted. Rename the SDK's tool with collectFeedback: { toolName: "..." } to keep both.`
875
+ )
856
876
  }
857
877
  }
858
878
 
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '0.16.1'
1
+ export const version = '0.16.3'