@posthog/mcp 0.11.2 → 0.11.3
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/dist/extensions/client-identity.d.ts +17 -1
- package/dist/extensions/client-identity.d.ts.map +1 -1
- package/dist/extensions/client-identity.js +21 -3
- package/dist/extensions/client-identity.mjs +13 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.mjs +1 -1
- package/package.json +3 -3
- package/src/extensions/client-identity.ts +39 -2
- package/src/version.ts +1 -1
|
@@ -11,7 +11,11 @@ import type { CompatibleRequestHandlerExtra, McpEvent, MCPRequestLike, MCPServer
|
|
|
11
11
|
* the time a handler runs they are here and `params._meta` is empty.
|
|
12
12
|
* 2. `request.params._meta` — where 2026-07-28 puts them on the wire, and
|
|
13
13
|
* where they still are on any server that does not lift them.
|
|
14
|
-
* 3. the
|
|
14
|
+
* 3. the `MCP-Protocol-Version` request header, which 2025-11-25 requires a
|
|
15
|
+
* client to send on every request after `initialize` — the only per-request
|
|
16
|
+
* carrier a legacy-era request has, and therefore the only one that
|
|
17
|
+
* survives a per-request server instance.
|
|
18
|
+
* 4. the server's own accessors — `getClientVersion()` from a legacy
|
|
15
19
|
* `initialize` handshake, `getNegotiatedProtocolVersion()` on v2.
|
|
16
20
|
*
|
|
17
21
|
* The 2026-07-28 revision removed the `initialize` handshake and the
|
|
@@ -22,6 +26,8 @@ import type { CompatibleRequestHandlerExtra, McpEvent, MCPRequestLike, MCPServer
|
|
|
22
26
|
*/
|
|
23
27
|
export declare const META_CLIENT_INFO_KEY = "io.modelcontextprotocol/clientInfo";
|
|
24
28
|
export declare const META_PROTOCOL_VERSION_KEY = "io.modelcontextprotocol/protocolVersion";
|
|
29
|
+
/** Required on every post-`initialize` request by 2025-11-25 (and sent by modern clients too). */
|
|
30
|
+
export declare const PROTOCOL_VERSION_HEADER = "mcp-protocol-version";
|
|
25
31
|
export interface MetaClientInfo {
|
|
26
32
|
clientName?: string;
|
|
27
33
|
clientVersion?: string;
|
|
@@ -52,6 +58,16 @@ export declare function readMetaClientInfo(request: MCPRequestLike): MetaClientI
|
|
|
52
58
|
* everything.
|
|
53
59
|
*/
|
|
54
60
|
export declare function readEnvelopeClientInfo(extra: CompatibleRequestHandlerExtra | undefined): MetaClientInfo | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* Reads the protocol version off the request headers.
|
|
63
|
+
*
|
|
64
|
+
* This is what closes the gap on **2025-11-25 traffic served by a per-request
|
|
65
|
+
* server**: that era carries identity at the handshake, and the instance
|
|
66
|
+
* handling a later `tools/call` never saw it. The header rides every request, so
|
|
67
|
+
* it survives where the handshake does not. Carries no client name — that still
|
|
68
|
+
* depends on the replayed session token.
|
|
69
|
+
*/
|
|
70
|
+
export declare function readHeaderProtocolVersion(extra: CompatibleRequestHandlerExtra | undefined): MetaClientInfo | undefined;
|
|
55
71
|
/**
|
|
56
72
|
* Asks the server itself. `getClientVersion()` answers on any server that
|
|
57
73
|
* handled an `initialize` (and v2 hosts such as `createMcpHandler` backfill it
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-identity.d.ts","sourceRoot":"","sources":["../../src/extensions/client-identity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,6BAA6B,EAAE,QAAQ,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"client-identity.d.ts","sourceRoot":"","sources":["../../src/extensions/client-identity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,6BAA6B,EAAE,QAAQ,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAKtG;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,oBAAoB,uCAAuC,CAAA;AACxE,eAAO,MAAM,yBAAyB,4CAA4C,CAAA;AAClF,kGAAkG;AAClG,eAAO,MAAM,uBAAuB,yBAAyB,CAAA;AAI7D,MAAM,WAAW,cAAc;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,eAAe,CAAC,EAAE,MAAM,CAAA;CACzB;AAED,8DAA8D;AAC9D,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,cAAc,CAAA;IACvB,KAAK,CAAC,EAAE,6BAA6B,CAAA;IACrC;;;;;OAKG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB;AAuCD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,cAAc,GAAG,cAAc,GAAG,SAAS,CAEtF;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,6BAA6B,GAAG,SAAS,GAAG,cAAc,GAAG,SAAS,CAEnH;AAED;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,6BAA6B,GAAG,SAAS,GAC/C,cAAc,GAAG,SAAS,CAS5B;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,OAAO,GAAG,cAAc,GAAG,SAAS,CAsBpF;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,qBAAqB,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,qBAAqB,GAAG,cAAc,GAAG,SAAS,CAiBnH;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,QAAQ,EACf,OAAO,EAAE,cAAc,EACvB,KAAK,CAAC,EAAE,6BAA6B,EACrC,MAAM,CAAC,EAAE,aAAa,GACrB,IAAI,CAcN"}
|
|
@@ -24,17 +24,23 @@ var __webpack_require__ = {};
|
|
|
24
24
|
var __webpack_exports__ = {};
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
resolveClientIdentity: ()=>resolveClientIdentity,
|
|
28
27
|
readMetaClientInfo: ()=>readMetaClientInfo,
|
|
29
|
-
|
|
30
|
-
readEnvelopeClientInfo: ()=>readEnvelopeClientInfo,
|
|
28
|
+
readHeaderProtocolVersion: ()=>readHeaderProtocolVersion,
|
|
31
29
|
META_PROTOCOL_VERSION_KEY: ()=>META_PROTOCOL_VERSION_KEY,
|
|
30
|
+
PROTOCOL_VERSION_HEADER: ()=>PROTOCOL_VERSION_HEADER,
|
|
32
31
|
stampClientIdentity: ()=>stampClientIdentity,
|
|
32
|
+
resolveClientIdentity: ()=>resolveClientIdentity,
|
|
33
|
+
readServerClientIdentity: ()=>readServerClientIdentity,
|
|
34
|
+
readEnvelopeClientInfo: ()=>readEnvelopeClientInfo,
|
|
33
35
|
META_CLIENT_INFO_KEY: ()=>META_CLIENT_INFO_KEY
|
|
34
36
|
});
|
|
35
37
|
const external_detect_js_namespaceObject = require("./detect.js");
|
|
38
|
+
const external_headers_js_namespaceObject = require("./headers.js");
|
|
39
|
+
const external_request_headers_js_namespaceObject = require("./request-headers.js");
|
|
36
40
|
const META_CLIENT_INFO_KEY = 'io.modelcontextprotocol/clientInfo';
|
|
37
41
|
const META_PROTOCOL_VERSION_KEY = 'io.modelcontextprotocol/protocolVersion';
|
|
42
|
+
const PROTOCOL_VERSION_HEADER = 'mcp-protocol-version';
|
|
43
|
+
const MAX_PROTOCOL_VERSION_LENGTH = 64;
|
|
38
44
|
function nonEmptyString(value) {
|
|
39
45
|
return 'string' == typeof value && value.length > 0 ? value : void 0;
|
|
40
46
|
}
|
|
@@ -64,6 +70,13 @@ function readMetaClientInfo(request) {
|
|
|
64
70
|
function readEnvelopeClientInfo(extra) {
|
|
65
71
|
return readReservedKeys(extra?.mcpReq?.envelope);
|
|
66
72
|
}
|
|
73
|
+
function readHeaderProtocolVersion(extra) {
|
|
74
|
+
const protocolVersion = (0, external_headers_js_namespaceObject.readHeaderValue)((0, external_request_headers_js_namespaceObject.getRequestHeaders)(extra), PROTOCOL_VERSION_HEADER);
|
|
75
|
+
if (!protocolVersion || protocolVersion.length > MAX_PROTOCOL_VERSION_LENGTH) return;
|
|
76
|
+
return {
|
|
77
|
+
protocolVersion
|
|
78
|
+
};
|
|
79
|
+
}
|
|
67
80
|
function readServerClientIdentity(server) {
|
|
68
81
|
if (!server) return;
|
|
69
82
|
const result = {};
|
|
@@ -81,6 +94,7 @@ function resolveClientIdentity({ request, extra, server }) {
|
|
|
81
94
|
const chain = [
|
|
82
95
|
readEnvelopeClientInfo(extra),
|
|
83
96
|
readMetaClientInfo(request),
|
|
97
|
+
readHeaderProtocolVersion(extra),
|
|
84
98
|
readServerClientIdentity(server)
|
|
85
99
|
];
|
|
86
100
|
const result = {};
|
|
@@ -104,7 +118,9 @@ function stampClientIdentity(event, request, extra, server) {
|
|
|
104
118
|
}
|
|
105
119
|
exports.META_CLIENT_INFO_KEY = __webpack_exports__.META_CLIENT_INFO_KEY;
|
|
106
120
|
exports.META_PROTOCOL_VERSION_KEY = __webpack_exports__.META_PROTOCOL_VERSION_KEY;
|
|
121
|
+
exports.PROTOCOL_VERSION_HEADER = __webpack_exports__.PROTOCOL_VERSION_HEADER;
|
|
107
122
|
exports.readEnvelopeClientInfo = __webpack_exports__.readEnvelopeClientInfo;
|
|
123
|
+
exports.readHeaderProtocolVersion = __webpack_exports__.readHeaderProtocolVersion;
|
|
108
124
|
exports.readMetaClientInfo = __webpack_exports__.readMetaClientInfo;
|
|
109
125
|
exports.readServerClientIdentity = __webpack_exports__.readServerClientIdentity;
|
|
110
126
|
exports.resolveClientIdentity = __webpack_exports__.resolveClientIdentity;
|
|
@@ -112,7 +128,9 @@ exports.stampClientIdentity = __webpack_exports__.stampClientIdentity;
|
|
|
112
128
|
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
113
129
|
"META_CLIENT_INFO_KEY",
|
|
114
130
|
"META_PROTOCOL_VERSION_KEY",
|
|
131
|
+
"PROTOCOL_VERSION_HEADER",
|
|
115
132
|
"readEnvelopeClientInfo",
|
|
133
|
+
"readHeaderProtocolVersion",
|
|
116
134
|
"readMetaClientInfo",
|
|
117
135
|
"readServerClientIdentity",
|
|
118
136
|
"resolveClientIdentity",
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { hasClientVersionAccessor, hasNegotiatedProtocolVersionAccessor } from "./detect.mjs";
|
|
2
|
+
import { readHeaderValue } from "./headers.mjs";
|
|
3
|
+
import { getRequestHeaders } from "./request-headers.mjs";
|
|
2
4
|
const META_CLIENT_INFO_KEY = 'io.modelcontextprotocol/clientInfo';
|
|
3
5
|
const META_PROTOCOL_VERSION_KEY = 'io.modelcontextprotocol/protocolVersion';
|
|
6
|
+
const PROTOCOL_VERSION_HEADER = 'mcp-protocol-version';
|
|
7
|
+
const MAX_PROTOCOL_VERSION_LENGTH = 64;
|
|
4
8
|
function nonEmptyString(value) {
|
|
5
9
|
return 'string' == typeof value && value.length > 0 ? value : void 0;
|
|
6
10
|
}
|
|
@@ -30,6 +34,13 @@ function readMetaClientInfo(request) {
|
|
|
30
34
|
function readEnvelopeClientInfo(extra) {
|
|
31
35
|
return readReservedKeys(extra?.mcpReq?.envelope);
|
|
32
36
|
}
|
|
37
|
+
function readHeaderProtocolVersion(extra) {
|
|
38
|
+
const protocolVersion = readHeaderValue(getRequestHeaders(extra), PROTOCOL_VERSION_HEADER);
|
|
39
|
+
if (!protocolVersion || protocolVersion.length > MAX_PROTOCOL_VERSION_LENGTH) return;
|
|
40
|
+
return {
|
|
41
|
+
protocolVersion
|
|
42
|
+
};
|
|
43
|
+
}
|
|
33
44
|
function readServerClientIdentity(server) {
|
|
34
45
|
if (!server) return;
|
|
35
46
|
const result = {};
|
|
@@ -47,6 +58,7 @@ function resolveClientIdentity({ request, extra, server }) {
|
|
|
47
58
|
const chain = [
|
|
48
59
|
readEnvelopeClientInfo(extra),
|
|
49
60
|
readMetaClientInfo(request),
|
|
61
|
+
readHeaderProtocolVersion(extra),
|
|
50
62
|
readServerClientIdentity(server)
|
|
51
63
|
];
|
|
52
64
|
const result = {};
|
|
@@ -68,4 +80,4 @@ function stampClientIdentity(event, request, extra, server) {
|
|
|
68
80
|
if (info.clientVersion) event.clientVersion = info.clientVersion;
|
|
69
81
|
if (info.protocolVersion) event.protocolVersion = info.protocolVersion;
|
|
70
82
|
}
|
|
71
|
-
export { META_CLIENT_INFO_KEY, META_PROTOCOL_VERSION_KEY, readEnvelopeClientInfo, readMetaClientInfo, readServerClientIdentity, resolveClientIdentity, stampClientIdentity };
|
|
83
|
+
export { META_CLIENT_INFO_KEY, META_PROTOCOL_VERSION_KEY, PROTOCOL_VERSION_HEADER, readEnvelopeClientInfo, readHeaderProtocolVersion, readMetaClientInfo, readServerClientIdentity, resolveClientIdentity, stampClientIdentity };
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "0.11.
|
|
1
|
+
export declare const version = "0.11.3";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/version.js
CHANGED
|
@@ -26,7 +26,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
27
|
version: ()=>version
|
|
28
28
|
});
|
|
29
|
-
const version = '0.11.
|
|
29
|
+
const version = '0.11.3';
|
|
30
30
|
exports.version = __webpack_exports__.version;
|
|
31
31
|
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
32
32
|
"version"
|
package/dist/version.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const version = '0.11.
|
|
1
|
+
const version = '0.11.3';
|
|
2
2
|
export { version };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@posthog/mcp",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.3",
|
|
4
4
|
"bugs": {
|
|
5
5
|
"url": "https://github.com/PostHog/posthog-js/issues"
|
|
6
6
|
},
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"@types/node": "^20.0.0",
|
|
41
41
|
"jest": "29.7.0",
|
|
42
42
|
"zod": "^3.25.0",
|
|
43
|
-
"posthog-
|
|
44
|
-
"
|
|
43
|
+
"@posthog-tooling/tsconfig-base": "1.1.1",
|
|
44
|
+
"posthog-node": "^5.48.1"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"@modelcontextprotocol/sdk": ">=1.26.0",
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { CompatibleRequestHandlerExtra, McpEvent, MCPRequestLike, MCPServerLike } from '../types'
|
|
2
2
|
import { hasClientVersionAccessor, hasNegotiatedProtocolVersionAccessor } from './detect'
|
|
3
|
+
import { readHeaderValue } from './headers'
|
|
4
|
+
import { getRequestHeaders } from './request-headers'
|
|
3
5
|
|
|
4
6
|
/**
|
|
5
7
|
* Client identity — who is calling, and which spec revision they speak.
|
|
@@ -13,7 +15,11 @@ import { hasClientVersionAccessor, hasNegotiatedProtocolVersionAccessor } from '
|
|
|
13
15
|
* the time a handler runs they are here and `params._meta` is empty.
|
|
14
16
|
* 2. `request.params._meta` — where 2026-07-28 puts them on the wire, and
|
|
15
17
|
* where they still are on any server that does not lift them.
|
|
16
|
-
* 3. the
|
|
18
|
+
* 3. the `MCP-Protocol-Version` request header, which 2025-11-25 requires a
|
|
19
|
+
* client to send on every request after `initialize` — the only per-request
|
|
20
|
+
* carrier a legacy-era request has, and therefore the only one that
|
|
21
|
+
* survives a per-request server instance.
|
|
22
|
+
* 4. the server's own accessors — `getClientVersion()` from a legacy
|
|
17
23
|
* `initialize` handshake, `getNegotiatedProtocolVersion()` on v2.
|
|
18
24
|
*
|
|
19
25
|
* The 2026-07-28 revision removed the `initialize` handshake and the
|
|
@@ -24,6 +30,10 @@ import { hasClientVersionAccessor, hasNegotiatedProtocolVersionAccessor } from '
|
|
|
24
30
|
*/
|
|
25
31
|
export const META_CLIENT_INFO_KEY = 'io.modelcontextprotocol/clientInfo'
|
|
26
32
|
export const META_PROTOCOL_VERSION_KEY = 'io.modelcontextprotocol/protocolVersion'
|
|
33
|
+
/** Required on every post-`initialize` request by 2025-11-25 (and sent by modern clients too). */
|
|
34
|
+
export const PROTOCOL_VERSION_HEADER = 'mcp-protocol-version'
|
|
35
|
+
/** A version string is a date-like token; anything longer is junk we should not record. */
|
|
36
|
+
const MAX_PROTOCOL_VERSION_LENGTH = 64
|
|
27
37
|
|
|
28
38
|
export interface MetaClientInfo {
|
|
29
39
|
clientName?: string
|
|
@@ -100,6 +110,28 @@ export function readEnvelopeClientInfo(extra: CompatibleRequestHandlerExtra | un
|
|
|
100
110
|
return readReservedKeys((extra as { mcpReq?: { envelope?: unknown } } | undefined)?.mcpReq?.envelope)
|
|
101
111
|
}
|
|
102
112
|
|
|
113
|
+
/**
|
|
114
|
+
* Reads the protocol version off the request headers.
|
|
115
|
+
*
|
|
116
|
+
* This is what closes the gap on **2025-11-25 traffic served by a per-request
|
|
117
|
+
* server**: that era carries identity at the handshake, and the instance
|
|
118
|
+
* handling a later `tools/call` never saw it. The header rides every request, so
|
|
119
|
+
* it survives where the handshake does not. Carries no client name — that still
|
|
120
|
+
* depends on the replayed session token.
|
|
121
|
+
*/
|
|
122
|
+
export function readHeaderProtocolVersion(
|
|
123
|
+
extra: CompatibleRequestHandlerExtra | undefined
|
|
124
|
+
): MetaClientInfo | undefined {
|
|
125
|
+
// `getRequestHeaders` answers *where* the headers are on either SDK major;
|
|
126
|
+
// `readHeaderValue` answers how to read one value out of the bag it returns —
|
|
127
|
+
// repeated values, mixed case, blank strings. Two questions, one place each.
|
|
128
|
+
const protocolVersion = readHeaderValue(getRequestHeaders(extra), PROTOCOL_VERSION_HEADER)
|
|
129
|
+
if (!protocolVersion || protocolVersion.length > MAX_PROTOCOL_VERSION_LENGTH) {
|
|
130
|
+
return undefined
|
|
131
|
+
}
|
|
132
|
+
return { protocolVersion }
|
|
133
|
+
}
|
|
134
|
+
|
|
103
135
|
/**
|
|
104
136
|
* Asks the server itself. `getClientVersion()` answers on any server that
|
|
105
137
|
* handled an `initialize` (and v2 hosts such as `createMcpHandler` backfill it
|
|
@@ -148,7 +180,12 @@ export function readServerClientIdentity(server: unknown): MetaClientInfo | unde
|
|
|
148
180
|
* keeps it a fallback: any request that identifies itself wins outright.
|
|
149
181
|
*/
|
|
150
182
|
export function resolveClientIdentity({ request, extra, server }: ClientIdentitySources): MetaClientInfo | undefined {
|
|
151
|
-
const chain = [
|
|
183
|
+
const chain = [
|
|
184
|
+
readEnvelopeClientInfo(extra),
|
|
185
|
+
readMetaClientInfo(request),
|
|
186
|
+
readHeaderProtocolVersion(extra),
|
|
187
|
+
readServerClientIdentity(server),
|
|
188
|
+
]
|
|
152
189
|
const result: MetaClientInfo = {}
|
|
153
190
|
for (const source of chain) {
|
|
154
191
|
if (!source) {
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '0.11.
|
|
1
|
+
export const version = '0.11.3'
|