@orkestrel/mcp 0.0.36 → 0.0.38
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/src/core/index.cjs +26 -5
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +27 -1
- package/dist/src/core/index.d.ts +27 -1
- package/dist/src/core/index.js +26 -6
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/server/index.cjs +15 -7
- package/dist/src/server/index.cjs.map +1 -1
- package/dist/src/server/index.d.cts +7 -5
- package/dist/src/server/index.d.ts +7 -5
- package/dist/src/server/index.js +16 -8
- package/dist/src/server/index.js.map +1 -1
- package/package.json +19 -19
|
@@ -372,8 +372,8 @@ function inferHeaderTarget(request) {
|
|
|
372
372
|
* {@link import('@orkestrel/mcp').decodeSentinel} before the comparison, so a peer that had
|
|
373
373
|
* to encode its value still matches; a sentinel whose payload is invalid decodes to nothing
|
|
374
374
|
* and therefore mismatches, which is how an invalid header value is refused. A legacy request
|
|
375
|
-
* body requires a protocol header
|
|
376
|
-
* never echo the client-supplied one.
|
|
375
|
+
* body requires a protocol header except for `initialize` and an id-bearing legacy `ping`.
|
|
376
|
+
* Messages name the expected value but never echo the client-supplied one.
|
|
377
377
|
*
|
|
378
378
|
* The expectation a live session supplies is a different rule over a different input, so it
|
|
379
379
|
* is {@link inferSessionHeaderIssue} rather than a second arm of this one.
|
|
@@ -391,7 +391,7 @@ function inferHeaderTarget(request) {
|
|
|
391
391
|
function inferHeaderIssue(request, invocation) {
|
|
392
392
|
const protocol = request.headers.get(_src_core.MCP_PROTOCOL_VERSION_HEADER);
|
|
393
393
|
if (!(0, _src_core.isModernRequest)(invocation)) {
|
|
394
|
-
if ((0, _src_core.isInitializeRequest)(invocation) || protocol !== null) return void 0;
|
|
394
|
+
if ((0, _src_core.isInitializeRequest)(invocation) || (0, _src_core.isPingRequest)(invocation) || protocol !== null) return void 0;
|
|
395
395
|
return {
|
|
396
396
|
header: "MCP-Protocol-Version",
|
|
397
397
|
reason: "missing",
|
|
@@ -719,8 +719,8 @@ var HTTPDisconnect = class {
|
|
|
719
719
|
* comparison; a missing, mismatched, or invalidly encoded value returns HTTP `400` + `-32020`.
|
|
720
720
|
* A protocol header naming a modern revision holds the request to that revision whatever shape
|
|
721
721
|
* its body arrived in, so a body with no parsable modern `_meta` returns HTTP `400` + `-32602`.
|
|
722
|
-
* Headerless `initialize`
|
|
723
|
-
* session to supply its pinned version. A legacy-shaped request carrying a protocol header is
|
|
722
|
+
* Headerless `initialize` and id-bearing legacy `ping` are accepted; other headerless requests
|
|
723
|
+
* need a live legacy session to supply its pinned version. A legacy-shaped request carrying a protocol header is
|
|
724
724
|
* otherwise admitted only for a legacy revision; a revision this server does not implement
|
|
725
725
|
* returns HTTP `400` + `-32022` whose `supported` names the legacy revisions this door accepts.
|
|
726
726
|
* A present origin must occur in `origin.origins` unless validation is
|
|
@@ -1979,7 +1979,9 @@ function createStdioServer(mcp, options) {
|
|
|
1979
1979
|
* readSessionHeader}: a valid id touches the entry and sets `context.state.session`; an
|
|
1980
1980
|
* absent / unknown id whose (guarded) body parses to an `initialize` request ({@link
|
|
1981
1981
|
* isInitializeRequest}) mints a fresh {@link MCPSession} (`crypto.randomUUID()`, the `session`
|
|
1982
|
-
* options group) and sets `context.state.session
|
|
1982
|
+
* options group) and sets `context.state.session`. An id-bearing legacy `ping` with no
|
|
1983
|
+
* session header passes through without session state, a supplied protocol header, or a
|
|
1984
|
+
* response stamp. Other unresolved requests → {@link rejectUnknownSession}
|
|
1983
1985
|
* (`404`). The
|
|
1984
1986
|
* minted entry pins the negotiated legacy revision, which is supplied to a later headerless
|
|
1985
1987
|
* live-session request. It then
|
|
@@ -2108,7 +2110,13 @@ function createMCPSession(options) {
|
|
|
2108
2110
|
version: inferLegacyVersion(parsed)
|
|
2109
2111
|
};
|
|
2110
2112
|
entry = created;
|
|
2111
|
-
} else return
|
|
2113
|
+
} else if (id === void 0 && (0, _src_core.isPingRequest)(parsed)) return next(new Request(context.url, {
|
|
2114
|
+
method: "POST",
|
|
2115
|
+
headers: request.headers,
|
|
2116
|
+
body: text,
|
|
2117
|
+
signal: request.signal
|
|
2118
|
+
}));
|
|
2119
|
+
else return rejectUnknownSession();
|
|
2112
2120
|
}
|
|
2113
2121
|
if (!Reflect.set(context.state, "session", entry.session)) throw new Error("MCP session state is not writable");
|
|
2114
2122
|
const headers = new Headers(request.headers);
|