@posthog/mcp 0.10.9 → 0.11.1
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 +39 -0
- package/dist/extensions/capture.d.ts.map +1 -1
- package/dist/extensions/capture.js +2 -0
- package/dist/extensions/capture.mjs +2 -0
- package/dist/extensions/compatibility.d.ts.map +1 -1
- package/dist/extensions/compatibility.js +14 -18
- package/dist/extensions/compatibility.mjs +10 -14
- package/dist/extensions/constants.d.ts +2 -0
- package/dist/extensions/constants.d.ts.map +1 -1
- package/dist/extensions/constants.js +3 -1
- package/dist/extensions/constants.mjs +3 -1
- package/dist/extensions/context-parameters.d.ts.map +1 -1
- package/dist/extensions/conversation-id.d.ts +2 -13
- package/dist/extensions/conversation-id.d.ts.map +1 -1
- package/dist/extensions/detect.d.ts +45 -0
- package/dist/extensions/detect.d.ts.map +1 -0
- package/dist/extensions/detect.js +90 -0
- package/dist/extensions/detect.mjs +35 -0
- package/dist/extensions/headers.d.ts +33 -0
- package/dist/extensions/headers.d.ts.map +1 -0
- package/dist/extensions/headers.js +54 -0
- package/dist/extensions/headers.mjs +17 -0
- package/dist/extensions/instrument-highlevel.d.ts.map +1 -1
- package/dist/extensions/instrument-lowlevel.d.ts.map +1 -1
- package/dist/extensions/instrumentation.d.ts +7 -0
- package/dist/extensions/instrumentation.d.ts.map +1 -1
- package/dist/extensions/instrumentation.js +7 -2
- package/dist/extensions/instrumentation.mjs +7 -2
- package/dist/extensions/internal.d.ts.map +1 -1
- package/dist/extensions/internal.js +2 -0
- package/dist/extensions/internal.mjs +2 -0
- package/dist/extensions/output-instructions.d.ts +6 -8
- package/dist/extensions/output-instructions.d.ts.map +1 -1
- package/dist/extensions/posthog-events.js +4 -0
- package/dist/extensions/posthog-events.mjs +4 -0
- package/dist/extensions/posthog-mcp.d.ts.map +1 -1
- package/dist/extensions/posthog-mcp.js +3 -0
- package/dist/extensions/posthog-mcp.mjs +3 -0
- package/dist/extensions/request-headers.d.ts +36 -0
- package/dist/extensions/request-headers.d.ts.map +1 -0
- package/dist/extensions/request-headers.js +62 -0
- package/dist/extensions/request-headers.mjs +28 -0
- package/dist/extensions/session-token.d.ts.map +1 -1
- package/dist/extensions/session-token.js +5 -14
- package/dist/extensions/session-token.mjs +2 -11
- package/dist/extensions/session.d.ts +4 -3
- package/dist/extensions/session.d.ts.map +1 -1
- package/dist/extensions/session.js +2 -1
- package/dist/extensions/session.mjs +2 -1
- package/dist/extensions/sink.d.ts +4 -6
- package/dist/extensions/sink.d.ts.map +1 -1
- package/dist/extensions/tools.d.ts.map +1 -1
- package/dist/extensions/transport-identity.d.ts +64 -0
- package/dist/extensions/transport-identity.d.ts.map +1 -0
- package/dist/extensions/transport-identity.js +64 -0
- package/dist/extensions/transport-identity.mjs +21 -0
- package/dist/extensions/truncation.d.ts.map +1 -1
- package/dist/extensions/truncation.js +2 -0
- package/dist/extensions/truncation.mjs +2 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -7
- package/dist/index.mjs +2 -1
- package/dist/types.d.ts +52 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.mjs +1 -1
- package/package.json +2 -2
- package/src/extensions/capture.ts +6 -0
- package/src/extensions/compatibility.ts +25 -33
- package/src/extensions/constants.ts +2 -0
- package/src/extensions/context-parameters.ts +3 -11
- package/src/extensions/conversation-id.ts +5 -17
- package/src/extensions/detect.ts +78 -0
- package/src/extensions/headers.ts +52 -0
- package/src/extensions/instrument-highlevel.ts +0 -1
- package/src/extensions/instrument-lowlevel.ts +0 -1
- package/src/extensions/instrumentation.ts +32 -39
- package/src/extensions/internal.ts +6 -5
- package/src/extensions/output-instructions.ts +6 -8
- package/src/extensions/posthog-events.ts +14 -0
- package/src/extensions/posthog-mcp.ts +7 -5
- package/src/extensions/request-headers.ts +76 -0
- package/src/extensions/session-token.ts +3 -15
- package/src/extensions/session.ts +23 -36
- package/src/extensions/sink.ts +4 -6
- package/src/extensions/tools.ts +3 -6
- package/src/extensions/transport-identity.ts +100 -0
- package/src/extensions/truncation.ts +4 -0
- package/src/index.ts +4 -0
- package/src/types.ts +51 -0
- package/src/version.ts +1 -1
package/README.md
CHANGED
|
@@ -67,6 +67,45 @@ if (body?.method === 'initialize' && !req.headers[MCP_SESSION_HEADER]) {
|
|
|
67
67
|
|
|
68
68
|
Details: [docs/ARCHITECTURE.md §4](./docs/ARCHITECTURE.md).
|
|
69
69
|
|
|
70
|
+
## MCP TypeScript SDK v2
|
|
71
|
+
|
|
72
|
+
`instrument()` works on both SDK majors — `@modelcontextprotocol/sdk` v1 and
|
|
73
|
+
`@modelcontextprotocol/{core,server,client}` v2 — and on both the high-level `McpServer` and the
|
|
74
|
+
low-level `Server`. Shapes are detected at runtime, so neither major is a dependency here.
|
|
75
|
+
|
|
76
|
+
### Reading request headers in a callback
|
|
77
|
+
|
|
78
|
+
If your `identify`, `intentFallback`, `eventProperties` or `beforeSend` reads HTTP headers, it has
|
|
79
|
+
to change. The two majors put the request in different places and in different shapes: v1 attaches
|
|
80
|
+
a plain object at `extra.requestInfo.headers`, v2 attaches the WHATWG `Request` at `extra.http.req`,
|
|
81
|
+
whose `headers` only answers to `.get()`. A v1-shaped read returns `undefined` on v2 — an
|
|
82
|
+
`identify()` written that way returns `null` and every event goes anonymous.
|
|
83
|
+
|
|
84
|
+
The SDK hands your callback whatever the MCP SDK handed it, unchanged; it does **not** fake a v1
|
|
85
|
+
shape on v2, because a partially synthesised `requestInfo` is a more convincing lie than an absent
|
|
86
|
+
one. Read headers through the exported helper instead, which handles both majors, lowercases keys,
|
|
87
|
+
and duck-types `Headers` so it also works on edge runtimes:
|
|
88
|
+
|
|
89
|
+
```ts
|
|
90
|
+
import { getRequestHeaders } from '@posthog/mcp'
|
|
91
|
+
|
|
92
|
+
identify: async (request, extra) => {
|
|
93
|
+
const auth = getRequestHeaders(extra)?.['authorization'] // v1 and v2
|
|
94
|
+
// ...
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### If you switched to `instrument(server.server)`
|
|
99
|
+
|
|
100
|
+
Before v2 support landed, the compatibility gate rejected high-level v2 servers, and the usual
|
|
101
|
+
workaround was to instrument the underlying low-level server. `instrument(server)` now works, so
|
|
102
|
+
you can go back to the documented call.
|
|
103
|
+
|
|
104
|
+
Whether the workaround costs you anything depends on your stack: instrumenting the low-level server
|
|
105
|
+
skips the high-level tool registry, so tool descriptions and callback-level wrapping come only from
|
|
106
|
+
what is advertised over `tools/list`. If your framework never calls `registerTool()` — `@rekog/mcp-nest`
|
|
107
|
+
does not — the registry is empty and the two calls behave the same.
|
|
108
|
+
|
|
70
109
|
## Developing locally
|
|
71
110
|
|
|
72
111
|
To test local changes in a consumer app (e.g. a dummy MCP server), symlink **both**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capture.d.ts","sourceRoot":"","sources":["../../src/extensions/capture.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAGpE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAGxC;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,aAAa,EACrB,UAAU,EAAE,QAAQ,EACpB,MAAM,EAAE,QAAQ,EAChB,kBAAkB,CAAC,EAAE,WAAW,GAC/B,OAAO,CAAC,IAAI,CAAC,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"capture.d.ts","sourceRoot":"","sources":["../../src/extensions/capture.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAGpE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAGxC;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,aAAa,EACrB,UAAU,EAAE,QAAQ,EACpB,MAAM,EAAE,QAAQ,EAChB,kBAAkB,CAAC,EAAE,WAAW,GAC/B,OAAO,CAAC,IAAI,CAAC,GAAG,SAAS,CA0E3B"}
|
|
@@ -50,6 +50,8 @@ function captureEvent(server, eventInput, logger, requestAttribution) {
|
|
|
50
50
|
serverVersion: sessionInfo.serverVersion,
|
|
51
51
|
clientName: eventInput.clientName ?? sessionInfo.clientName,
|
|
52
52
|
clientVersion: eventInput.clientVersion ?? sessionInfo.clientVersion,
|
|
53
|
+
clientUserAgent: eventInput.clientUserAgent,
|
|
54
|
+
vendorClient: eventInput.vendorClient,
|
|
53
55
|
identifyActorGivenId: sessionInfo.identifyActorGivenId,
|
|
54
56
|
identifyActorData: sessionInfo.identifyActorData,
|
|
55
57
|
groups: sessionInfo.identifyActorGroups,
|
|
@@ -22,6 +22,8 @@ function captureEvent(server, eventInput, logger, requestAttribution) {
|
|
|
22
22
|
serverVersion: sessionInfo.serverVersion,
|
|
23
23
|
clientName: eventInput.clientName ?? sessionInfo.clientName,
|
|
24
24
|
clientVersion: eventInput.clientVersion ?? sessionInfo.clientVersion,
|
|
25
|
+
clientUserAgent: eventInput.clientUserAgent,
|
|
26
|
+
vendorClient: eventInput.vendorClient,
|
|
25
27
|
identifyActorGivenId: sessionInfo.identifyActorGivenId,
|
|
26
28
|
identifyActorData: sessionInfo.identifyActorData,
|
|
27
29
|
groups: sessionInfo.identifyActorGroups,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compatibility.d.ts","sourceRoot":"","sources":["../../src/extensions/compatibility.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"compatibility.d.ts","sourceRoot":"","sources":["../../src/extensions/compatibility.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAWrE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAExC,KAAK,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAE3C;;;;;;;;;;;GAWG;AAEH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,QAAQ,GAAG,IAAI,CAI9D;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,YAAY,GAAG;IAAE,MAAM,EAAE,YAAY,CAAA;CAAE,CAEpG;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,YAAY,CAExE;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,GAAG,aAAa,GAAG,sBAAsB,CAiChH;AAyCD,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAanE"}
|
|
@@ -24,20 +24,21 @@ var __webpack_require__ = {};
|
|
|
24
24
|
var __webpack_exports__ = {};
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
getMCPCompatibleErrorMessage: ()=>getMCPCompatibleErrorMessage,
|
|
28
|
-
isCompatibleServerType: ()=>isCompatibleServerType,
|
|
29
|
-
isHighLevelServer: ()=>isHighLevelServer,
|
|
30
27
|
isLowLevelServer: ()=>isLowLevelServer,
|
|
31
|
-
|
|
28
|
+
isHighLevelServer: ()=>isHighLevelServer,
|
|
29
|
+
logCompatibilityWarning: ()=>logCompatibilityWarning,
|
|
30
|
+
isCompatibleServerType: ()=>isCompatibleServerType,
|
|
31
|
+
getMCPCompatibleErrorMessage: ()=>getMCPCompatibleErrorMessage
|
|
32
32
|
});
|
|
33
|
+
const external_detect_js_namespaceObject = require("./detect.js");
|
|
33
34
|
function logCompatibilityWarning(logger) {
|
|
34
35
|
logger('PostHog MCP analytics SDK Compatibility: This version only supports Model Context Protocol TypeScript SDK v1.11 and above. Please upgrade if using an older version.');
|
|
35
36
|
}
|
|
36
37
|
function isHighLevelServer(server) {
|
|
37
|
-
return
|
|
38
|
+
return (0, external_detect_js_namespaceObject.hasNestedLowLevelServer)(server);
|
|
38
39
|
}
|
|
39
40
|
function isLowLevelServer(server) {
|
|
40
|
-
return
|
|
41
|
+
return (0, external_detect_js_namespaceObject.isBareServerShape)(server);
|
|
41
42
|
}
|
|
42
43
|
function isCompatibleServerType(server, logger) {
|
|
43
44
|
if (!server || 'object' != typeof server) {
|
|
@@ -45,13 +46,13 @@ function isCompatibleServerType(server, logger) {
|
|
|
45
46
|
throw new Error("PostHog MCP analytics SDK compatibility error: Server must be an object. Ensure you're using MCP SDK v1.11 or higher.");
|
|
46
47
|
}
|
|
47
48
|
if (isHighLevelServer(server)) {
|
|
48
|
-
if (!
|
|
49
|
+
if (!(0, external_detect_js_namespaceObject.hasToolRegistry)(server)) {
|
|
49
50
|
logCompatibilityWarning(logger);
|
|
50
51
|
throw new Error('PostHog MCP analytics SDK compatibility error: High-level server must have _registeredTools object. This requires MCP SDK v1.11 or higher.');
|
|
51
52
|
}
|
|
52
|
-
if (
|
|
53
|
+
if (!(0, external_detect_js_namespaceObject.canRegisterTools)(server)) {
|
|
53
54
|
logCompatibilityWarning(logger);
|
|
54
|
-
throw new Error('PostHog MCP analytics SDK compatibility error: High-level server must have tool() method. This requires MCP SDK v1.11 or higher.');
|
|
55
|
+
throw new Error('PostHog MCP analytics SDK compatibility error: High-level server must have a registerTool() or tool() method. This requires MCP SDK v1.11 or higher.');
|
|
55
56
|
}
|
|
56
57
|
const targetServer = server.server;
|
|
57
58
|
validateLowLevelServer(targetServer, logger);
|
|
@@ -65,24 +66,19 @@ function validateLowLevelServer(server, logger) {
|
|
|
65
66
|
logCompatibilityWarning(logger);
|
|
66
67
|
throw new Error("PostHog MCP analytics SDK compatibility error: Server must be an object. Ensure you're using MCP SDK v1.11 or higher.");
|
|
67
68
|
}
|
|
68
|
-
|
|
69
|
-
if ('function' != typeof serverRecord.setRequestHandler) {
|
|
69
|
+
if (!(0, external_detect_js_namespaceObject.canSetRequestHandler)(server)) {
|
|
70
70
|
logCompatibilityWarning(logger);
|
|
71
71
|
throw new Error('PostHog MCP analytics SDK compatibility error: Server must have a setRequestHandler method. This requires MCP SDK v1.11 or higher.');
|
|
72
72
|
}
|
|
73
|
-
if (!(
|
|
73
|
+
if (!(0, external_detect_js_namespaceObject.hasRequestHandlerMap)(server)) {
|
|
74
74
|
logCompatibilityWarning(logger);
|
|
75
75
|
throw new Error('PostHog MCP analytics SDK compatibility error: Server._requestHandlers is not accessible. This requires MCP SDK v1.11 or higher.');
|
|
76
76
|
}
|
|
77
|
-
if (
|
|
78
|
-
logCompatibilityWarning(logger);
|
|
79
|
-
throw new Error('PostHog MCP analytics SDK compatibility error: Server._requestHandlers must be a Map with a get method. This requires MCP SDK v1.11 or higher.');
|
|
80
|
-
}
|
|
81
|
-
if ('function' != typeof serverRecord.getClientVersion) {
|
|
77
|
+
if (!(0, external_detect_js_namespaceObject.hasClientVersionAccessor)(server)) {
|
|
82
78
|
logCompatibilityWarning(logger);
|
|
83
79
|
throw new Error('PostHog MCP analytics SDK compatibility error: Server.getClientVersion must be a function. This requires MCP SDK v1.11 or higher.');
|
|
84
80
|
}
|
|
85
|
-
if (!
|
|
81
|
+
if (!(0, external_detect_js_namespaceObject.hasServerInfo)(server)) {
|
|
86
82
|
logCompatibilityWarning(logger);
|
|
87
83
|
throw new Error('PostHog MCP analytics SDK compatibility error: Server._serverInfo is not accessible or missing name. This requires MCP SDK v1.11 or higher.');
|
|
88
84
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import { canRegisterTools, canSetRequestHandler, hasClientVersionAccessor, hasNestedLowLevelServer, hasRequestHandlerMap, hasServerInfo, hasToolRegistry, isBareServerShape } from "./detect.mjs";
|
|
1
2
|
function logCompatibilityWarning(logger) {
|
|
2
3
|
logger('PostHog MCP analytics SDK Compatibility: This version only supports Model Context Protocol TypeScript SDK v1.11 and above. Please upgrade if using an older version.');
|
|
3
4
|
}
|
|
4
5
|
function isHighLevelServer(server) {
|
|
5
|
-
return
|
|
6
|
+
return hasNestedLowLevelServer(server);
|
|
6
7
|
}
|
|
7
8
|
function isLowLevelServer(server) {
|
|
8
|
-
return
|
|
9
|
+
return isBareServerShape(server);
|
|
9
10
|
}
|
|
10
11
|
function isCompatibleServerType(server, logger) {
|
|
11
12
|
if (!server || 'object' != typeof server) {
|
|
@@ -13,13 +14,13 @@ function isCompatibleServerType(server, logger) {
|
|
|
13
14
|
throw new Error("PostHog MCP analytics SDK compatibility error: Server must be an object. Ensure you're using MCP SDK v1.11 or higher.");
|
|
14
15
|
}
|
|
15
16
|
if (isHighLevelServer(server)) {
|
|
16
|
-
if (!server
|
|
17
|
+
if (!hasToolRegistry(server)) {
|
|
17
18
|
logCompatibilityWarning(logger);
|
|
18
19
|
throw new Error('PostHog MCP analytics SDK compatibility error: High-level server must have _registeredTools object. This requires MCP SDK v1.11 or higher.');
|
|
19
20
|
}
|
|
20
|
-
if (
|
|
21
|
+
if (!canRegisterTools(server)) {
|
|
21
22
|
logCompatibilityWarning(logger);
|
|
22
|
-
throw new Error('PostHog MCP analytics SDK compatibility error: High-level server must have tool() method. This requires MCP SDK v1.11 or higher.');
|
|
23
|
+
throw new Error('PostHog MCP analytics SDK compatibility error: High-level server must have a registerTool() or tool() method. This requires MCP SDK v1.11 or higher.');
|
|
23
24
|
}
|
|
24
25
|
const targetServer = server.server;
|
|
25
26
|
validateLowLevelServer(targetServer, logger);
|
|
@@ -33,24 +34,19 @@ function validateLowLevelServer(server, logger) {
|
|
|
33
34
|
logCompatibilityWarning(logger);
|
|
34
35
|
throw new Error("PostHog MCP analytics SDK compatibility error: Server must be an object. Ensure you're using MCP SDK v1.11 or higher.");
|
|
35
36
|
}
|
|
36
|
-
|
|
37
|
-
if ('function' != typeof serverRecord.setRequestHandler) {
|
|
37
|
+
if (!canSetRequestHandler(server)) {
|
|
38
38
|
logCompatibilityWarning(logger);
|
|
39
39
|
throw new Error('PostHog MCP analytics SDK compatibility error: Server must have a setRequestHandler method. This requires MCP SDK v1.11 or higher.');
|
|
40
40
|
}
|
|
41
|
-
if (!(
|
|
41
|
+
if (!hasRequestHandlerMap(server)) {
|
|
42
42
|
logCompatibilityWarning(logger);
|
|
43
43
|
throw new Error('PostHog MCP analytics SDK compatibility error: Server._requestHandlers is not accessible. This requires MCP SDK v1.11 or higher.');
|
|
44
44
|
}
|
|
45
|
-
if (
|
|
46
|
-
logCompatibilityWarning(logger);
|
|
47
|
-
throw new Error('PostHog MCP analytics SDK compatibility error: Server._requestHandlers must be a Map with a get method. This requires MCP SDK v1.11 or higher.');
|
|
48
|
-
}
|
|
49
|
-
if ('function' != typeof serverRecord.getClientVersion) {
|
|
45
|
+
if (!hasClientVersionAccessor(server)) {
|
|
50
46
|
logCompatibilityWarning(logger);
|
|
51
47
|
throw new Error('PostHog MCP analytics SDK compatibility error: Server.getClientVersion must be a function. This requires MCP SDK v1.11 or higher.');
|
|
52
48
|
}
|
|
53
|
-
if (!
|
|
49
|
+
if (!hasServerInfo(server)) {
|
|
54
50
|
logCompatibilityWarning(logger);
|
|
55
51
|
throw new Error('PostHog MCP analytics SDK compatibility error: Server._serverInfo is not accessible or missing name. This requires MCP SDK v1.11 or higher.');
|
|
56
52
|
}
|
|
@@ -19,6 +19,7 @@ export declare const PostHogMCPAnalyticsEvent: {
|
|
|
19
19
|
export type PostHogMCPAnalyticsEvent = (typeof PostHogMCPAnalyticsEvent)[keyof typeof PostHogMCPAnalyticsEvent];
|
|
20
20
|
export declare const PostHogMCPAnalyticsProperty: {
|
|
21
21
|
readonly ClientName: "$mcp_client_name";
|
|
22
|
+
readonly ClientUserAgent: "$mcp_client_user_agent";
|
|
22
23
|
readonly ClientVersion: "$mcp_client_version";
|
|
23
24
|
readonly ConversationId: "$mcp_conversation_id";
|
|
24
25
|
readonly DurationMs: "$mcp_duration_ms";
|
|
@@ -39,6 +40,7 @@ export declare const PostHogMCPAnalyticsProperty: {
|
|
|
39
40
|
readonly ToolCategory: "$mcp_tool_category";
|
|
40
41
|
readonly ToolDescription: "$mcp_tool_description";
|
|
41
42
|
readonly ToolName: "$mcp_tool_name";
|
|
43
|
+
readonly VendorClient: "$mcp_vendor_client";
|
|
42
44
|
};
|
|
43
45
|
export type PostHogMCPAnalyticsProperty = (typeof PostHogMCPAnalyticsProperty)[keyof typeof PostHogMCPAnalyticsProperty];
|
|
44
46
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/extensions/constants.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,6BAA6B,KAAK,CAAA;AAE/C,eAAO,MAAM,qCAAqC,2hBAAyhB,CAAA;AAE3kB,eAAO,MAAM,mCAAmC,4LACsI,CAAA;AAEtL,eAAO,MAAM,4BAA4B,0BAA0B,CAAA;AAMnE,eAAO,MAAM,oBAAoB,qBAAqB,CAAA;AAItD,eAAO,MAAM,wBAAwB;;;;;;;;;;;;CAY3B,CAAA;AAEV,MAAM,MAAM,wBAAwB,GAAG,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,OAAO,wBAAwB,CAAC,CAAA;AAE/G,eAAO,MAAM,2BAA2B
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/extensions/constants.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,6BAA6B,KAAK,CAAA;AAE/C,eAAO,MAAM,qCAAqC,2hBAAyhB,CAAA;AAE3kB,eAAO,MAAM,mCAAmC,4LACsI,CAAA;AAEtL,eAAO,MAAM,4BAA4B,0BAA0B,CAAA;AAMnE,eAAO,MAAM,oBAAoB,qBAAqB,CAAA;AAItD,eAAO,MAAM,wBAAwB;;;;;;;;;;;;CAY3B,CAAA;AAEV,MAAM,MAAM,wBAAwB,GAAG,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,OAAO,wBAAwB,CAAC,CAAA;AAE/G,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;CAwB9B,CAAA;AAEV,MAAM,MAAM,2BAA2B,GAAG,CAAC,OAAO,2BAA2B,CAAC,CAAC,MAAM,OAAO,2BAA2B,CAAC,CAAA"}
|
|
@@ -52,6 +52,7 @@ const PostHogMCPAnalyticsEvent = {
|
|
|
52
52
|
};
|
|
53
53
|
const PostHogMCPAnalyticsProperty = {
|
|
54
54
|
ClientName: '$mcp_client_name',
|
|
55
|
+
ClientUserAgent: '$mcp_client_user_agent',
|
|
55
56
|
ClientVersion: '$mcp_client_version',
|
|
56
57
|
ConversationId: '$mcp_conversation_id',
|
|
57
58
|
DurationMs: '$mcp_duration_ms',
|
|
@@ -71,7 +72,8 @@ const PostHogMCPAnalyticsProperty = {
|
|
|
71
72
|
Source: '$mcp_source',
|
|
72
73
|
ToolCategory: '$mcp_tool_category',
|
|
73
74
|
ToolDescription: "$mcp_tool_description",
|
|
74
|
-
ToolName: '$mcp_tool_name'
|
|
75
|
+
ToolName: '$mcp_tool_name',
|
|
76
|
+
VendorClient: '$mcp_vendor_client'
|
|
75
77
|
};
|
|
76
78
|
exports.DEFAULT_CONTEXT_PARAMETER_DESCRIPTION = __webpack_exports__.DEFAULT_CONTEXT_PARAMETER_DESCRIPTION;
|
|
77
79
|
exports.DEFAULT_CONVERSATION_ID_DESCRIPTION = __webpack_exports__.DEFAULT_CONVERSATION_ID_DESCRIPTION;
|
|
@@ -18,6 +18,7 @@ const PostHogMCPAnalyticsEvent = {
|
|
|
18
18
|
};
|
|
19
19
|
const PostHogMCPAnalyticsProperty = {
|
|
20
20
|
ClientName: '$mcp_client_name',
|
|
21
|
+
ClientUserAgent: '$mcp_client_user_agent',
|
|
21
22
|
ClientVersion: '$mcp_client_version',
|
|
22
23
|
ConversationId: '$mcp_conversation_id',
|
|
23
24
|
DurationMs: '$mcp_duration_ms',
|
|
@@ -37,6 +38,7 @@ const PostHogMCPAnalyticsProperty = {
|
|
|
37
38
|
Source: '$mcp_source',
|
|
38
39
|
ToolCategory: '$mcp_tool_category',
|
|
39
40
|
ToolDescription: "$mcp_tool_description",
|
|
40
|
-
ToolName: '$mcp_tool_name'
|
|
41
|
+
ToolName: '$mcp_tool_name',
|
|
42
|
+
VendorClient: '$mcp_vendor_client'
|
|
41
43
|
};
|
|
42
44
|
export { DEFAULT_CONTEXT_PARAMETER_DESCRIPTION, DEFAULT_CONVERSATION_ID_DESCRIPTION, INACTIVITY_TIMEOUT_IN_MINUTES, POSTHOG_MCP_ANALYTICS_SOURCE, POSTHOG_MCP_LIB_NAME, PostHogMCPAnalyticsEvent, PostHogMCPAnalyticsProperty };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-parameters.d.ts","sourceRoot":"","sources":["../../src/extensions/context-parameters.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AACnD,OAAO,EAGL,KAAK,6BAA6B,EACnC,MAAM,wBAAwB,CAAA;AAE/B,OAAO,EAAO,KAAK,QAAQ,EAAE,MAAM,UAAU,CAAA;AAE7C,MAAM,WAAW,qBAAqB;IACpC,WAAW,CAAC,EAAE,6BAA6B,CAAA;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,mBAAmB,CAAC,SAAS,CAAC,GAAG,OAAO,CAEjF;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,mBAAmB,CAAC,SAAS,CAAC,GAAG,MAAM,GAAG,SAAS,CAEjG;AAED;;;;;;;;;GASG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,SAAS,qBAAqB,EAC3E,IAAI,EAAE,KAAK,EACX,0BAA0B,CAAC,EAAE,MAAM,EACnC,MAAM,GAAE,QAAc,GACrB,KAAK,
|
|
1
|
+
{"version":3,"file":"context-parameters.d.ts","sourceRoot":"","sources":["../../src/extensions/context-parameters.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AACnD,OAAO,EAGL,KAAK,6BAA6B,EACnC,MAAM,wBAAwB,CAAA;AAE/B,OAAO,EAAO,KAAK,QAAQ,EAAE,MAAM,UAAU,CAAA;AAE7C,MAAM,WAAW,qBAAqB;IACpC,WAAW,CAAC,EAAE,6BAA6B,CAAA;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,mBAAmB,CAAC,SAAS,CAAC,GAAG,OAAO,CAEjF;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,mBAAmB,CAAC,SAAS,CAAC,GAAG,MAAM,GAAG,SAAS,CAEjG;AAED;;;;;;;;;GASG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,SAAS,qBAAqB,EAC3E,IAAI,EAAE,KAAK,EACX,0BAA0B,CAAC,EAAE,MAAM,EACnC,MAAM,GAAE,QAAc,GACrB,KAAK,CAqDP;AAED,wBAAgB,0BAA0B,CAAC,KAAK,SAAS,qBAAqB,EAC5E,KAAK,EAAE,KAAK,EAAE,EACd,0BAA0B,CAAC,EAAE,MAAM,EACnC,MAAM,GAAE,QAAc,GACrB,KAAK,EAAE,CAET"}
|
|
@@ -31,20 +31,9 @@ export type ConversationIdResolution = {
|
|
|
31
31
|
* derivation is deterministic so that two pods agree — which also means two
|
|
32
32
|
* *callers* sending the same string land in the same session. The strings agents
|
|
33
33
|
* invent are not random (`conv-1`, `1`, `session`), so trusting them verbatim
|
|
34
|
-
* would silently merge unrelated conversations, potentially across users.
|
|
35
|
-
*
|
|
36
|
-
* A compliant agent echoes the uuidv7 we minted and is unaffected. Anything else
|
|
37
|
-
* is treated exactly as if the handle were absent: mint, and prompt back. Shape
|
|
34
|
+
* would silently merge unrelated conversations, potentially across users. Shape
|
|
38
35
|
* rather than a registry of issued ids, because a per-request server has no
|
|
39
|
-
* memory of what it minted.
|
|
40
|
-
*
|
|
41
|
-
* This narrows the problem, it does not prove provenance: a caller supplying a
|
|
42
|
-
* well-formed uuidv7 is trusted, so two that pick the *same* one still merge. That
|
|
43
|
-
* residue is far smaller than the case it replaces — an agent ignoring the
|
|
44
|
-
* parameter description reaches for `conv-1` or `1`, not a conforming uuidv7 — and
|
|
45
|
-
* closing it needs a signed handle, i.e. a secret shared by every pod. Worth doing
|
|
46
|
-
* if this ever anchors something security-bearing; `$session_id` is an analytics
|
|
47
|
-
* grouping key, so it does not today.
|
|
36
|
+
* memory of what it minted. Residual risk and why it's accepted: ADR-0004.
|
|
48
37
|
*/
|
|
49
38
|
export declare function resolveConversationId(enabled: boolean, args: unknown): ConversationIdResolution;
|
|
50
39
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation-id.d.ts","sourceRoot":"","sources":["../../src/extensions/conversation-id.ts"],"names":[],"mappings":"AAMA,OAAO,EAGL,KAAK,6BAA6B,EACnC,MAAM,wBAAwB,CAAA;AAE/B,OAAO,EAAO,KAAK,QAAQ,EAAE,MAAM,UAAU,CAAA;AAE7C,eAAO,MAAM,0BAA0B,oBAAoB,CAAA;AAE3D,MAAM,WAAW,4BAA4B;IAC3C,WAAW,CAAC,EAAE,6BAA6B,CAAA;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB;AAED,wBAAgB,uBAAuB,CAAC,KAAK,SAAS,4BAA4B,EAChF,IAAI,EAAE,KAAK,EACX,MAAM,GAAE,QAAc,GACrB,KAAK,CA4CP;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,SAAS,4BAA4B,EACjF,KAAK,EAAE,KAAK,EAAE,EACd,MAAM,GAAE,QAAc,GACrB,KAAK,EAAE,CAET;AAQD,MAAM,MAAM,wBAAwB,GAChC;IAAE,MAAM,EAAE,KAAK,CAAC;IAAC,cAAc,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,GACrD;IAAE,MAAM,EAAE,IAAI,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAAE,CAAA;AAE5C
|
|
1
|
+
{"version":3,"file":"conversation-id.d.ts","sourceRoot":"","sources":["../../src/extensions/conversation-id.ts"],"names":[],"mappings":"AAMA,OAAO,EAGL,KAAK,6BAA6B,EACnC,MAAM,wBAAwB,CAAA;AAE/B,OAAO,EAAO,KAAK,QAAQ,EAAE,MAAM,UAAU,CAAA;AAE7C,eAAO,MAAM,0BAA0B,oBAAoB,CAAA;AAE3D,MAAM,WAAW,4BAA4B;IAC3C,WAAW,CAAC,EAAE,6BAA6B,CAAA;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB;AAED,wBAAgB,uBAAuB,CAAC,KAAK,SAAS,4BAA4B,EAChF,IAAI,EAAE,KAAK,EACX,MAAM,GAAE,QAAc,GACrB,KAAK,CA4CP;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,SAAS,4BAA4B,EACjF,KAAK,EAAE,KAAK,EAAE,EACd,MAAM,GAAE,QAAc,GACrB,KAAK,EAAE,CAET;AAQD,MAAM,MAAM,wBAAwB,GAChC;IAAE,MAAM,EAAE,KAAK,CAAC;IAAC,cAAc,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,GACrD;IAAE,MAAM,EAAE,IAAI,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAAE,CAAA;AAE5C;;;;;;;;;;;;;GAaG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,GAAG,wBAAwB,CAY/F;AAED;;;;;;;;GAQG;AACH,wBAAgB,iCAAiC,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAK1E;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAUvE;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAM1D;AAED,wBAAgB,6BAA6B,CAAC,cAAc,EAAE,MAAM,GAAG;IACrE,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;CACb,CAKA;AAED,wBAAgB,8BAA8B,CAAC,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO,CAS/F"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structural feature probes.
|
|
3
|
+
*
|
|
4
|
+
* Every question about the shape of a server object is answered here, by
|
|
5
|
+
* duck-typing the object in front of us — never by reading a package version or
|
|
6
|
+
* a protocol constant. Two reasons this is a rule and not a preference:
|
|
7
|
+
*
|
|
8
|
+
* - The two SDK majors expose the same capability under different names (v1's
|
|
9
|
+
* `.tool()` vs v2's `.registerTool()`), so "which SDK is installed" answers a
|
|
10
|
+
* different question than "can this object register a tool".
|
|
11
|
+
* - A single v2 server serves both protocol eras, request by request, so no
|
|
12
|
+
* module-level constant describes it. v2's exported `LATEST_PROTOCOL_VERSION`
|
|
13
|
+
* is `2025-11-25`.
|
|
14
|
+
*
|
|
15
|
+
* Nothing here imports `@modelcontextprotocol/*`; that boundary is pinned by
|
|
16
|
+
* `sdk-import-boundary.test.ts`.
|
|
17
|
+
*/
|
|
18
|
+
type UnknownRecord = Record<string, unknown>;
|
|
19
|
+
/** A high-level `McpServer` wrapper: it holds the low-level server on `.server`. */
|
|
20
|
+
export declare function hasNestedLowLevelServer(server: unknown): server is UnknownRecord & {
|
|
21
|
+
server: UnknownRecord;
|
|
22
|
+
};
|
|
23
|
+
/** No `.server` property, so the object is itself the low-level `Server`. */
|
|
24
|
+
export declare function isBareServerShape(server: unknown): boolean;
|
|
25
|
+
/** The high-level registry we read tool metadata from and wrap callbacks in. */
|
|
26
|
+
export declare function hasToolRegistry(server: unknown): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* The object can register a tool.
|
|
29
|
+
*
|
|
30
|
+
* v1 offers both `tool()` and `registerTool()`; v2 dropped the deprecated
|
|
31
|
+
* `tool()` and keeps only `registerTool()`. Requiring `tool()` specifically is
|
|
32
|
+
* what made `instrument()` reject every v2 high-level server — and, because
|
|
33
|
+
* `instrument()` swallows compatibility errors, reject it silently.
|
|
34
|
+
*/
|
|
35
|
+
export declare function canRegisterTools(server: unknown): boolean;
|
|
36
|
+
/** Handler registration, which we patch to wrap late registrations. */
|
|
37
|
+
export declare function canSetRequestHandler(server: unknown): boolean;
|
|
38
|
+
/** The live handler map we read and write directly. A real `Map` on both majors. */
|
|
39
|
+
export declare function hasRequestHandlerMap(server: unknown): boolean;
|
|
40
|
+
/** `getClientVersion()` — still present on v2, and a link in B1's identity chain. */
|
|
41
|
+
export declare function hasClientVersionAccessor(server: unknown): boolean;
|
|
42
|
+
/** `_serverInfo`, which names the server on every event. */
|
|
43
|
+
export declare function hasServerInfo(server: unknown): boolean;
|
|
44
|
+
export {};
|
|
45
|
+
//# sourceMappingURL=detect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect.d.ts","sourceRoot":"","sources":["../../src/extensions/detect.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,KAAK,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAU5C,oFAAoF;AACpF,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,aAAa,GAAG;IAAE,MAAM,EAAE,aAAa,CAAA;CAAE,CAG5G;AAED,6EAA6E;AAC7E,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAG1D;AAED,gFAAgF;AAChF,wBAAgB,eAAe,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAExD;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAEzD;AAED,uEAAuE;AACvE,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAE7D;AAED,oFAAoF;AACpF,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAG7D;AAED,qFAAqF;AACrF,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAEjE;AAED,4DAA4D;AAC5D,wBAAgB,aAAa,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAGtD"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
canRegisterTools: ()=>canRegisterTools,
|
|
28
|
+
canSetRequestHandler: ()=>canSetRequestHandler,
|
|
29
|
+
hasClientVersionAccessor: ()=>hasClientVersionAccessor,
|
|
30
|
+
hasNestedLowLevelServer: ()=>hasNestedLowLevelServer,
|
|
31
|
+
hasRequestHandlerMap: ()=>hasRequestHandlerMap,
|
|
32
|
+
hasServerInfo: ()=>hasServerInfo,
|
|
33
|
+
hasToolRegistry: ()=>hasToolRegistry,
|
|
34
|
+
isBareServerShape: ()=>isBareServerShape
|
|
35
|
+
});
|
|
36
|
+
function asRecord(value) {
|
|
37
|
+
return value && 'object' == typeof value ? value : void 0;
|
|
38
|
+
}
|
|
39
|
+
function hasMethod(value, key) {
|
|
40
|
+
return 'function' == typeof asRecord(value)?.[key];
|
|
41
|
+
}
|
|
42
|
+
function hasNestedLowLevelServer(server) {
|
|
43
|
+
const record = asRecord(server);
|
|
44
|
+
return !!record && 'server' in record && !!asRecord(record.server);
|
|
45
|
+
}
|
|
46
|
+
function isBareServerShape(server) {
|
|
47
|
+
const record = asRecord(server);
|
|
48
|
+
return !!record && !('server' in record);
|
|
49
|
+
}
|
|
50
|
+
function hasToolRegistry(server) {
|
|
51
|
+
return !!asRecord(asRecord(server)?._registeredTools);
|
|
52
|
+
}
|
|
53
|
+
function canRegisterTools(server) {
|
|
54
|
+
return hasMethod(server, 'registerTool') || hasMethod(server, 'tool');
|
|
55
|
+
}
|
|
56
|
+
function canSetRequestHandler(server) {
|
|
57
|
+
return hasMethod(server, 'setRequestHandler');
|
|
58
|
+
}
|
|
59
|
+
function hasRequestHandlerMap(server) {
|
|
60
|
+
const handlers = asRecord(server)?._requestHandlers;
|
|
61
|
+
return handlers instanceof Map && 'function' == typeof handlers.get;
|
|
62
|
+
}
|
|
63
|
+
function hasClientVersionAccessor(server) {
|
|
64
|
+
return hasMethod(server, 'getClientVersion');
|
|
65
|
+
}
|
|
66
|
+
function hasServerInfo(server) {
|
|
67
|
+
const info = asRecord(asRecord(server)?._serverInfo);
|
|
68
|
+
return !!info && 'name' in info;
|
|
69
|
+
}
|
|
70
|
+
exports.canRegisterTools = __webpack_exports__.canRegisterTools;
|
|
71
|
+
exports.canSetRequestHandler = __webpack_exports__.canSetRequestHandler;
|
|
72
|
+
exports.hasClientVersionAccessor = __webpack_exports__.hasClientVersionAccessor;
|
|
73
|
+
exports.hasNestedLowLevelServer = __webpack_exports__.hasNestedLowLevelServer;
|
|
74
|
+
exports.hasRequestHandlerMap = __webpack_exports__.hasRequestHandlerMap;
|
|
75
|
+
exports.hasServerInfo = __webpack_exports__.hasServerInfo;
|
|
76
|
+
exports.hasToolRegistry = __webpack_exports__.hasToolRegistry;
|
|
77
|
+
exports.isBareServerShape = __webpack_exports__.isBareServerShape;
|
|
78
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
79
|
+
"canRegisterTools",
|
|
80
|
+
"canSetRequestHandler",
|
|
81
|
+
"hasClientVersionAccessor",
|
|
82
|
+
"hasNestedLowLevelServer",
|
|
83
|
+
"hasRequestHandlerMap",
|
|
84
|
+
"hasServerInfo",
|
|
85
|
+
"hasToolRegistry",
|
|
86
|
+
"isBareServerShape"
|
|
87
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
88
|
+
Object.defineProperty(exports, '__esModule', {
|
|
89
|
+
value: true
|
|
90
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
function asRecord(value) {
|
|
2
|
+
return value && 'object' == typeof value ? value : void 0;
|
|
3
|
+
}
|
|
4
|
+
function hasMethod(value, key) {
|
|
5
|
+
return 'function' == typeof asRecord(value)?.[key];
|
|
6
|
+
}
|
|
7
|
+
function hasNestedLowLevelServer(server) {
|
|
8
|
+
const record = asRecord(server);
|
|
9
|
+
return !!record && 'server' in record && !!asRecord(record.server);
|
|
10
|
+
}
|
|
11
|
+
function isBareServerShape(server) {
|
|
12
|
+
const record = asRecord(server);
|
|
13
|
+
return !!record && !('server' in record);
|
|
14
|
+
}
|
|
15
|
+
function hasToolRegistry(server) {
|
|
16
|
+
return !!asRecord(asRecord(server)?._registeredTools);
|
|
17
|
+
}
|
|
18
|
+
function canRegisterTools(server) {
|
|
19
|
+
return hasMethod(server, 'registerTool') || hasMethod(server, 'tool');
|
|
20
|
+
}
|
|
21
|
+
function canSetRequestHandler(server) {
|
|
22
|
+
return hasMethod(server, 'setRequestHandler');
|
|
23
|
+
}
|
|
24
|
+
function hasRequestHandlerMap(server) {
|
|
25
|
+
const handlers = asRecord(server)?._requestHandlers;
|
|
26
|
+
return handlers instanceof Map && 'function' == typeof handlers.get;
|
|
27
|
+
}
|
|
28
|
+
function hasClientVersionAccessor(server) {
|
|
29
|
+
return hasMethod(server, 'getClientVersion');
|
|
30
|
+
}
|
|
31
|
+
function hasServerInfo(server) {
|
|
32
|
+
const info = asRecord(asRecord(server)?._serverInfo);
|
|
33
|
+
return !!info && 'name' in info;
|
|
34
|
+
}
|
|
35
|
+
export { canRegisterTools, canSetRequestHandler, hasClientVersionAccessor, hasNestedLowLevelServer, hasRequestHandlerMap, hasServerInfo, hasToolRegistry, isBareServerShape };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The single place this package reads an HTTP request header.
|
|
3
|
+
*
|
|
4
|
+
* The MCP SDK hands us `IsomorphicHeaders` — a plain
|
|
5
|
+
* `Record<string, string | string[] | undefined>`, not a `Headers` instance — so
|
|
6
|
+
* values come out by bracket access rather than `.get()`. MCP SDK v2 plans to
|
|
7
|
+
* pass a real `Headers` object instead; funnelling every read through here keeps
|
|
8
|
+
* that migration a one-function change instead of a hunt for bracket lookups.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Reads one header value out of an `IsomorphicHeaders` bag. `name` must be
|
|
12
|
+
* lower-cased: the HTTP transports build the bag with
|
|
13
|
+
* `Object.fromEntries(req.headers.entries())` and the Fetch spec lower-cases
|
|
14
|
+
* header names. A hand-rolled transport can still hand us mixed-case keys, so a
|
|
15
|
+
* case-insensitive scan backs up the direct lookup.
|
|
16
|
+
*
|
|
17
|
+
* Repeated headers arrive as an array — we take the first entry, since every
|
|
18
|
+
* header we read is single-valued by definition. Returns `undefined` for a
|
|
19
|
+
* missing, non-string, or blank value, and never throws: a malformed header from
|
|
20
|
+
* an untrusted client must not break the request it rode in on.
|
|
21
|
+
*/
|
|
22
|
+
export declare function readHeaderValue(headers: unknown, name: string): string | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Coerces one raw header value into a clean string, or `undefined`.
|
|
25
|
+
*
|
|
26
|
+
* Exported so the custom-dispatcher path can apply the same rules to values a host
|
|
27
|
+
* read off the request itself. Without it the two integration paths emit different
|
|
28
|
+
* properties for the *same* request: a whitespace-only header would survive as a junk
|
|
29
|
+
* value, and a repeated header would reach the wire as an array, because the
|
|
30
|
+
* downstream length cap passes non-strings through untouched.
|
|
31
|
+
*/
|
|
32
|
+
export declare function normalizeHeaderString(value: unknown): string | undefined;
|
|
33
|
+
//# sourceMappingURL=headers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"headers.d.ts","sourceRoot":"","sources":["../../src/extensions/headers.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAWlF;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAOxE"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
normalizeHeaderString: ()=>normalizeHeaderString,
|
|
28
|
+
readHeaderValue: ()=>readHeaderValue
|
|
29
|
+
});
|
|
30
|
+
function readHeaderValue(headers, name) {
|
|
31
|
+
if (!headers || 'object' != typeof headers) return;
|
|
32
|
+
const record = headers;
|
|
33
|
+
let value = record[name];
|
|
34
|
+
if (void 0 === value) {
|
|
35
|
+
const key = Object.keys(record).find((k)=>k.toLowerCase() === name);
|
|
36
|
+
value = void 0 === key ? void 0 : record[key];
|
|
37
|
+
}
|
|
38
|
+
return normalizeHeaderString(value);
|
|
39
|
+
}
|
|
40
|
+
function normalizeHeaderString(value) {
|
|
41
|
+
const first = Array.isArray(value) ? value[0] : value;
|
|
42
|
+
if ('string' != typeof first) return;
|
|
43
|
+
const trimmed = first.trim();
|
|
44
|
+
return trimmed.length > 0 ? trimmed : void 0;
|
|
45
|
+
}
|
|
46
|
+
exports.normalizeHeaderString = __webpack_exports__.normalizeHeaderString;
|
|
47
|
+
exports.readHeaderValue = __webpack_exports__.readHeaderValue;
|
|
48
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
49
|
+
"normalizeHeaderString",
|
|
50
|
+
"readHeaderValue"
|
|
51
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
52
|
+
Object.defineProperty(exports, '__esModule', {
|
|
53
|
+
value: true
|
|
54
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
function readHeaderValue(headers, name) {
|
|
2
|
+
if (!headers || 'object' != typeof headers) return;
|
|
3
|
+
const record = headers;
|
|
4
|
+
let value = record[name];
|
|
5
|
+
if (void 0 === value) {
|
|
6
|
+
const key = Object.keys(record).find((k)=>k.toLowerCase() === name);
|
|
7
|
+
value = void 0 === key ? void 0 : record[key];
|
|
8
|
+
}
|
|
9
|
+
return normalizeHeaderString(value);
|
|
10
|
+
}
|
|
11
|
+
function normalizeHeaderString(value) {
|
|
12
|
+
const first = Array.isArray(value) ? value[0] : value;
|
|
13
|
+
if ('string' != typeof first) return;
|
|
14
|
+
const trimmed = first.trim();
|
|
15
|
+
return trimmed.length > 0 ? trimmed : void 0;
|
|
16
|
+
}
|
|
17
|
+
export { normalizeHeaderString, readHeaderValue };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrument-highlevel.d.ts","sourceRoot":"","sources":["../../src/extensions/instrument-highlevel.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAEV,sBAAsB,EAIvB,MAAM,UAAU,CAAA;AASjB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAgQxC,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,sBAAsB,EAAE,MAAM,EAAE,QAAQ,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"instrument-highlevel.d.ts","sourceRoot":"","sources":["../../src/extensions/instrument-highlevel.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAEV,sBAAsB,EAIvB,MAAM,UAAU,CAAA;AASjB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAgQxC,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,sBAAsB,EAAE,MAAM,EAAE,QAAQ,GAAG,IAAI,CA0BhG"}
|
|
@@ -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;AAG5F,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAmBxC;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,QAAQ,GAAG,IAAI,
|
|
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;AAG5F,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAmBxC;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,QAAQ,GAAG,IAAI,CAyBtF"}
|
|
@@ -77,6 +77,13 @@ export type HandlerPatch = (server: MCPServerLike, originalHandler: MCPRequestHa
|
|
|
77
77
|
* the shipped bundle.
|
|
78
78
|
*/
|
|
79
79
|
export declare function registerFallbackRequestHandler(server: MCPServerLike, handlerName: string, fallbackHandler: MCPRequestHandler, patch: HandlerPatch): void;
|
|
80
|
+
/**
|
|
81
|
+
* Applies the `patches` (keyed by method, e.g. `initialize`, `tools/list`) to the
|
|
82
|
+
* handlers already registered, and patches `setRequestHandler` so matching
|
|
83
|
+
* handlers registered later are patched too. The latter is what makes adapters
|
|
84
|
+
* that register handlers post-construction work — e.g. `@rekog/mcp-nest` hands a
|
|
85
|
+
* bare server to instrument() and only then registers its handlers.
|
|
86
|
+
*/
|
|
80
87
|
export declare function patchRequestHandlers(server: MCPServerLike, patches: Record<string, HandlerPatch>): void;
|
|
81
88
|
/**
|
|
82
89
|
* Checks the server's raw listing for a real owner of a candidate virtual tool.
|