@alcyone-labs/arg-parser 1.1.0 → 1.2.0
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 +150 -24
- package/dist/index.cjs +21863 -2500
- package/dist/index.cjs.map +1 -1
- package/dist/index.min.mjs +14541 -1827
- package/dist/index.min.mjs.map +1 -1
- package/dist/index.mjs +21865 -2502
- package/dist/index.mjs.map +1 -1
- package/dist/src/ArgParser.d.ts +2 -10
- package/dist/src/ArgParser.d.ts.map +1 -1
- package/dist/src/ArgParserBase.d.ts.map +1 -1
- package/dist/src/mcp-integration.d.ts.map +1 -1
- package/dist/src/types.d.ts +11 -0
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +25 -5
- package/dist/examples/fuzzy-demo.d.ts +0 -8
- package/dist/examples/fuzzy-demo.d.ts.map +0 -1
- package/dist/examples/fuzzy-test-example.d.ts +0 -8
- package/dist/examples/fuzzy-test-example.d.ts.map +0 -1
- package/dist/examples/fzf-search-cli.d.ts +0 -8
- package/dist/examples/fzf-search-cli.d.ts.map +0 -1
- package/dist/examples/getting-started.d.ts +0 -27
- package/dist/examples/getting-started.d.ts.map +0 -1
- package/dist/examples/mcp-preset-transports.d.ts +0 -19
- package/dist/examples/mcp-preset-transports.d.ts.map +0 -1
- package/dist/examples/simple-cli.d.ts +0 -26
- package/dist/examples/simple-cli.d.ts.map +0 -1
- package/dist/examples/v1.1.0-showcase.d.ts +0 -16
- package/dist/examples/v1.1.0-showcase.d.ts.map +0 -1
- package/dist/examples/with-env-example.d.ts +0 -3
- package/dist/examples/with-env-example.d.ts.map +0 -1
- package/dist/index-6G9StDO_.js +0 -6445
- package/dist/index-6G9StDO_.js.map +0 -1
- package/dist/index-CqU7Fj3C.cjs +0 -6444
- package/dist/index-CqU7Fj3C.cjs.map +0 -1
- package/dist/index-Dx_q1msW.js +0 -4682
- package/dist/index-Dx_q1msW.js.map +0 -1
- package/dist/sse-B5Jf_YpG.cjs +0 -121
- package/dist/sse-B5Jf_YpG.cjs.map +0 -1
- package/dist/sse-BDL3h2Ll.js +0 -121
- package/dist/sse-BDL3h2Ll.js.map +0 -1
- package/dist/sse-DSjLfGFo.js +0 -107
- package/dist/sse-DSjLfGFo.js.map +0 -1
- package/dist/stdio-Cf19UQO7.js +0 -70
- package/dist/stdio-Cf19UQO7.js.map +0 -1
- package/dist/stdio-DESvSONI.cjs +0 -94
- package/dist/stdio-DESvSONI.cjs.map +0 -1
- package/dist/stdio-DLOResWr.js +0 -94
- package/dist/stdio-DLOResWr.js.map +0 -1
- package/dist/streamableHttp-DXIdDSbF.js +0 -342
- package/dist/streamableHttp-DXIdDSbF.js.map +0 -1
- package/dist/streamableHttp-DsXlAnqJ.cjs +0 -456
- package/dist/streamableHttp-DsXlAnqJ.cjs.map +0 -1
- package/dist/streamableHttp-Vd4Qsgko.js +0 -456
- package/dist/streamableHttp-Vd4Qsgko.js.map +0 -1
- package/dist/types-DSxPEImy.cjs +0 -943
- package/dist/types-DSxPEImy.cjs.map +0 -1
- package/dist/types-DdsPVLQ5.js +0 -846
- package/dist/types-DdsPVLQ5.js.map +0 -1
- package/dist/types-DpK81FWv.js +0 -944
- package/dist/types-DpK81FWv.js.map +0 -1
package/dist/stdio-DLOResWr.js
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import process from "node:process";
|
|
2
|
-
import { J as JSONRPCMessageSchema } from "./types-DpK81FWv.js";
|
|
3
|
-
class ReadBuffer {
|
|
4
|
-
append(chunk) {
|
|
5
|
-
this._buffer = this._buffer ? Buffer.concat([this._buffer, chunk]) : chunk;
|
|
6
|
-
}
|
|
7
|
-
readMessage() {
|
|
8
|
-
if (!this._buffer) {
|
|
9
|
-
return null;
|
|
10
|
-
}
|
|
11
|
-
const index = this._buffer.indexOf("\n");
|
|
12
|
-
if (index === -1) {
|
|
13
|
-
return null;
|
|
14
|
-
}
|
|
15
|
-
const line = this._buffer.toString("utf8", 0, index).replace(/\r$/, "");
|
|
16
|
-
this._buffer = this._buffer.subarray(index + 1);
|
|
17
|
-
return deserializeMessage(line);
|
|
18
|
-
}
|
|
19
|
-
clear() {
|
|
20
|
-
this._buffer = void 0;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
function deserializeMessage(line) {
|
|
24
|
-
return JSONRPCMessageSchema.parse(JSON.parse(line));
|
|
25
|
-
}
|
|
26
|
-
function serializeMessage(message) {
|
|
27
|
-
return JSON.stringify(message) + "\n";
|
|
28
|
-
}
|
|
29
|
-
class StdioServerTransport {
|
|
30
|
-
constructor(_stdin = process.stdin, _stdout = process.stdout) {
|
|
31
|
-
this._stdin = _stdin;
|
|
32
|
-
this._stdout = _stdout;
|
|
33
|
-
this._readBuffer = new ReadBuffer();
|
|
34
|
-
this._started = false;
|
|
35
|
-
this._ondata = (chunk) => {
|
|
36
|
-
this._readBuffer.append(chunk);
|
|
37
|
-
this.processReadBuffer();
|
|
38
|
-
};
|
|
39
|
-
this._onerror = (error) => {
|
|
40
|
-
var _a;
|
|
41
|
-
(_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, error);
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Starts listening for messages on stdin.
|
|
46
|
-
*/
|
|
47
|
-
async start() {
|
|
48
|
-
if (this._started) {
|
|
49
|
-
throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");
|
|
50
|
-
}
|
|
51
|
-
this._started = true;
|
|
52
|
-
this._stdin.on("data", this._ondata);
|
|
53
|
-
this._stdin.on("error", this._onerror);
|
|
54
|
-
}
|
|
55
|
-
processReadBuffer() {
|
|
56
|
-
var _a, _b;
|
|
57
|
-
while (true) {
|
|
58
|
-
try {
|
|
59
|
-
const message = this._readBuffer.readMessage();
|
|
60
|
-
if (message === null) {
|
|
61
|
-
break;
|
|
62
|
-
}
|
|
63
|
-
(_a = this.onmessage) === null || _a === void 0 ? void 0 : _a.call(this, message);
|
|
64
|
-
} catch (error) {
|
|
65
|
-
(_b = this.onerror) === null || _b === void 0 ? void 0 : _b.call(this, error);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
async close() {
|
|
70
|
-
var _a;
|
|
71
|
-
this._stdin.off("data", this._ondata);
|
|
72
|
-
this._stdin.off("error", this._onerror);
|
|
73
|
-
const remainingDataListeners = this._stdin.listenerCount("data");
|
|
74
|
-
if (remainingDataListeners === 0) {
|
|
75
|
-
this._stdin.pause();
|
|
76
|
-
}
|
|
77
|
-
this._readBuffer.clear();
|
|
78
|
-
(_a = this.onclose) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
79
|
-
}
|
|
80
|
-
send(message) {
|
|
81
|
-
return new Promise((resolve) => {
|
|
82
|
-
const json = serializeMessage(message);
|
|
83
|
-
if (this._stdout.write(json)) {
|
|
84
|
-
resolve();
|
|
85
|
-
} else {
|
|
86
|
-
this._stdout.once("drain", resolve);
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
export {
|
|
92
|
-
StdioServerTransport
|
|
93
|
-
};
|
|
94
|
-
//# sourceMappingURL=stdio-DLOResWr.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stdio-DLOResWr.js","sources":["../node_modules/.pnpm/@modelcontextprotocol+sdk@1.13.1/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js","../node_modules/.pnpm/@modelcontextprotocol+sdk@1.13.1/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js"],"sourcesContent":["import { JSONRPCMessageSchema } from \"../types.js\";\n/**\n * Buffers a continuous stdio stream into discrete JSON-RPC messages.\n */\nexport class ReadBuffer {\n append(chunk) {\n this._buffer = this._buffer ? Buffer.concat([this._buffer, chunk]) : chunk;\n }\n readMessage() {\n if (!this._buffer) {\n return null;\n }\n const index = this._buffer.indexOf(\"\\n\");\n if (index === -1) {\n return null;\n }\n const line = this._buffer.toString(\"utf8\", 0, index).replace(/\\r$/, '');\n this._buffer = this._buffer.subarray(index + 1);\n return deserializeMessage(line);\n }\n clear() {\n this._buffer = undefined;\n }\n}\nexport function deserializeMessage(line) {\n return JSONRPCMessageSchema.parse(JSON.parse(line));\n}\nexport function serializeMessage(message) {\n return JSON.stringify(message) + \"\\n\";\n}\n//# sourceMappingURL=stdio.js.map","import process from \"node:process\";\nimport { ReadBuffer, serializeMessage } from \"../shared/stdio.js\";\n/**\n * Server transport for stdio: this communicates with a MCP client by reading from the current process' stdin and writing to stdout.\n *\n * This transport is only available in Node.js environments.\n */\nexport class StdioServerTransport {\n constructor(_stdin = process.stdin, _stdout = process.stdout) {\n this._stdin = _stdin;\n this._stdout = _stdout;\n this._readBuffer = new ReadBuffer();\n this._started = false;\n // Arrow functions to bind `this` properly, while maintaining function identity.\n this._ondata = (chunk) => {\n this._readBuffer.append(chunk);\n this.processReadBuffer();\n };\n this._onerror = (error) => {\n var _a;\n (_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, error);\n };\n }\n /**\n * Starts listening for messages on stdin.\n */\n async start() {\n if (this._started) {\n throw new Error(\"StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.\");\n }\n this._started = true;\n this._stdin.on(\"data\", this._ondata);\n this._stdin.on(\"error\", this._onerror);\n }\n processReadBuffer() {\n var _a, _b;\n while (true) {\n try {\n const message = this._readBuffer.readMessage();\n if (message === null) {\n break;\n }\n (_a = this.onmessage) === null || _a === void 0 ? void 0 : _a.call(this, message);\n }\n catch (error) {\n (_b = this.onerror) === null || _b === void 0 ? void 0 : _b.call(this, error);\n }\n }\n }\n async close() {\n var _a;\n // Remove our event listeners first\n this._stdin.off(\"data\", this._ondata);\n this._stdin.off(\"error\", this._onerror);\n // Check if we were the only data listener\n const remainingDataListeners = this._stdin.listenerCount('data');\n if (remainingDataListeners === 0) {\n // Only pause stdin if we were the only listener\n // This prevents interfering with other parts of the application that might be using stdin\n this._stdin.pause();\n }\n // Clear the buffer and notify closure\n this._readBuffer.clear();\n (_a = this.onclose) === null || _a === void 0 ? void 0 : _a.call(this);\n }\n send(message) {\n return new Promise((resolve) => {\n const json = serializeMessage(message);\n if (this._stdout.write(json)) {\n resolve();\n }\n else {\n this._stdout.once(\"drain\", resolve);\n }\n });\n }\n}\n//# sourceMappingURL=stdio.js.map"],"names":[],"mappings":";;AAIO,MAAM,WAAW;AAAA,EACpB,OAAO,OAAO;AACV,SAAK,UAAU,KAAK,UAAU,OAAO,OAAO,CAAC,KAAK,SAAS,KAAK,CAAC,IAAI;AAAA,EAC7E;AAAA,EACI,cAAc;AACV,QAAI,CAAC,KAAK,SAAS;AACf,aAAO;AAAA,IACnB;AACQ,UAAM,QAAQ,KAAK,QAAQ,QAAQ,IAAI;AACvC,QAAI,UAAU,IAAI;AACd,aAAO;AAAA,IACnB;AACQ,UAAM,OAAO,KAAK,QAAQ,SAAS,QAAQ,GAAG,KAAK,EAAE,QAAQ,OAAO,EAAE;AACtE,SAAK,UAAU,KAAK,QAAQ,SAAS,QAAQ,CAAC;AAC9C,WAAO,mBAAmB,IAAI;AAAA,EACtC;AAAA,EACI,QAAQ;AACJ,SAAK,UAAU;AAAA,EACvB;AACA;AACO,SAAS,mBAAmB,MAAM;AACrC,SAAO,qBAAqB,MAAM,KAAK,MAAM,IAAI,CAAC;AACtD;AACO,SAAS,iBAAiB,SAAS;AACtC,SAAO,KAAK,UAAU,OAAO,IAAI;AACrC;ACtBO,MAAM,qBAAqB;AAAA,EAC9B,YAAY,SAAS,QAAQ,OAAO,UAAU,QAAQ,QAAQ;AAC1D,SAAK,SAAS;AACd,SAAK,UAAU;AACf,SAAK,cAAc,IAAI,WAAU;AACjC,SAAK,WAAW;AAEhB,SAAK,UAAU,CAAC,UAAU;AACtB,WAAK,YAAY,OAAO,KAAK;AAC7B,WAAK,kBAAiB;AAAA,IAClC;AACQ,SAAK,WAAW,CAAC,UAAU;AACvB,UAAI;AACJ,OAAC,KAAK,KAAK,aAAa,QAAQ,OAAO,SAAS,S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A;","x_google_ignoreList":[0,1]}
|
|
@@ -1,342 +0,0 @@
|
|
|
1
|
-
import { J as g, i as I, a as y, D as R, S as w, b as f, c as S } from "./types-DdsPVLQ5.js";
|
|
2
|
-
import { c as E, g as M } from "./index-Dx_q1msW.js";
|
|
3
|
-
import { randomUUID as O } from "node:crypto";
|
|
4
|
-
const T = "4mb";
|
|
5
|
-
class q {
|
|
6
|
-
constructor(e) {
|
|
7
|
-
var t;
|
|
8
|
-
this._started = !1, this._streamMapping = /* @__PURE__ */ new Map(), this._requestToStreamMapping = /* @__PURE__ */ new Map(), this._requestResponseMap = /* @__PURE__ */ new Map(), this._initialized = !1, this._enableJsonResponse = !1, this._standaloneSseStreamId = "_GET_stream", this.sessionIdGenerator = e.sessionIdGenerator, this._enableJsonResponse = (t = e.enableJsonResponse) !== null && t !== void 0 ? t : !1, this._eventStore = e.eventStore, this._onsessioninitialized = e.onsessioninitialized;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Starts the transport. This is required by the Transport interface but is a no-op
|
|
12
|
-
* for the Streamable HTTP transport as connections are managed per-request.
|
|
13
|
-
*/
|
|
14
|
-
async start() {
|
|
15
|
-
if (this._started)
|
|
16
|
-
throw new Error("Transport already started");
|
|
17
|
-
this._started = !0;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Handles an incoming HTTP request, whether GET or POST
|
|
21
|
-
*/
|
|
22
|
-
async handleRequest(e, t, s) {
|
|
23
|
-
e.method === "POST" ? await this.handlePostRequest(e, t, s) : e.method === "GET" ? await this.handleGetRequest(e, t) : e.method === "DELETE" ? await this.handleDeleteRequest(e, t) : await this.handleUnsupportedRequest(t);
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Handles GET requests for SSE stream
|
|
27
|
-
*/
|
|
28
|
-
async handleGetRequest(e, t) {
|
|
29
|
-
const s = e.headers.accept;
|
|
30
|
-
if (!(s != null && s.includes("text/event-stream"))) {
|
|
31
|
-
t.writeHead(406).end(JSON.stringify({
|
|
32
|
-
jsonrpc: "2.0",
|
|
33
|
-
error: {
|
|
34
|
-
code: -32e3,
|
|
35
|
-
message: "Not Acceptable: Client must accept text/event-stream"
|
|
36
|
-
},
|
|
37
|
-
id: null
|
|
38
|
-
}));
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
if (!this.validateSession(e, t) || !this.validateProtocolVersion(e, t))
|
|
42
|
-
return;
|
|
43
|
-
if (this._eventStore) {
|
|
44
|
-
const n = e.headers["last-event-id"];
|
|
45
|
-
if (n) {
|
|
46
|
-
await this.replayEvents(n, t);
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
const i = {
|
|
51
|
-
"Content-Type": "text/event-stream",
|
|
52
|
-
"Cache-Control": "no-cache, no-transform",
|
|
53
|
-
Connection: "keep-alive"
|
|
54
|
-
};
|
|
55
|
-
if (this.sessionId !== void 0 && (i["mcp-session-id"] = this.sessionId), this._streamMapping.get(this._standaloneSseStreamId) !== void 0) {
|
|
56
|
-
t.writeHead(409).end(JSON.stringify({
|
|
57
|
-
jsonrpc: "2.0",
|
|
58
|
-
error: {
|
|
59
|
-
code: -32e3,
|
|
60
|
-
message: "Conflict: Only one SSE stream is allowed per session"
|
|
61
|
-
},
|
|
62
|
-
id: null
|
|
63
|
-
}));
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
t.writeHead(200, i).flushHeaders(), this._streamMapping.set(this._standaloneSseStreamId, t), t.on("close", () => {
|
|
67
|
-
this._streamMapping.delete(this._standaloneSseStreamId);
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Replays events that would have been sent after the specified event ID
|
|
72
|
-
* Only used when resumability is enabled
|
|
73
|
-
*/
|
|
74
|
-
async replayEvents(e, t) {
|
|
75
|
-
var s, i;
|
|
76
|
-
if (this._eventStore)
|
|
77
|
-
try {
|
|
78
|
-
const n = {
|
|
79
|
-
"Content-Type": "text/event-stream",
|
|
80
|
-
"Cache-Control": "no-cache, no-transform",
|
|
81
|
-
Connection: "keep-alive"
|
|
82
|
-
};
|
|
83
|
-
this.sessionId !== void 0 && (n["mcp-session-id"] = this.sessionId), t.writeHead(200, n).flushHeaders();
|
|
84
|
-
const o = await ((s = this._eventStore) === null || s === void 0 ? void 0 : s.replayEventsAfter(e, {
|
|
85
|
-
send: async (d, r) => {
|
|
86
|
-
var a;
|
|
87
|
-
this.writeSSEEvent(t, r, d) || ((a = this.onerror) === null || a === void 0 || a.call(this, new Error("Failed replay events")), t.end());
|
|
88
|
-
}
|
|
89
|
-
}));
|
|
90
|
-
this._streamMapping.set(o, t);
|
|
91
|
-
} catch (n) {
|
|
92
|
-
(i = this.onerror) === null || i === void 0 || i.call(this, n);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Writes an event to the SSE stream with proper formatting
|
|
97
|
-
*/
|
|
98
|
-
writeSSEEvent(e, t, s) {
|
|
99
|
-
let i = `event: message
|
|
100
|
-
`;
|
|
101
|
-
return s && (i += `id: ${s}
|
|
102
|
-
`), i += `data: ${JSON.stringify(t)}
|
|
103
|
-
|
|
104
|
-
`, e.write(i);
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Handles unsupported requests (PUT, PATCH, etc.)
|
|
108
|
-
*/
|
|
109
|
-
async handleUnsupportedRequest(e) {
|
|
110
|
-
e.writeHead(405, {
|
|
111
|
-
Allow: "GET, POST, DELETE"
|
|
112
|
-
}).end(JSON.stringify({
|
|
113
|
-
jsonrpc: "2.0",
|
|
114
|
-
error: {
|
|
115
|
-
code: -32e3,
|
|
116
|
-
message: "Method not allowed."
|
|
117
|
-
},
|
|
118
|
-
id: null
|
|
119
|
-
}));
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Handles POST requests containing JSON-RPC messages
|
|
123
|
-
*/
|
|
124
|
-
async handlePostRequest(e, t, s) {
|
|
125
|
-
var i, n, o, d, r;
|
|
126
|
-
try {
|
|
127
|
-
const a = e.headers.accept;
|
|
128
|
-
if (!(a != null && a.includes("application/json")) || !a.includes("text/event-stream")) {
|
|
129
|
-
t.writeHead(406).end(JSON.stringify({
|
|
130
|
-
jsonrpc: "2.0",
|
|
131
|
-
error: {
|
|
132
|
-
code: -32e3,
|
|
133
|
-
message: "Not Acceptable: Client must accept both application/json and text/event-stream"
|
|
134
|
-
},
|
|
135
|
-
id: null
|
|
136
|
-
}));
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
const p = e.headers["content-type"];
|
|
140
|
-
if (!p || !p.includes("application/json")) {
|
|
141
|
-
t.writeHead(415).end(JSON.stringify({
|
|
142
|
-
jsonrpc: "2.0",
|
|
143
|
-
error: {
|
|
144
|
-
code: -32e3,
|
|
145
|
-
message: "Unsupported Media Type: Content-Type must be application/json"
|
|
146
|
-
},
|
|
147
|
-
id: null
|
|
148
|
-
}));
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
const v = e.auth;
|
|
152
|
-
let u;
|
|
153
|
-
if (s !== void 0)
|
|
154
|
-
u = s;
|
|
155
|
-
else {
|
|
156
|
-
const l = E.parse(p), c = await M(e, {
|
|
157
|
-
limit: T,
|
|
158
|
-
encoding: (i = l.parameters.charset) !== null && i !== void 0 ? i : "utf-8"
|
|
159
|
-
});
|
|
160
|
-
u = JSON.parse(c.toString());
|
|
161
|
-
}
|
|
162
|
-
let h;
|
|
163
|
-
Array.isArray(u) ? h = u.map((l) => g.parse(l)) : h = [g.parse(u)];
|
|
164
|
-
const m = h.some(I);
|
|
165
|
-
if (m) {
|
|
166
|
-
if (this._initialized && this.sessionId !== void 0) {
|
|
167
|
-
t.writeHead(400).end(JSON.stringify({
|
|
168
|
-
jsonrpc: "2.0",
|
|
169
|
-
error: {
|
|
170
|
-
code: -32600,
|
|
171
|
-
message: "Invalid Request: Server already initialized"
|
|
172
|
-
},
|
|
173
|
-
id: null
|
|
174
|
-
}));
|
|
175
|
-
return;
|
|
176
|
-
}
|
|
177
|
-
if (h.length > 1) {
|
|
178
|
-
t.writeHead(400).end(JSON.stringify({
|
|
179
|
-
jsonrpc: "2.0",
|
|
180
|
-
error: {
|
|
181
|
-
code: -32600,
|
|
182
|
-
message: "Invalid Request: Only one initialization request is allowed"
|
|
183
|
-
},
|
|
184
|
-
id: null
|
|
185
|
-
}));
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
188
|
-
this.sessionId = (n = this.sessionIdGenerator) === null || n === void 0 ? void 0 : n.call(this), this._initialized = !0, this.sessionId && this._onsessioninitialized && this._onsessioninitialized(this.sessionId);
|
|
189
|
-
}
|
|
190
|
-
if (!m && (!this.validateSession(e, t) || !this.validateProtocolVersion(e, t)))
|
|
191
|
-
return;
|
|
192
|
-
const _ = h.some(y);
|
|
193
|
-
if (_) {
|
|
194
|
-
if (_) {
|
|
195
|
-
const l = O();
|
|
196
|
-
if (!this._enableJsonResponse) {
|
|
197
|
-
const c = {
|
|
198
|
-
"Content-Type": "text/event-stream",
|
|
199
|
-
"Cache-Control": "no-cache",
|
|
200
|
-
Connection: "keep-alive"
|
|
201
|
-
};
|
|
202
|
-
this.sessionId !== void 0 && (c["mcp-session-id"] = this.sessionId), t.writeHead(200, c);
|
|
203
|
-
}
|
|
204
|
-
for (const c of h)
|
|
205
|
-
y(c) && (this._streamMapping.set(l, t), this._requestToStreamMapping.set(c.id, l));
|
|
206
|
-
t.on("close", () => {
|
|
207
|
-
this._streamMapping.delete(l);
|
|
208
|
-
});
|
|
209
|
-
for (const c of h)
|
|
210
|
-
(d = this.onmessage) === null || d === void 0 || d.call(this, c, { authInfo: v });
|
|
211
|
-
}
|
|
212
|
-
} else {
|
|
213
|
-
t.writeHead(202).end();
|
|
214
|
-
for (const l of h)
|
|
215
|
-
(o = this.onmessage) === null || o === void 0 || o.call(this, l, { authInfo: v });
|
|
216
|
-
}
|
|
217
|
-
} catch (a) {
|
|
218
|
-
t.writeHead(400).end(JSON.stringify({
|
|
219
|
-
jsonrpc: "2.0",
|
|
220
|
-
error: {
|
|
221
|
-
code: -32700,
|
|
222
|
-
message: "Parse error",
|
|
223
|
-
data: String(a)
|
|
224
|
-
},
|
|
225
|
-
id: null
|
|
226
|
-
})), (r = this.onerror) === null || r === void 0 || r.call(this, a);
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
/**
|
|
230
|
-
* Handles DELETE requests to terminate sessions
|
|
231
|
-
*/
|
|
232
|
-
async handleDeleteRequest(e, t) {
|
|
233
|
-
this.validateSession(e, t) && this.validateProtocolVersion(e, t) && (await this.close(), t.writeHead(200).end());
|
|
234
|
-
}
|
|
235
|
-
/**
|
|
236
|
-
* Validates session ID for non-initialization requests
|
|
237
|
-
* Returns true if the session is valid, false otherwise
|
|
238
|
-
*/
|
|
239
|
-
validateSession(e, t) {
|
|
240
|
-
if (this.sessionIdGenerator === void 0)
|
|
241
|
-
return !0;
|
|
242
|
-
if (!this._initialized)
|
|
243
|
-
return t.writeHead(400).end(JSON.stringify({
|
|
244
|
-
jsonrpc: "2.0",
|
|
245
|
-
error: {
|
|
246
|
-
code: -32e3,
|
|
247
|
-
message: "Bad Request: Server not initialized"
|
|
248
|
-
},
|
|
249
|
-
id: null
|
|
250
|
-
})), !1;
|
|
251
|
-
const s = e.headers["mcp-session-id"];
|
|
252
|
-
if (s) {
|
|
253
|
-
if (Array.isArray(s))
|
|
254
|
-
return t.writeHead(400).end(JSON.stringify({
|
|
255
|
-
jsonrpc: "2.0",
|
|
256
|
-
error: {
|
|
257
|
-
code: -32e3,
|
|
258
|
-
message: "Bad Request: Mcp-Session-Id header must be a single value"
|
|
259
|
-
},
|
|
260
|
-
id: null
|
|
261
|
-
})), !1;
|
|
262
|
-
if (s !== this.sessionId)
|
|
263
|
-
return t.writeHead(404).end(JSON.stringify({
|
|
264
|
-
jsonrpc: "2.0",
|
|
265
|
-
error: {
|
|
266
|
-
code: -32001,
|
|
267
|
-
message: "Session not found"
|
|
268
|
-
},
|
|
269
|
-
id: null
|
|
270
|
-
})), !1;
|
|
271
|
-
} else return t.writeHead(400).end(JSON.stringify({
|
|
272
|
-
jsonrpc: "2.0",
|
|
273
|
-
error: {
|
|
274
|
-
code: -32e3,
|
|
275
|
-
message: "Bad Request: Mcp-Session-Id header is required"
|
|
276
|
-
},
|
|
277
|
-
id: null
|
|
278
|
-
})), !1;
|
|
279
|
-
return !0;
|
|
280
|
-
}
|
|
281
|
-
validateProtocolVersion(e, t) {
|
|
282
|
-
var s;
|
|
283
|
-
let i = (s = e.headers["mcp-protocol-version"]) !== null && s !== void 0 ? s : R;
|
|
284
|
-
return Array.isArray(i) && (i = i[i.length - 1]), w.includes(i) ? !0 : (t.writeHead(400).end(JSON.stringify({
|
|
285
|
-
jsonrpc: "2.0",
|
|
286
|
-
error: {
|
|
287
|
-
code: -32e3,
|
|
288
|
-
message: `Bad Request: Unsupported protocol version (supported versions: ${w.join(", ")})`
|
|
289
|
-
},
|
|
290
|
-
id: null
|
|
291
|
-
})), !1);
|
|
292
|
-
}
|
|
293
|
-
async close() {
|
|
294
|
-
var e;
|
|
295
|
-
this._streamMapping.forEach((t) => {
|
|
296
|
-
t.end();
|
|
297
|
-
}), this._streamMapping.clear(), this._requestResponseMap.clear(), (e = this.onclose) === null || e === void 0 || e.call(this);
|
|
298
|
-
}
|
|
299
|
-
async send(e, t) {
|
|
300
|
-
let s = t == null ? void 0 : t.relatedRequestId;
|
|
301
|
-
if ((f(e) || S(e)) && (s = e.id), s === void 0) {
|
|
302
|
-
if (f(e) || S(e))
|
|
303
|
-
throw new Error("Cannot send a response on a standalone SSE stream unless resuming a previous client request");
|
|
304
|
-
const o = this._streamMapping.get(this._standaloneSseStreamId);
|
|
305
|
-
if (o === void 0)
|
|
306
|
-
return;
|
|
307
|
-
let d;
|
|
308
|
-
this._eventStore && (d = await this._eventStore.storeEvent(this._standaloneSseStreamId, e)), this.writeSSEEvent(o, e, d);
|
|
309
|
-
return;
|
|
310
|
-
}
|
|
311
|
-
const i = this._requestToStreamMapping.get(s), n = this._streamMapping.get(i);
|
|
312
|
-
if (!i)
|
|
313
|
-
throw new Error(`No connection established for request ID: ${String(s)}`);
|
|
314
|
-
if (!this._enableJsonResponse) {
|
|
315
|
-
let o;
|
|
316
|
-
this._eventStore && (o = await this._eventStore.storeEvent(i, e)), n && this.writeSSEEvent(n, e, o);
|
|
317
|
-
}
|
|
318
|
-
if (f(e) || S(e)) {
|
|
319
|
-
this._requestResponseMap.set(s, e);
|
|
320
|
-
const o = Array.from(this._requestToStreamMapping.entries()).filter(([r, a]) => this._streamMapping.get(a) === n).map(([r]) => r);
|
|
321
|
-
if (o.every((r) => this._requestResponseMap.has(r))) {
|
|
322
|
-
if (!n)
|
|
323
|
-
throw new Error(`No connection established for request ID: ${String(s)}`);
|
|
324
|
-
if (this._enableJsonResponse) {
|
|
325
|
-
const r = {
|
|
326
|
-
"Content-Type": "application/json"
|
|
327
|
-
};
|
|
328
|
-
this.sessionId !== void 0 && (r["mcp-session-id"] = this.sessionId);
|
|
329
|
-
const a = o.map((p) => this._requestResponseMap.get(p));
|
|
330
|
-
n.writeHead(200, r), a.length === 1 ? n.end(JSON.stringify(a[0])) : n.end(JSON.stringify(a));
|
|
331
|
-
} else
|
|
332
|
-
n.end();
|
|
333
|
-
for (const r of o)
|
|
334
|
-
this._requestResponseMap.delete(r), this._requestToStreamMapping.delete(r);
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
export {
|
|
340
|
-
q as StreamableHTTPServerTransport
|
|
341
|
-
};
|
|
342
|
-
//# sourceMappingURL=streamableHttp-DXIdDSbF.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"streamableHttp-DXIdDSbF.js","sources":["../node_modules/.pnpm/@modelcontextprotocol+sdk@1.13.1/node_modules/@modelcontextprotocol/sdk/dist/esm/server/streamableHttp.js"],"sourcesContent":["import { isInitializeRequest, isJSONRPCError, isJSONRPCRequest, isJSONRPCResponse, JSONRPCMessageSchema, SUPPORTED_PROTOCOL_VERSIONS, DEFAULT_NEGOTIATED_PROTOCOL_VERSION } from \"../types.js\";\nimport getRawBody from \"raw-body\";\nimport contentType from \"content-type\";\nimport { randomUUID } from \"node:crypto\";\nconst MAXIMUM_MESSAGE_SIZE = \"4mb\";\n/**\n * Server transport for Streamable HTTP: this implements the MCP Streamable HTTP transport specification.\n * It supports both SSE streaming and direct HTTP responses.\n *\n * Usage example:\n *\n * ```typescript\n * // Stateful mode - server sets the session ID\n * const statefulTransport = new StreamableHTTPServerTransport({\n * sessionIdGenerator: () => randomUUID(),\n * });\n *\n * // Stateless mode - explicitly set session ID to undefined\n * const statelessTransport = new StreamableHTTPServerTransport({\n * sessionIdGenerator: undefined,\n * });\n *\n * // Using with pre-parsed request body\n * app.post('/mcp', (req, res) => {\n * transport.handleRequest(req, res, req.body);\n * });\n * ```\n *\n * In stateful mode:\n * - Session ID is generated and included in response headers\n * - Session ID is always included in initialization responses\n * - Requests with invalid session IDs are rejected with 404 Not Found\n * - Non-initialization requests without a session ID are rejected with 400 Bad Request\n * - State is maintained in-memory (connections, message history)\n *\n * In stateless mode:\n * - No Session ID is included in any responses\n * - No session validation is performed\n */\nexport class StreamableHTTPServerTransport {\n constructor(options) {\n var _a;\n this._started = false;\n this._streamMapping = new Map();\n this._requestToStreamMapping = new Map();\n this._requestResponseMap = new Map();\n this._initialized = false;\n this._enableJsonResponse = false;\n this._standaloneSseStreamId = '_GET_stream';\n this.sessionIdGenerator = options.sessionIdGenerator;\n this._enableJsonResponse = (_a = options.enableJsonResponse) !== null && _a !== void 0 ? _a : false;\n this._eventStore = options.eventStore;\n this._onsessioninitialized = options.onsessioninitialized;\n }\n /**\n * Starts the transport. This is required by the Transport interface but is a no-op\n * for the Streamable HTTP transport as connections are managed per-request.\n */\n async start() {\n if (this._started) {\n throw new Error(\"Transport already started\");\n }\n this._started = true;\n }\n /**\n * Handles an incoming HTTP request, whether GET or POST\n */\n async handleRequest(req, res, parsedBody) {\n if (req.method === \"POST\") {\n await this.handlePostRequest(req, res, parsedBody);\n }\n else if (req.method === \"GET\") {\n await this.handleGetRequest(req, res);\n }\n else if (req.method === \"DELETE\") {\n await this.handleDeleteRequest(req, res);\n }\n else {\n await this.handleUnsupportedRequest(res);\n }\n }\n /**\n * Handles GET requests for SSE stream\n */\n async handleGetRequest(req, res) {\n // The client MUST include an Accept header, listing text/event-stream as a supported content type.\n const acceptHeader = req.headers.accept;\n if (!(acceptHeader === null || acceptHeader === void 0 ? void 0 : acceptHeader.includes(\"text/event-stream\"))) {\n res.writeHead(406).end(JSON.stringify({\n jsonrpc: \"2.0\",\n error: {\n code: -32000,\n message: \"Not Acceptable: Client must accept text/event-stream\"\n },\n id: null\n }));\n return;\n }\n // If an Mcp-Session-Id is returned by the server during initialization,\n // clients using the Streamable HTTP transport MUST include it\n // in the Mcp-Session-Id header on all of their subsequent HTTP requests.\n if (!this.validateSession(req, res)) {\n return;\n }\n if (!this.validateProtocolVersion(req, res)) {\n return;\n }\n // Handle resumability: check for Last-Event-ID header\n if (this._eventStore) {\n const lastEventId = req.headers['last-event-id'];\n if (lastEventId) {\n await this.replayEvents(lastEventId, res);\n return;\n }\n }\n // The server MUST either return Content-Type: text/event-stream in response to this HTTP GET,\n // or else return HTTP 405 Method Not Allowed\n const headers = {\n \"Content-Type\": \"text/event-stream\",\n \"Cache-Control\": \"no-cache, no-transform\",\n Connection: \"keep-alive\",\n };\n // After initialization, always include the session ID if we have one\n if (this.sessionId !== undefined) {\n headers[\"mcp-session-id\"] = this.sessionId;\n }\n // Check if there's already an active standalone SSE stream for this session\n if (this._streamMapping.get(this._standaloneSseStreamId) !== undefined) {\n // Only one GET SSE stream is allowed per session\n res.writeHead(409).end(JSON.stringify({\n jsonrpc: \"2.0\",\n error: {\n code: -32000,\n message: \"Conflict: Only one SSE stream is allowed per session\"\n },\n id: null\n }));\n return;\n }\n // We need to send headers immediately as messages will arrive much later,\n // otherwise the client will just wait for the first message\n res.writeHead(200, headers).flushHeaders();\n // Assign the response to the standalone SSE stream\n this._streamMapping.set(this._standaloneSseStreamId, res);\n // Set up close handler for client disconnects\n res.on(\"close\", () => {\n this._streamMapping.delete(this._standaloneSseStreamId);\n });\n }\n /**\n * Replays events that would have been sent after the specified event ID\n * Only used when resumability is enabled\n */\n async replayEvents(lastEventId, res) {\n var _a, _b;\n if (!this._eventStore) {\n return;\n }\n try {\n const headers = {\n \"Content-Type\": \"text/event-stream\",\n \"Cache-Control\": \"no-cache, no-transform\",\n Connection: \"keep-alive\",\n };\n if (this.sessionId !== undefined) {\n headers[\"mcp-session-id\"] = this.sessionId;\n }\n res.writeHead(200, headers).flushHeaders();\n const streamId = await ((_a = this._eventStore) === null || _a === void 0 ? void 0 : _a.replayEventsAfter(lastEventId, {\n send: async (eventId, message) => {\n var _a;\n if (!this.writeSSEEvent(res, message, eventId)) {\n (_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, new Error(\"Failed replay events\"));\n res.end();\n }\n }\n }));\n this._streamMapping.set(streamId, res);\n }\n catch (error) {\n (_b = this.onerror) === null || _b === void 0 ? void 0 : _b.call(this, error);\n }\n }\n /**\n * Writes an event to the SSE stream with proper formatting\n */\n writeSSEEvent(res, message, eventId) {\n let eventData = `event: message\\n`;\n // Include event ID if provided - this is important for resumability\n if (eventId) {\n eventData += `id: ${eventId}\\n`;\n }\n eventData += `data: ${JSON.stringify(message)}\\n\\n`;\n return res.write(eventData);\n }\n /**\n * Handles unsupported requests (PUT, PATCH, etc.)\n */\n async handleUnsupportedRequest(res) {\n res.writeHead(405, {\n \"Allow\": \"GET, POST, DELETE\"\n }).end(JSON.stringify({\n jsonrpc: \"2.0\",\n error: {\n code: -32000,\n message: \"Method not allowed.\"\n },\n id: null\n }));\n }\n /**\n * Handles POST requests containing JSON-RPC messages\n */\n async handlePostRequest(req, res, parsedBody) {\n var _a, _b, _c, _d, _e;\n try {\n // Validate the Accept header\n const acceptHeader = req.headers.accept;\n // The client MUST include an Accept header, listing both application/json and text/event-stream as supported content types.\n if (!(acceptHeader === null || acceptHeader === void 0 ? void 0 : acceptHeader.includes(\"application/json\")) || !acceptHeader.includes(\"text/event-stream\")) {\n res.writeHead(406).end(JSON.stringify({\n jsonrpc: \"2.0\",\n error: {\n code: -32000,\n message: \"Not Acceptable: Client must accept both application/json and text/event-stream\"\n },\n id: null\n }));\n return;\n }\n const ct = req.headers[\"content-type\"];\n if (!ct || !ct.includes(\"application/json\")) {\n res.writeHead(415).end(JSON.stringify({\n jsonrpc: \"2.0\",\n error: {\n code: -32000,\n message: \"Unsupported Media Type: Content-Type must be application/json\"\n },\n id: null\n }));\n return;\n }\n const authInfo = req.auth;\n let rawMessage;\n if (parsedBody !== undefined) {\n rawMessage = parsedBody;\n }\n else {\n const parsedCt = contentType.parse(ct);\n const body = await getRawBody(req, {\n limit: MAXIMUM_MESSAGE_SIZE,\n encoding: (_a = parsedCt.parameters.charset) !== null && _a !== void 0 ? _a : \"utf-8\",\n });\n rawMessage = JSON.parse(body.toString());\n }\n let messages;\n // handle batch and single messages\n if (Array.isArray(rawMessage)) {\n messages = rawMessage.map(msg => JSONRPCMessageSchema.parse(msg));\n }\n else {\n messages = [JSONRPCMessageSchema.parse(rawMessage)];\n }\n // Check if this is an initialization request\n // https://spec.modelcontextprotocol.io/specification/2025-03-26/basic/lifecycle/\n const isInitializationRequest = messages.some(isInitializeRequest);\n if (isInitializationRequest) {\n // If it's a server with session management and the session ID is already set we should reject the request\n // to avoid re-initialization.\n if (this._initialized && this.sessionId !== undefined) {\n res.writeHead(400).end(JSON.stringify({\n jsonrpc: \"2.0\",\n error: {\n code: -32600,\n message: \"Invalid Request: Server already initialized\"\n },\n id: null\n }));\n return;\n }\n if (messages.length > 1) {\n res.writeHead(400).end(JSON.stringify({\n jsonrpc: \"2.0\",\n error: {\n code: -32600,\n message: \"Invalid Request: Only one initialization request is allowed\"\n },\n id: null\n }));\n return;\n }\n this.sessionId = (_b = this.sessionIdGenerator) === null || _b === void 0 ? void 0 : _b.call(this);\n this._initialized = true;\n // If we have a session ID and an onsessioninitialized handler, call it immediately\n // This is needed in cases where the server needs to keep track of multiple sessions\n if (this.sessionId && this._onsessioninitialized) {\n this._onsessioninitialized(this.sessionId);\n }\n }\n if (!isInitializationRequest) {\n // If an Mcp-Session-Id is returned by the server during initialization,\n // clients using the Streamable HTTP transport MUST include it \n // in the Mcp-Session-Id header on all of their subsequent HTTP requests.\n if (!this.validateSession(req, res)) {\n return;\n }\n // Mcp-Protocol-Version header is required for all requests after initialization.\n if (!this.validateProtocolVersion(req, res)) {\n return;\n }\n }\n // check if it contains requests\n const hasRequests = messages.some(isJSONRPCRequest);\n if (!hasRequests) {\n // if it only contains notifications or responses, return 202\n res.writeHead(202).end();\n // handle each message\n for (const message of messages) {\n (_c = this.onmessage) === null || _c === void 0 ? void 0 : _c.call(this, message, { authInfo });\n }\n }\n else if (hasRequests) {\n // The default behavior is to use SSE streaming\n // but in some cases server will return JSON responses\n const streamId = randomUUID();\n if (!this._enableJsonResponse) {\n const headers = {\n \"Content-Type\": \"text/event-stream\",\n \"Cache-Control\": \"no-cache\",\n Connection: \"keep-alive\",\n };\n // After initialization, always include the session ID if we have one\n if (this.sessionId !== undefined) {\n headers[\"mcp-session-id\"] = this.sessionId;\n }\n res.writeHead(200, headers);\n }\n // Store the response for this request to send messages back through this connection\n // We need to track by request ID to maintain the connection\n for (const message of messages) {\n if (isJSONRPCRequest(message)) {\n this._streamMapping.set(streamId, res);\n this._requestToStreamMapping.set(message.id, streamId);\n }\n }\n // Set up close handler for client disconnects\n res.on(\"close\", () => {\n this._streamMapping.delete(streamId);\n });\n // handle each message\n for (const message of messages) {\n (_d = this.onmessage) === null || _d === void 0 ? void 0 : _d.call(this, message, { authInfo });\n }\n // The server SHOULD NOT close the SSE stream before sending all JSON-RPC responses\n // This will be handled by the send() method when responses are ready\n }\n }\n catch (error) {\n // return JSON-RPC formatted error\n res.writeHead(400).end(JSON.stringify({\n jsonrpc: \"2.0\",\n error: {\n code: -32700,\n message: \"Parse error\",\n data: String(error)\n },\n id: null\n }));\n (_e = this.onerror) === null || _e === void 0 ? void 0 : _e.call(this, error);\n }\n }\n /**\n * Handles DELETE requests to terminate sessions\n */\n async handleDeleteRequest(req, res) {\n if (!this.validateSession(req, res)) {\n return;\n }\n if (!this.validateProtocolVersion(req, res)) {\n return;\n }\n await this.close();\n res.writeHead(200).end();\n }\n /**\n * Validates session ID for non-initialization requests\n * Returns true if the session is valid, false otherwise\n */\n validateSession(req, res) {\n if (this.sessionIdGenerator === undefined) {\n // If the sessionIdGenerator ID is not set, the session management is disabled\n // and we don't need to validate the session ID\n return true;\n }\n if (!this._initialized) {\n // If the server has not been initialized yet, reject all requests\n res.writeHead(400).end(JSON.stringify({\n jsonrpc: \"2.0\",\n error: {\n code: -32000,\n message: \"Bad Request: Server not initialized\"\n },\n id: null\n }));\n return false;\n }\n const sessionId = req.headers[\"mcp-session-id\"];\n if (!sessionId) {\n // Non-initialization requests without a session ID should return 400 Bad Request\n res.writeHead(400).end(JSON.stringify({\n jsonrpc: \"2.0\",\n error: {\n code: -32000,\n message: \"Bad Request: Mcp-Session-Id header is required\"\n },\n id: null\n }));\n return false;\n }\n else if (Array.isArray(sessionId)) {\n res.writeHead(400).end(JSON.stringify({\n jsonrpc: \"2.0\",\n error: {\n code: -32000,\n message: \"Bad Request: Mcp-Session-Id header must be a single value\"\n },\n id: null\n }));\n return false;\n }\n else if (sessionId !== this.sessionId) {\n // Reject requests with invalid session ID with 404 Not Found\n res.writeHead(404).end(JSON.stringify({\n jsonrpc: \"2.0\",\n error: {\n code: -32001,\n message: \"Session not found\"\n },\n id: null\n }));\n return false;\n }\n return true;\n }\n validateProtocolVersion(req, res) {\n var _a;\n let protocolVersion = (_a = req.headers[\"mcp-protocol-version\"]) !== null && _a !== void 0 ? _a : DEFAULT_NEGOTIATED_PROTOCOL_VERSION;\n if (Array.isArray(protocolVersion)) {\n protocolVersion = protocolVersion[protocolVersion.length - 1];\n }\n if (!SUPPORTED_PROTOCOL_VERSIONS.includes(protocolVersion)) {\n res.writeHead(400).end(JSON.stringify({\n jsonrpc: \"2.0\",\n error: {\n code: -32000,\n message: `Bad Request: Unsupported protocol version (supported versions: ${SUPPORTED_PROTOCOL_VERSIONS.join(\", \")})`\n },\n id: null\n }));\n return false;\n }\n return true;\n }\n async close() {\n var _a;\n // Close all SSE connections\n this._streamMapping.forEach((response) => {\n response.end();\n });\n this._streamMapping.clear();\n // Clear any pending responses\n this._requestResponseMap.clear();\n (_a = this.onclose) === null || _a === void 0 ? void 0 : _a.call(this);\n }\n async send(message, options) {\n let requestId = options === null || options === void 0 ? void 0 : options.relatedRequestId;\n if (isJSONRPCResponse(message) || isJSONRPCError(message)) {\n // If the message is a response, use the request ID from the message\n requestId = message.id;\n }\n // Check if this message should be sent on the standalone SSE stream (no request ID)\n // Ignore notifications from tools (which have relatedRequestId set)\n // Those will be sent via dedicated response SSE streams\n if (requestId === undefined) {\n // For standalone SSE streams, we can only send requests and notifications\n if (isJSONRPCResponse(message) || isJSONRPCError(message)) {\n throw new Error(\"Cannot send a response on a standalone SSE stream unless resuming a previous client request\");\n }\n const standaloneSse = this._streamMapping.get(this._standaloneSseStreamId);\n if (standaloneSse === undefined) {\n // The spec says the server MAY send messages on the stream, so it's ok to discard if no stream\n return;\n }\n // Generate and store event ID if event store is provided\n let eventId;\n if (this._eventStore) {\n // Stores the event and gets the generated event ID\n eventId = await this._eventStore.storeEvent(this._standaloneSseStreamId, message);\n }\n // Send the message to the standalone SSE stream\n this.writeSSEEvent(standaloneSse, message, eventId);\n return;\n }\n // Get the response for this request\n const streamId = this._requestToStreamMapping.get(requestId);\n const response = this._streamMapping.get(streamId);\n if (!streamId) {\n throw new Error(`No connection established for request ID: ${String(requestId)}`);\n }\n if (!this._enableJsonResponse) {\n // For SSE responses, generate event ID if event store is provided\n let eventId;\n if (this._eventStore) {\n eventId = await this._eventStore.storeEvent(streamId, message);\n }\n if (response) {\n // Write the event to the response stream\n this.writeSSEEvent(response, message, eventId);\n }\n }\n if (isJSONRPCResponse(message) || isJSONRPCError(message)) {\n this._requestResponseMap.set(requestId, message);\n const relatedIds = Array.from(this._requestToStreamMapping.entries())\n .filter(([_, streamId]) => this._streamMapping.get(streamId) === response)\n .map(([id]) => id);\n // Check if we have responses for all requests using this connection\n const allResponsesReady = relatedIds.every(id => this._requestResponseMap.has(id));\n if (allResponsesReady) {\n if (!response) {\n throw new Error(`No connection established for request ID: ${String(requestId)}`);\n }\n if (this._enableJsonResponse) {\n // All responses ready, send as JSON\n const headers = {\n 'Content-Type': 'application/json',\n };\n if (this.sessionId !== undefined) {\n headers['mcp-session-id'] = this.sessionId;\n }\n const responses = relatedIds\n .map(id => this._requestResponseMap.get(id));\n response.writeHead(200, headers);\n if (responses.length === 1) {\n response.end(JSON.stringify(responses[0]));\n }\n else {\n response.end(JSON.stringify(responses));\n }\n }\n else {\n // End the SSE stream\n response.end();\n }\n // Clean up\n for (const id of relatedIds) {\n this._requestResponseMap.delete(id);\n this._requestToStreamMapping.delete(id);\n }\n }\n }\n }\n}\n//# sourceMappingURL=streamableHttp.js.map"],"names":["MAXIMUM_MESSAGE_SIZE","StreamableHTTPServerTransport","options","_a","req","res","parsedBody","acceptHeader","lastEventId","headers","_b","streamId","eventId","message","error","eventData","_c","_d","_e","ct","authInfo","rawMessage","parsedCt","contentType","body","getRawBody","messages","msg","JSONRPCMessageSchema","isInitializationRequest","isInitializeRequest","hasRequests","isJSONRPCRequest","randomUUID","sessionId","protocolVersion","DEFAULT_NEGOTIATED_PROTOCOL_VERSION","SUPPORTED_PROTOCOL_VERSIONS","response","requestId","isJSONRPCResponse","isJSONRPCError","standaloneSse","relatedIds","_","id","responses"],"mappings":";;;AAIA,MAAMA,IAAuB;AAmCtB,MAAMC,EAA8B;AAAA,EACvC,YAAYC,GAAS;AACjB,QAAIC;AACJ,SAAK,WAAW,IAChB,KAAK,iBAAiB,oBAAI,IAAG,GAC7B,KAAK,0BAA0B,oBAAI,IAAG,GACtC,K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