@posthog/mcp 0.0.6 → 0.0.8
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 +1 -0
- package/dist/index.cjs +19 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.mjs +19 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
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;
|
|
@@ -557,6 +559,7 @@ const PROTECTED_FIELDS = new Set([
|
|
|
557
559
|
"identifyData",
|
|
558
560
|
"resourceName",
|
|
559
561
|
"toolDescription",
|
|
562
|
+
"listedToolNames",
|
|
560
563
|
"eventType",
|
|
561
564
|
"actorId",
|
|
562
565
|
"tags",
|
|
@@ -734,7 +737,7 @@ function sanitizeParameters(obj) {
|
|
|
734
737
|
}
|
|
735
738
|
//#endregion
|
|
736
739
|
//#region package.json
|
|
737
|
-
var version = "0.0.
|
|
740
|
+
var version = "0.0.8";
|
|
738
741
|
//#endregion
|
|
739
742
|
//#region src/modules/session.ts
|
|
740
743
|
function newSessionId() {
|
|
@@ -1195,6 +1198,7 @@ function publishEvent(server, eventInput) {
|
|
|
1195
1198
|
identifyActorData: sessionInfo.identifyActorData,
|
|
1196
1199
|
resourceName: eventInput.resourceName,
|
|
1197
1200
|
toolDescription: eventInput.toolDescription,
|
|
1201
|
+
listedToolNames: eventInput.listedToolNames,
|
|
1198
1202
|
parameters: eventInput.parameters,
|
|
1199
1203
|
response: eventInput.response,
|
|
1200
1204
|
userIntent: eventInput.userIntent,
|
|
@@ -1869,6 +1873,12 @@ function getReportMissingToolDescriptor() {
|
|
|
1869
1873
|
description: "A description of your goal and what kind of tool would help accomplish it."
|
|
1870
1874
|
} },
|
|
1871
1875
|
required: ["context"]
|
|
1876
|
+
},
|
|
1877
|
+
annotations: {
|
|
1878
|
+
readOnlyHint: true,
|
|
1879
|
+
idempotentHint: false,
|
|
1880
|
+
openWorldHint: false,
|
|
1881
|
+
destructiveHint: false
|
|
1872
1882
|
}
|
|
1873
1883
|
};
|
|
1874
1884
|
}
|
|
@@ -1924,9 +1934,8 @@ function setupMCPAnalyticsTools(server) {
|
|
|
1924
1934
|
return { tools };
|
|
1925
1935
|
}
|
|
1926
1936
|
if (isContextEnabled(data.options.context)) tools = addContextParameterToTools(tools, getContextDescription(data.options.context));
|
|
1927
|
-
if (data.options.reportMissing)
|
|
1928
|
-
|
|
1929
|
-
}
|
|
1937
|
+
if (data.options.reportMissing) if (tools.some((tool) => tool?.name === "get_more_tools")) writeToLog("Warning: report_missing tool already present in tools list. Skipping addition. This is likely due to the server already including a report_missing tool. If you want to rely on the PostHog MCP Analytics report_missing tool, you should disable the server's report_missing tool.");
|
|
1938
|
+
else tools.push(getReportMissingToolDescriptor());
|
|
1930
1939
|
event.response = { tools };
|
|
1931
1940
|
event.isError = false;
|
|
1932
1941
|
event.duration = event.timestamp && Date.now() - event.timestamp.getTime() || 0;
|
|
@@ -2129,11 +2138,17 @@ async function handleListToolsRequest(server, originalListToolsHandler, request,
|
|
|
2129
2138
|
return { tools };
|
|
2130
2139
|
}
|
|
2131
2140
|
event.response = { tools };
|
|
2141
|
+
event.listedToolNames = collectListedToolNames(tools);
|
|
2132
2142
|
event.isError = false;
|
|
2133
2143
|
event.duration = getEventDuration(event);
|
|
2134
2144
|
publishEvent(server, event);
|
|
2135
2145
|
return { tools };
|
|
2136
2146
|
}
|
|
2147
|
+
function collectListedToolNames(tools) {
|
|
2148
|
+
if (!tools || tools.length === 0) return;
|
|
2149
|
+
const names = tools.map((tool) => tool?.name).filter((name) => typeof name === "string");
|
|
2150
|
+
return names.length > 0 ? names : void 0;
|
|
2151
|
+
}
|
|
2137
2152
|
async function getTracedToolsList(server, originalListToolsHandler, request, extra, event) {
|
|
2138
2153
|
try {
|
|
2139
2154
|
const data = getServerTrackingData(server);
|