@posthog/mcp 0.0.5 → 0.0.7

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
@@ -103,6 +103,7 @@ Important properties:
103
103
  - `$mcp_intent_source` as `context_parameter` or `inferred`
104
104
  - `$mcp_tool_name` and `$mcp_resource_name`
105
105
  - `$mcp_tool_description`, the tool's current `description` at the moment of the call — populated on `mcp_tool_call` and on the paired `$exception` event so the description is visible inline while triaging
106
+ - `$mcp_listed_tool_names`, the array of tool names advertised in a `tools/list` response — populated on `mcp_tools_list` events so you can correlate "tools the agent was offered" with "tools the agent actually called" (e.g. find advertised tools that never get picked)
106
107
  - `$mcp_parameters` and `$mcp_response`, after redaction and truncation
107
108
  - `$mcp_duration_ms`
108
109
  - `$mcp_is_error`
package/dist/index.cjs CHANGED
@@ -382,6 +382,7 @@ const PostHogMCPAnalyticsProperty = {
382
382
  IsError: "$mcp_is_error",
383
383
  Intent: "$mcp_intent",
384
384
  IntentSource: "$mcp_intent_source",
385
+ ListedToolNames: "$mcp_listed_tool_names",
385
386
  Parameters: "$mcp_parameters",
386
387
  ResourceName: "$mcp_resource_name",
387
388
  Response: "$mcp_response",
@@ -459,6 +460,7 @@ function addCommonEventProperties(event, properties) {
459
460
  if (event.eventType === MCPAnalyticsEventType.mcpToolsCall) properties[PostHogMCPAnalyticsProperty.ToolName] = event.resourceName;
460
461
  }
461
462
  if (event.toolDescription && event.eventType === MCPAnalyticsEventType.mcpToolsCall) properties[PostHogMCPAnalyticsProperty.ToolDescription] = event.toolDescription;
463
+ if (event.listedToolNames && event.listedToolNames.length > 0 && event.eventType === MCPAnalyticsEventType.mcpToolsList) properties[PostHogMCPAnalyticsProperty.ListedToolNames] = event.listedToolNames;
462
464
  if (event.duration !== void 0) properties[PostHogMCPAnalyticsProperty.DurationMs] = event.duration;
463
465
  if (event.serverName) properties[PostHogMCPAnalyticsProperty.ServerName] = event.serverName;
464
466
  if (event.serverVersion) properties[PostHogMCPAnalyticsProperty.ServerVersion] = event.serverVersion;
@@ -500,6 +502,7 @@ function buildExceptionEvent(event) {
500
502
  if (event.serverVersion) properties[PostHogMCPAnalyticsProperty.ServerVersion] = event.serverVersion;
501
503
  if (event.clientName) properties[PostHogMCPAnalyticsProperty.ClientName] = event.clientName;
502
504
  if (event.clientVersion) properties[PostHogMCPAnalyticsProperty.ClientVersion] = event.clientVersion;
505
+ addCustomEventProperties(event, properties);
503
506
  return {
504
507
  event: PostHogMCPAnalyticsEvent.Exception,
505
508
  distinct_id: distinctId,
@@ -556,6 +559,7 @@ const PROTECTED_FIELDS = new Set([
556
559
  "identifyData",
557
560
  "resourceName",
558
561
  "toolDescription",
562
+ "listedToolNames",
559
563
  "eventType",
560
564
  "actorId",
561
565
  "tags",
@@ -733,7 +737,7 @@ function sanitizeParameters(obj) {
733
737
  }
734
738
  //#endregion
735
739
  //#region package.json
736
- var version = "0.0.5";
740
+ var version = "0.0.7";
737
741
  //#endregion
738
742
  //#region src/modules/session.ts
739
743
  function newSessionId() {
@@ -1194,6 +1198,7 @@ function publishEvent(server, eventInput) {
1194
1198
  identifyActorData: sessionInfo.identifyActorData,
1195
1199
  resourceName: eventInput.resourceName,
1196
1200
  toolDescription: eventInput.toolDescription,
1201
+ listedToolNames: eventInput.listedToolNames,
1197
1202
  parameters: eventInput.parameters,
1198
1203
  response: eventInput.response,
1199
1204
  userIntent: eventInput.userIntent,
@@ -2128,11 +2133,17 @@ async function handleListToolsRequest(server, originalListToolsHandler, request,
2128
2133
  return { tools };
2129
2134
  }
2130
2135
  event.response = { tools };
2136
+ event.listedToolNames = collectListedToolNames(tools);
2131
2137
  event.isError = false;
2132
2138
  event.duration = getEventDuration(event);
2133
2139
  publishEvent(server, event);
2134
2140
  return { tools };
2135
2141
  }
2142
+ function collectListedToolNames(tools) {
2143
+ if (!tools || tools.length === 0) return;
2144
+ const names = tools.map((tool) => tool?.name).filter((name) => typeof name === "string");
2145
+ return names.length > 0 ? names : void 0;
2146
+ }
2136
2147
  async function getTracedToolsList(server, originalListToolsHandler, request, extra, event) {
2137
2148
  try {
2138
2149
  const data = getServerTrackingData(server);