@posthog/mcp 0.0.7 → 0.0.9
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 -1
- package/README.md +17 -16
- package/dist/index.cjs +14 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +14 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -28,7 +28,7 @@ interface MCPAnalyticsOptions {
|
|
|
28
28
|
eventProperties?: (request: MCPRequestLike, extra?: CompatibleRequestHandlerExtra) => JsonRecord | null | Promise<JsonRecord | null>;
|
|
29
29
|
eventTags?: (request: MCPRequestLike, extra?: CompatibleRequestHandlerExtra) => Record<string, string> | null | Promise<Record<string, string> | null>;
|
|
30
30
|
host?: string;
|
|
31
|
-
identify?: (request: MCPRequestLike, extra?: CompatibleRequestHandlerExtra) => Promise<UserIdentity | null
|
|
31
|
+
identify?: ((request: MCPRequestLike, extra?: CompatibleRequestHandlerExtra) => Promise<UserIdentity | null>) | UserIdentity | null;
|
|
32
32
|
intentFallback?: (request: MCPRequestLike, extra?: CompatibleRequestHandlerExtra) => MaybePromise<string | null | undefined>;
|
|
33
33
|
posthogClient?: PostHogCaptureClient;
|
|
34
34
|
posthogOptions?: Pick<PostHogOptions, "fetch" | "flushAt" | "flushInterval" | "host" | "requestTimeout" | "waitUntil" | "waitUntilDebounceMs" | "waitUntilMaxWaitMs">;
|
package/dist/index.d.mts
CHANGED
|
@@ -27,7 +27,7 @@ interface MCPAnalyticsOptions {
|
|
|
27
27
|
eventProperties?: (request: MCPRequestLike, extra?: CompatibleRequestHandlerExtra) => JsonRecord | null | Promise<JsonRecord | null>;
|
|
28
28
|
eventTags?: (request: MCPRequestLike, extra?: CompatibleRequestHandlerExtra) => Record<string, string> | null | Promise<Record<string, string> | null>;
|
|
29
29
|
host?: string;
|
|
30
|
-
identify?: (request: MCPRequestLike, extra?: CompatibleRequestHandlerExtra) => Promise<UserIdentity | null
|
|
30
|
+
identify?: ((request: MCPRequestLike, extra?: CompatibleRequestHandlerExtra) => Promise<UserIdentity | null>) | UserIdentity | null;
|
|
31
31
|
intentFallback?: (request: MCPRequestLike, extra?: CompatibleRequestHandlerExtra) => MaybePromise<string | null | undefined>;
|
|
32
32
|
posthogClient?: PostHogCaptureClient;
|
|
33
33
|
posthogOptions?: Pick<PostHogOptions, "fetch" | "flushAt" | "flushInterval" | "host" | "requestTimeout" | "waitUntil" | "waitUntilDebounceMs" | "waitUntilMaxWaitMs">;
|
package/dist/index.mjs
CHANGED
|
@@ -295,7 +295,7 @@ async function handleIdentify(server, data, request, extra) {
|
|
|
295
295
|
redactionFn: data.options.redactSensitiveInformation
|
|
296
296
|
};
|
|
297
297
|
try {
|
|
298
|
-
const identityResult = await data.options.identify(request, extra);
|
|
298
|
+
const identityResult = typeof data.options.identify === "function" ? await data.options.identify(request, extra) : data.options.identify;
|
|
299
299
|
if (identityResult) {
|
|
300
300
|
const currentSessionId = data.sessionId;
|
|
301
301
|
const previousIdentity = _globalIdentityCache.get(currentSessionId);
|
|
@@ -736,7 +736,7 @@ function sanitizeParameters(obj) {
|
|
|
736
736
|
}
|
|
737
737
|
//#endregion
|
|
738
738
|
//#region package.json
|
|
739
|
-
var version = "0.0.
|
|
739
|
+
var version = "0.0.9";
|
|
740
740
|
//#endregion
|
|
741
741
|
//#region src/modules/session.ts
|
|
742
742
|
function newSessionId() {
|
|
@@ -1872,6 +1872,13 @@ function getReportMissingToolDescriptor() {
|
|
|
1872
1872
|
description: "A description of your goal and what kind of tool would help accomplish it."
|
|
1873
1873
|
} },
|
|
1874
1874
|
required: ["context"]
|
|
1875
|
+
},
|
|
1876
|
+
annotations: {
|
|
1877
|
+
title: "Get More Tools",
|
|
1878
|
+
readOnlyHint: true,
|
|
1879
|
+
openWorldHint: true,
|
|
1880
|
+
idempotentHint: true,
|
|
1881
|
+
destructiveHint: false
|
|
1875
1882
|
}
|
|
1876
1883
|
};
|
|
1877
1884
|
}
|
|
@@ -1927,9 +1934,8 @@ function setupMCPAnalyticsTools(server) {
|
|
|
1927
1934
|
return { tools };
|
|
1928
1935
|
}
|
|
1929
1936
|
if (isContextEnabled(data.options.context)) tools = addContextParameterToTools(tools, getContextDescription(data.options.context));
|
|
1930
|
-
if (data.options.reportMissing)
|
|
1931
|
-
|
|
1932
|
-
}
|
|
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());
|
|
1933
1939
|
event.response = { tools };
|
|
1934
1940
|
event.isError = false;
|
|
1935
1941
|
event.duration = event.timestamp && Date.now() - event.timestamp.getTime() || 0;
|
|
@@ -2507,7 +2513,7 @@ async function handleWrappedToolsCall(originalHandler, server, request, extra) {
|
|
|
2507
2513
|
const startTime = /* @__PURE__ */ new Date();
|
|
2508
2514
|
const conversation = resolveConversationId(getServerTrackingData(server)?.options.enableConversationId ?? false, request.params?.arguments, request.params?.name);
|
|
2509
2515
|
const tracing = await initializeToolCallEvent(server, request, conversation.conversationId ? cloneRequestWithoutConversationId(request) : request, extra, startTime, conversation);
|
|
2510
|
-
if (request?.params?.name === "get_more_tools") return
|
|
2516
|
+
if (request?.params?.name === "get_more_tools") return executeReportMissingTool(server, request, tracing, startTime);
|
|
2511
2517
|
return await executeOriginalTool(originalHandler, server, request, extra, tracing, startTime);
|
|
2512
2518
|
}
|
|
2513
2519
|
async function initializeToolCallEvent(server, request, downstreamRequest, extra, startTime, conversation) {
|
|
@@ -2556,10 +2562,10 @@ async function applyResolvedMetadata(event, data, request, extra) {
|
|
|
2556
2562
|
const resolvedProperties = await resolveEventProperties(data, request, extra);
|
|
2557
2563
|
if (resolvedProperties) event.properties = resolvedProperties;
|
|
2558
2564
|
}
|
|
2559
|
-
|
|
2565
|
+
function executeReportMissingTool(server, request, tracing, startTime) {
|
|
2560
2566
|
try {
|
|
2561
2567
|
const context = getContextArgument(request) || "";
|
|
2562
|
-
const result =
|
|
2568
|
+
const result = handleReportMissing({ context });
|
|
2563
2569
|
publishSuccessfulToolEvent(server, tracing, result, startTime, {
|
|
2564
2570
|
userIntent: context,
|
|
2565
2571
|
userIntentSource: "context_parameter"
|