@posthog/mcp 0.16.3 → 0.16.4
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 +2 -0
- package/dist/extensions/instrument-highlevel.d.ts.map +1 -1
- package/dist/extensions/instrument-highlevel.js +2 -2
- package/dist/extensions/instrument-highlevel.mjs +3 -3
- package/dist/extensions/instrument-lowlevel.d.ts.map +1 -1
- package/dist/extensions/instrument-lowlevel.js +3 -2
- package/dist/extensions/instrument-lowlevel.mjs +4 -3
- package/dist/extensions/instrumentation.d.ts +0 -20
- package/dist/extensions/instrumentation.d.ts.map +1 -1
- package/dist/extensions/instrumentation.js +0 -9
- package/dist/extensions/instrumentation.mjs +1 -7
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.mjs +1 -1
- package/package.json +3 -2
- package/src/extensions/instrument-highlevel.ts +2 -11
- package/src/extensions/instrument-lowlevel.ts +3 -11
- package/src/extensions/instrumentation.ts +0 -30
- package/src/version.ts +1 -1
package/README.md
CHANGED
|
@@ -81,6 +81,8 @@ Protocol revision is a property of each **request**, not of the server: a v2 ser
|
|
|
81
81
|
- **On `2026-07-28`** there is no `initialize` and no session header — the revision removed
|
|
82
82
|
protocol-level sessions, and this SDK will not mint one. Session correlation therefore comes from
|
|
83
83
|
`enableConversationId`, which is **opt-in**. Without it every request is its own `$session_id`.
|
|
84
|
+
The `get_more_tools` and `send_feedback` virtual tools also use this handle, including calls handled
|
|
85
|
+
by a fresh server instance.
|
|
84
86
|
- **On `2025-11-25`**, the session id and the client's name and version are exchanged once at
|
|
85
87
|
`initialize`. If your server builds a fresh `McpServer` per HTTP request — which
|
|
86
88
|
`createMcpHandler` does by default — the instance serving a later `tools/call` never saw that
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrument-highlevel.d.ts","sourceRoot":"","sources":["../../src/extensions/instrument-highlevel.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAGV,sBAAsB,EAIvB,MAAM,UAAU,CAAA;AAmBjB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"instrument-highlevel.d.ts","sourceRoot":"","sources":["../../src/extensions/instrument-highlevel.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAGV,sBAAsB,EAIvB,MAAM,UAAU,CAAA;AAmBjB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAuRxC,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,sBAAsB,EAAE,MAAM,EAAE,QAAQ,GAAG,IAAI,CA+BhG"}
|
|
@@ -172,7 +172,7 @@ async function handleToolCallRequest(highLevelServer, server, originalCallToolHa
|
|
|
172
172
|
extra,
|
|
173
173
|
eventType: external_event_types_js_namespaceObject.MCPAnalyticsEventType.mcpMissingCapability,
|
|
174
174
|
explicitContextIntent: context,
|
|
175
|
-
parameterOwnership: (0,
|
|
175
|
+
parameterOwnership: (0, external_analytics_parameters_js_namespaceObject.getAnalyticsParameterOwnership)((0, external_tools_js_namespaceObject.getReportMissingToolDescriptor)(toolName).inputSchema),
|
|
176
176
|
execute: async ()=>(0, external_tools_js_namespaceObject.handleReportMissing)({
|
|
177
177
|
context
|
|
178
178
|
}, data.logger)
|
|
@@ -191,7 +191,7 @@ async function handleToolCallRequest(highLevelServer, server, originalCallToolHa
|
|
|
191
191
|
explicitContextIntent: (0, external_feedback_js_namespaceObject.buildFeedbackIntent)(report),
|
|
192
192
|
omitCapturedParameters: true,
|
|
193
193
|
extraEventProperties: (0, external_feedback_js_namespaceObject.buildFeedbackEventProperties)(report),
|
|
194
|
-
parameterOwnership: (0,
|
|
194
|
+
parameterOwnership: (0, external_analytics_parameters_js_namespaceObject.getAnalyticsParameterOwnership)((0, external_feedback_js_namespaceObject.getFeedbackToolDescriptor)(feedbackOptions).inputSchema),
|
|
195
195
|
execute: async ()=>(0, external_feedback_js_namespaceObject.handleFeedback)(report, feedbackOptions, data.logger)
|
|
196
196
|
});
|
|
197
197
|
}
|
|
@@ -6,7 +6,7 @@ import { MCPAnalyticsEventType } from "./event-types.mjs";
|
|
|
6
6
|
import { getServerTrackingData } from "./internal.mjs";
|
|
7
7
|
import { createWrappedTool, getToolFunction, hasToolFunction } from "./mcp-sdk-compat.mjs";
|
|
8
8
|
import { getReportMissingToolDescriptor, handleReportMissing, resolveMissingCapabilityToolName } from "./tools.mjs";
|
|
9
|
-
import { captureToolCall,
|
|
9
|
+
import { captureToolCall, handleInitializeRequest, handleListToolsRequest, isToolAdvertised, patchRequestHandlers, readToolMetaCategory, traceResourceRequest } from "./instrumentation.mjs";
|
|
10
10
|
import { getContextArgument } from "./tracing-helpers.mjs";
|
|
11
11
|
const wrappedCallbacks = new WeakMap();
|
|
12
12
|
const MCP_ANALYTICS_PROCESSED = Symbol('__posthog_mcp_analytics_processed__');
|
|
@@ -140,7 +140,7 @@ async function handleToolCallRequest(highLevelServer, server, originalCallToolHa
|
|
|
140
140
|
extra,
|
|
141
141
|
eventType: MCPAnalyticsEventType.mcpMissingCapability,
|
|
142
142
|
explicitContextIntent: context,
|
|
143
|
-
parameterOwnership:
|
|
143
|
+
parameterOwnership: getAnalyticsParameterOwnership(getReportMissingToolDescriptor(toolName).inputSchema),
|
|
144
144
|
execute: async ()=>handleReportMissing({
|
|
145
145
|
context
|
|
146
146
|
}, data.logger)
|
|
@@ -159,7 +159,7 @@ async function handleToolCallRequest(highLevelServer, server, originalCallToolHa
|
|
|
159
159
|
explicitContextIntent: buildFeedbackIntent(report),
|
|
160
160
|
omitCapturedParameters: true,
|
|
161
161
|
extraEventProperties: buildFeedbackEventProperties(report),
|
|
162
|
-
parameterOwnership:
|
|
162
|
+
parameterOwnership: getAnalyticsParameterOwnership(getFeedbackToolDescriptor(feedbackOptions).inputSchema),
|
|
163
163
|
execute: async ()=>handleFeedback(report, feedbackOptions, data.logger)
|
|
164
164
|
});
|
|
165
165
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrument-lowlevel.d.ts","sourceRoot":"","sources":["../../src/extensions/instrument-lowlevel.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAiD,aAAa,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"instrument-lowlevel.d.ts","sourceRoot":"","sources":["../../src/extensions/instrument-lowlevel.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAiD,aAAa,EAAE,MAAM,UAAU,CAAA;AAa5F,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAoBxC;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,QAAQ,GAAG,IAAI,CA8BtF"}
|
|
@@ -31,6 +31,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
31
31
|
instrumentLowLevelServer: ()=>instrumentLowLevelServer
|
|
32
32
|
});
|
|
33
33
|
const external_feedback_js_namespaceObject = require("./feedback.js");
|
|
34
|
+
const external_analytics_parameters_js_namespaceObject = require("./analytics-parameters.js");
|
|
34
35
|
const external_event_types_js_namespaceObject = require("./event-types.js");
|
|
35
36
|
const external_internal_js_namespaceObject = require("./internal.js");
|
|
36
37
|
const external_tools_js_namespaceObject = require("./tools.js");
|
|
@@ -75,7 +76,7 @@ async function handleToolCallRequest(server, originalCallToolHandler, request, e
|
|
|
75
76
|
extra,
|
|
76
77
|
eventType: external_event_types_js_namespaceObject.MCPAnalyticsEventType.mcpMissingCapability,
|
|
77
78
|
explicitContextIntent: context,
|
|
78
|
-
parameterOwnership: (0,
|
|
79
|
+
parameterOwnership: (0, external_analytics_parameters_js_namespaceObject.getAnalyticsParameterOwnership)((0, external_tools_js_namespaceObject.getReportMissingToolDescriptor)(toolName).inputSchema),
|
|
79
80
|
execute: async ()=>(0, external_tools_js_namespaceObject.handleReportMissing)({
|
|
80
81
|
context
|
|
81
82
|
}, data.logger)
|
|
@@ -94,7 +95,7 @@ async function handleToolCallRequest(server, originalCallToolHandler, request, e
|
|
|
94
95
|
explicitContextIntent: (0, external_feedback_js_namespaceObject.buildFeedbackIntent)(report),
|
|
95
96
|
omitCapturedParameters: true,
|
|
96
97
|
extraEventProperties: (0, external_feedback_js_namespaceObject.buildFeedbackEventProperties)(report),
|
|
97
|
-
parameterOwnership: (0,
|
|
98
|
+
parameterOwnership: (0, external_analytics_parameters_js_namespaceObject.getAnalyticsParameterOwnership)((0, external_feedback_js_namespaceObject.getFeedbackToolDescriptor)(feedbackOptions).inputSchema),
|
|
98
99
|
execute: async ()=>(0, external_feedback_js_namespaceObject.handleFeedback)(report, feedbackOptions, data.logger)
|
|
99
100
|
});
|
|
100
101
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { SEND_FEEDBACK_TOOL_NAME, buildFeedbackEventProperties, buildFeedbackIntent, getFeedbackToolDescriptor, handleFeedback, parseFeedbackReport, resolveCollectFeedbackOptions } from "./feedback.mjs";
|
|
2
|
+
import { getAnalyticsParameterOwnership } from "./analytics-parameters.mjs";
|
|
2
3
|
import { MCPAnalyticsEventType } from "./event-types.mjs";
|
|
3
4
|
import { getServerTrackingData } from "./internal.mjs";
|
|
4
5
|
import { getReportMissingToolDescriptor, handleReportMissing, resolveMissingCapabilityToolName } from "./tools.mjs";
|
|
5
|
-
import { captureToolCall,
|
|
6
|
+
import { captureToolCall, handleInitializeRequest, handleListToolsRequest, isToolAdvertised, patchRequestHandlers, registerFallbackRequestHandler, traceResourceRequest } from "./instrumentation.mjs";
|
|
6
7
|
import { getContextArgument } from "./tracing-helpers.mjs";
|
|
7
8
|
function instrumentLowLevelServer(server, logger) {
|
|
8
9
|
try {
|
|
@@ -43,7 +44,7 @@ async function handleToolCallRequest(server, originalCallToolHandler, request, e
|
|
|
43
44
|
extra,
|
|
44
45
|
eventType: MCPAnalyticsEventType.mcpMissingCapability,
|
|
45
46
|
explicitContextIntent: context,
|
|
46
|
-
parameterOwnership:
|
|
47
|
+
parameterOwnership: getAnalyticsParameterOwnership(getReportMissingToolDescriptor(toolName).inputSchema),
|
|
47
48
|
execute: async ()=>handleReportMissing({
|
|
48
49
|
context
|
|
49
50
|
}, data.logger)
|
|
@@ -62,7 +63,7 @@ async function handleToolCallRequest(server, originalCallToolHandler, request, e
|
|
|
62
63
|
explicitContextIntent: buildFeedbackIntent(report),
|
|
63
64
|
omitCapturedParameters: true,
|
|
64
65
|
extraEventProperties: buildFeedbackEventProperties(report),
|
|
65
|
-
parameterOwnership:
|
|
66
|
+
parameterOwnership: getAnalyticsParameterOwnership(getFeedbackToolDescriptor(feedbackOptions).inputSchema),
|
|
66
67
|
execute: async ()=>handleFeedback(report, feedbackOptions, data.logger)
|
|
67
68
|
});
|
|
68
69
|
}
|
|
@@ -100,26 +100,6 @@ export declare function registerFallbackRequestHandler(server: MCPServerLike, ha
|
|
|
100
100
|
* bare server to instrument() and only then registers its handlers.
|
|
101
101
|
*/
|
|
102
102
|
export declare function patchRequestHandlers(server: MCPServerLike, patches: Record<string, HandlerPatch>): void;
|
|
103
|
-
/**
|
|
104
|
-
* Ownership for an SDK-owned virtual tool (`get_more_tools`, `send_feedback`),
|
|
105
|
-
* resolved from its own descriptor rather than the `tools/list` cache.
|
|
106
|
-
*
|
|
107
|
-
* A virtual-tool branch is only entered when the application does not advertise
|
|
108
|
-
* a tool by this name, so the descriptor is the SDK's own and what it declares
|
|
109
|
-
* is known statically. An instance that never served a listing — a per-request
|
|
110
|
-
* `McpServer`/`Server`, the topology in ADR-0011 — would otherwise read every
|
|
111
|
-
* injected parameter as not-ours and neither capture nor strip it.
|
|
112
|
-
*
|
|
113
|
-
* `conversation_id` still comes from the cache on purpose: resolving it here too
|
|
114
|
-
* would start minting a handle, and appending its prompt-back block, on
|
|
115
|
-
* instances that today mint none. That changes session anchoring (ADR-0004)
|
|
116
|
-
* rather than closing this gap.
|
|
117
|
-
*
|
|
118
|
-
* `virtualToolInputSchema` is required (not defaulted to one specific virtual
|
|
119
|
-
* tool's descriptor) so every call site names the tool it means; each caller
|
|
120
|
-
* passes its own descriptor's `inputSchema`.
|
|
121
|
-
*/
|
|
122
|
-
export declare function getVirtualToolParameterOwnership(data: MCPAnalyticsData, toolName: string, virtualToolInputSchema: unknown): AnalyticsParameterOwnership;
|
|
123
103
|
/**
|
|
124
104
|
* Checks the server's raw listing for a real owner of a candidate virtual tool.
|
|
125
105
|
* This does not depend on a previous client request and does not call the
|
|
@@ -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,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAUxC;;;;;;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;;;;;OAKG;IACH,SAAS,CAAC,EAAE,qBAAqB,CAAA;IACjC;;;;OAIG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B;;;OAGG;IACH,oBAA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AUN;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"}
|
|
@@ -31,7 +31,6 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
31
31
|
cacheToolCategories: ()=>cacheToolCategories,
|
|
32
32
|
cacheToolDescriptions: ()=>cacheToolDescriptions,
|
|
33
33
|
captureToolCall: ()=>captureToolCall,
|
|
34
|
-
getVirtualToolParameterOwnership: ()=>getVirtualToolParameterOwnership,
|
|
35
34
|
handleInitializeRequest: ()=>handleInitializeRequest,
|
|
36
35
|
handleListToolsRequest: ()=>handleListToolsRequest,
|
|
37
36
|
isToolAdvertised: ()=>isToolAdvertised,
|
|
@@ -296,12 +295,6 @@ function patchRequestHandlers(server, patches) {
|
|
|
296
295
|
return result;
|
|
297
296
|
};
|
|
298
297
|
}
|
|
299
|
-
function getVirtualToolParameterOwnership(data, toolName, virtualToolInputSchema) {
|
|
300
|
-
return {
|
|
301
|
-
...(0, external_analytics_parameters_js_namespaceObject.getAnalyticsParameterOwnership)(virtualToolInputSchema),
|
|
302
|
-
conversationId: data.toolAnalyticsParameterOwnership.get(toolName)?.conversationId === true
|
|
303
|
-
};
|
|
304
|
-
}
|
|
305
298
|
async function isToolAdvertised(server, toolName, extra, logger) {
|
|
306
299
|
const listHandler = originalRequestHandlers.get(server)?.get('tools/list');
|
|
307
300
|
if (!listHandler || !server._requestHandlers.has('tools/list')) return;
|
|
@@ -547,7 +540,6 @@ function readProtocolVersion(result, request) {
|
|
|
547
540
|
exports.cacheToolCategories = __webpack_exports__.cacheToolCategories;
|
|
548
541
|
exports.cacheToolDescriptions = __webpack_exports__.cacheToolDescriptions;
|
|
549
542
|
exports.captureToolCall = __webpack_exports__.captureToolCall;
|
|
550
|
-
exports.getVirtualToolParameterOwnership = __webpack_exports__.getVirtualToolParameterOwnership;
|
|
551
543
|
exports.handleInitializeRequest = __webpack_exports__.handleInitializeRequest;
|
|
552
544
|
exports.handleListToolsRequest = __webpack_exports__.handleListToolsRequest;
|
|
553
545
|
exports.isToolAdvertised = __webpack_exports__.isToolAdvertised;
|
|
@@ -559,7 +551,6 @@ for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
|
559
551
|
"cacheToolCategories",
|
|
560
552
|
"cacheToolDescriptions",
|
|
561
553
|
"captureToolCall",
|
|
562
|
-
"getVirtualToolParameterOwnership",
|
|
563
554
|
"handleInitializeRequest",
|
|
564
555
|
"handleListToolsRequest",
|
|
565
556
|
"isToolAdvertised",
|
|
@@ -254,12 +254,6 @@ function patchRequestHandlers(server, patches) {
|
|
|
254
254
|
return result;
|
|
255
255
|
};
|
|
256
256
|
}
|
|
257
|
-
function getVirtualToolParameterOwnership(data, toolName, virtualToolInputSchema) {
|
|
258
|
-
return {
|
|
259
|
-
...getAnalyticsParameterOwnership(virtualToolInputSchema),
|
|
260
|
-
conversationId: data.toolAnalyticsParameterOwnership.get(toolName)?.conversationId === true
|
|
261
|
-
};
|
|
262
|
-
}
|
|
263
257
|
async function isToolAdvertised(server, toolName, extra, logger) {
|
|
264
258
|
const listHandler = originalRequestHandlers.get(server)?.get('tools/list');
|
|
265
259
|
if (!listHandler || !server._requestHandlers.has('tools/list')) return;
|
|
@@ -502,4 +496,4 @@ function readProtocolVersion(result, request) {
|
|
|
502
496
|
const requested = request.params?.protocolVersion;
|
|
503
497
|
return 'string' == typeof requested && requested.length > 0 ? requested : void 0;
|
|
504
498
|
}
|
|
505
|
-
export { cacheToolCategories, cacheToolDescriptions, captureToolCall,
|
|
499
|
+
export { cacheToolCategories, cacheToolDescriptions, captureToolCall, handleInitializeRequest, handleListToolsRequest, isToolAdvertised, patchRequestHandlers, readToolMetaCategory, registerFallbackRequestHandler, traceResourceRequest };
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "0.16.
|
|
1
|
+
export declare const version = "0.16.4";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/version.js
CHANGED
package/dist/version.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const version = '0.16.
|
|
1
|
+
const version = '0.16.4';
|
|
2
2
|
export { version };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@posthog/mcp",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.4",
|
|
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.54.
|
|
31
|
+
"@posthog/core": "^1.54.3"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@babel/preset-env": "^7.27.1",
|
|
@@ -84,6 +84,7 @@
|
|
|
84
84
|
}
|
|
85
85
|
},
|
|
86
86
|
"scripts": {
|
|
87
|
+
"check-types": "pnpm prebuild && tsc --noEmit --project tsconfig.build.json",
|
|
87
88
|
"clean": "rimraf dist coverage",
|
|
88
89
|
"lint": "oxlint --report-unused-disable-directives-severity error src && oxfmt --check harness",
|
|
89
90
|
"lint:fix": "oxlint --report-unused-disable-directives-severity error src --fix && oxfmt --write harness",
|
|
@@ -38,7 +38,6 @@ import {
|
|
|
38
38
|
traceResourceRequest,
|
|
39
39
|
patchRequestHandlers,
|
|
40
40
|
captureToolCall,
|
|
41
|
-
getVirtualToolParameterOwnership,
|
|
42
41
|
isToolAdvertised,
|
|
43
42
|
readToolMetaCategory,
|
|
44
43
|
type HandlerPatch,
|
|
@@ -260,11 +259,7 @@ async function handleToolCallRequest(
|
|
|
260
259
|
extra,
|
|
261
260
|
eventType: MCPAnalyticsEventType.mcpMissingCapability,
|
|
262
261
|
explicitContextIntent: context,
|
|
263
|
-
parameterOwnership:
|
|
264
|
-
data,
|
|
265
|
-
toolName,
|
|
266
|
-
getReportMissingToolDescriptor(toolName).inputSchema
|
|
267
|
-
),
|
|
262
|
+
parameterOwnership: getAnalyticsParameterOwnership(getReportMissingToolDescriptor(toolName).inputSchema),
|
|
268
263
|
execute: async () => handleReportMissing({ context }, data.logger),
|
|
269
264
|
})
|
|
270
265
|
}
|
|
@@ -284,11 +279,7 @@ async function handleToolCallRequest(
|
|
|
284
279
|
explicitContextIntent: buildFeedbackIntent(report),
|
|
285
280
|
omitCapturedParameters: true,
|
|
286
281
|
extraEventProperties: buildFeedbackEventProperties(report),
|
|
287
|
-
parameterOwnership:
|
|
288
|
-
data,
|
|
289
|
-
toolName,
|
|
290
|
-
getFeedbackToolDescriptor(feedbackOptions).inputSchema
|
|
291
|
-
),
|
|
282
|
+
parameterOwnership: getAnalyticsParameterOwnership(getFeedbackToolDescriptor(feedbackOptions).inputSchema),
|
|
292
283
|
execute: async () => handleFeedback(report, feedbackOptions, data.logger),
|
|
293
284
|
})
|
|
294
285
|
}
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
resolveCollectFeedbackOptions,
|
|
14
14
|
SEND_FEEDBACK_TOOL_NAME,
|
|
15
15
|
} from './feedback'
|
|
16
|
+
import { getAnalyticsParameterOwnership } from './analytics-parameters'
|
|
16
17
|
import { MCPAnalyticsEventType } from './event-types'
|
|
17
18
|
import { getServerTrackingData } from './internal'
|
|
18
19
|
import type { LoggerFn } from './logger'
|
|
@@ -24,7 +25,6 @@ import {
|
|
|
24
25
|
patchRequestHandlers,
|
|
25
26
|
registerFallbackRequestHandler,
|
|
26
27
|
captureToolCall,
|
|
27
|
-
getVirtualToolParameterOwnership,
|
|
28
28
|
isToolAdvertised,
|
|
29
29
|
type HandlerPatch,
|
|
30
30
|
} from './instrumentation'
|
|
@@ -107,11 +107,7 @@ async function handleToolCallRequest(
|
|
|
107
107
|
extra,
|
|
108
108
|
eventType: MCPAnalyticsEventType.mcpMissingCapability,
|
|
109
109
|
explicitContextIntent: context,
|
|
110
|
-
parameterOwnership:
|
|
111
|
-
data,
|
|
112
|
-
toolName,
|
|
113
|
-
getReportMissingToolDescriptor(toolName).inputSchema
|
|
114
|
-
),
|
|
110
|
+
parameterOwnership: getAnalyticsParameterOwnership(getReportMissingToolDescriptor(toolName).inputSchema),
|
|
115
111
|
execute: async () => handleReportMissing({ context }, data.logger),
|
|
116
112
|
})
|
|
117
113
|
}
|
|
@@ -131,11 +127,7 @@ async function handleToolCallRequest(
|
|
|
131
127
|
explicitContextIntent: buildFeedbackIntent(report),
|
|
132
128
|
omitCapturedParameters: true,
|
|
133
129
|
extraEventProperties: buildFeedbackEventProperties(report),
|
|
134
|
-
parameterOwnership:
|
|
135
|
-
data,
|
|
136
|
-
toolName,
|
|
137
|
-
getFeedbackToolDescriptor(feedbackOptions).inputSchema
|
|
138
|
-
),
|
|
130
|
+
parameterOwnership: getAnalyticsParameterOwnership(getFeedbackToolDescriptor(feedbackOptions).inputSchema),
|
|
139
131
|
execute: async () => handleFeedback(report, feedbackOptions, data.logger),
|
|
140
132
|
})
|
|
141
133
|
}
|
|
@@ -640,36 +640,6 @@ export function patchRequestHandlers(server: MCPServerLike, patches: Record<stri
|
|
|
640
640
|
}) as MCPServerLike['setRequestHandler']
|
|
641
641
|
}
|
|
642
642
|
|
|
643
|
-
/**
|
|
644
|
-
* Ownership for an SDK-owned virtual tool (`get_more_tools`, `send_feedback`),
|
|
645
|
-
* resolved from its own descriptor rather than the `tools/list` cache.
|
|
646
|
-
*
|
|
647
|
-
* A virtual-tool branch is only entered when the application does not advertise
|
|
648
|
-
* a tool by this name, so the descriptor is the SDK's own and what it declares
|
|
649
|
-
* is known statically. An instance that never served a listing — a per-request
|
|
650
|
-
* `McpServer`/`Server`, the topology in ADR-0011 — would otherwise read every
|
|
651
|
-
* injected parameter as not-ours and neither capture nor strip it.
|
|
652
|
-
*
|
|
653
|
-
* `conversation_id` still comes from the cache on purpose: resolving it here too
|
|
654
|
-
* would start minting a handle, and appending its prompt-back block, on
|
|
655
|
-
* instances that today mint none. That changes session anchoring (ADR-0004)
|
|
656
|
-
* rather than closing this gap.
|
|
657
|
-
*
|
|
658
|
-
* `virtualToolInputSchema` is required (not defaulted to one specific virtual
|
|
659
|
-
* tool's descriptor) so every call site names the tool it means; each caller
|
|
660
|
-
* passes its own descriptor's `inputSchema`.
|
|
661
|
-
*/
|
|
662
|
-
export function getVirtualToolParameterOwnership(
|
|
663
|
-
data: MCPAnalyticsData,
|
|
664
|
-
toolName: string,
|
|
665
|
-
virtualToolInputSchema: unknown
|
|
666
|
-
): AnalyticsParameterOwnership {
|
|
667
|
-
return {
|
|
668
|
-
...getAnalyticsParameterOwnership(virtualToolInputSchema),
|
|
669
|
-
conversationId: data.toolAnalyticsParameterOwnership.get(toolName)?.conversationId === true,
|
|
670
|
-
}
|
|
671
|
-
}
|
|
672
|
-
|
|
673
643
|
/**
|
|
674
644
|
* Checks the server's raw listing for a real owner of a candidate virtual tool.
|
|
675
645
|
* This does not depend on a previous client request and does not call the
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '0.16.
|
|
1
|
+
export const version = '0.16.4'
|