@modelcontextprotocol/sdk 1.24.3 → 1.25.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.
Files changed (233) hide show
  1. package/dist/cjs/client/auth-extensions.js +5 -9
  2. package/dist/cjs/client/auth-extensions.js.map +1 -1
  3. package/dist/cjs/client/auth.js +30 -37
  4. package/dist/cjs/client/auth.js.map +1 -1
  5. package/dist/cjs/client/index.d.ts +61 -14
  6. package/dist/cjs/client/index.d.ts.map +1 -1
  7. package/dist/cjs/client/index.js +117 -36
  8. package/dist/cjs/client/index.js.map +1 -1
  9. package/dist/cjs/client/middleware.js +3 -3
  10. package/dist/cjs/client/middleware.js.map +1 -1
  11. package/dist/cjs/client/sse.js +19 -27
  12. package/dist/cjs/client/sse.js.map +1 -1
  13. package/dist/cjs/client/stdio.js +18 -28
  14. package/dist/cjs/client/stdio.js.map +1 -1
  15. package/dist/cjs/client/streamableHttp.d.ts.map +1 -1
  16. package/dist/cjs/client/streamableHttp.js +39 -49
  17. package/dist/cjs/client/streamableHttp.js.map +1 -1
  18. package/dist/cjs/client/websocket.js +6 -11
  19. package/dist/cjs/client/websocket.js.map +1 -1
  20. package/dist/cjs/examples/client/elicitationUrlExample.js +4 -5
  21. package/dist/cjs/examples/client/elicitationUrlExample.js.map +1 -1
  22. package/dist/cjs/examples/client/simpleOAuthClient.js +3 -3
  23. package/dist/cjs/examples/client/simpleOAuthClient.js.map +1 -1
  24. package/dist/cjs/examples/client/simpleStreamableHttp.js +7 -9
  25. package/dist/cjs/examples/client/simpleStreamableHttp.js.map +1 -1
  26. package/dist/cjs/examples/client/simpleTaskInteractiveClient.js +1 -2
  27. package/dist/cjs/examples/client/simpleTaskInteractiveClient.js.map +1 -1
  28. package/dist/cjs/examples/server/honoWebStandardStreamableHttp.d.ts +10 -0
  29. package/dist/cjs/examples/server/honoWebStandardStreamableHttp.d.ts.map +1 -0
  30. package/dist/cjs/examples/server/honoWebStandardStreamableHttp.js +81 -0
  31. package/dist/cjs/examples/server/honoWebStandardStreamableHttp.js.map +1 -0
  32. package/dist/cjs/examples/server/jsonResponseStreamableHttp.js +10 -4
  33. package/dist/cjs/examples/server/jsonResponseStreamableHttp.js.map +1 -1
  34. package/dist/cjs/examples/server/simpleSseServer.js +6 -3
  35. package/dist/cjs/examples/server/simpleSseServer.js.map +1 -1
  36. package/dist/cjs/examples/server/simpleStatelessStreamableHttp.js +12 -6
  37. package/dist/cjs/examples/server/simpleStatelessStreamableHttp.js.map +1 -1
  38. package/dist/cjs/examples/server/simpleStreamableHttp.js +21 -11
  39. package/dist/cjs/examples/server/simpleStreamableHttp.js.map +1 -1
  40. package/dist/cjs/examples/server/simpleTaskInteractive.js +7 -11
  41. package/dist/cjs/examples/server/simpleTaskInteractive.js.map +1 -1
  42. package/dist/cjs/examples/server/sseAndStreamableHttpCompatibleServer.js +10 -7
  43. package/dist/cjs/examples/server/sseAndStreamableHttpCompatibleServer.js.map +1 -1
  44. package/dist/cjs/examples/server/standaloneSseWithGetStreamableHttp.js +1 -1
  45. package/dist/cjs/examples/server/standaloneSseWithGetStreamableHttp.js.map +1 -1
  46. package/dist/cjs/experimental/tasks/client.js +1 -2
  47. package/dist/cjs/experimental/tasks/client.js.map +1 -1
  48. package/dist/cjs/experimental/tasks/helpers.js +3 -5
  49. package/dist/cjs/experimental/tasks/helpers.js.map +1 -1
  50. package/dist/cjs/experimental/tasks/interfaces.d.ts +3 -3
  51. package/dist/cjs/experimental/tasks/interfaces.d.ts.map +1 -1
  52. package/dist/cjs/experimental/tasks/stores/in-memory.d.ts +1 -1
  53. package/dist/cjs/experimental/tasks/stores/in-memory.d.ts.map +1 -1
  54. package/dist/cjs/experimental/tasks/stores/in-memory.js +3 -5
  55. package/dist/cjs/experimental/tasks/stores/in-memory.js.map +1 -1
  56. package/dist/cjs/inMemory.js +5 -7
  57. package/dist/cjs/inMemory.js.map +1 -1
  58. package/dist/cjs/server/auth/handlers/token.js +1 -1
  59. package/dist/cjs/server/auth/handlers/token.js.map +1 -1
  60. package/dist/cjs/server/auth/providers/proxyProvider.js +11 -17
  61. package/dist/cjs/server/auth/providers/proxyProvider.js.map +1 -1
  62. package/dist/cjs/server/auth/router.js +3 -6
  63. package/dist/cjs/server/auth/router.js.map +1 -1
  64. package/dist/cjs/server/completable.js +1 -1
  65. package/dist/cjs/server/completable.js.map +1 -1
  66. package/dist/cjs/server/index.d.ts +3 -3
  67. package/dist/cjs/server/index.d.ts.map +1 -1
  68. package/dist/cjs/server/index.js +20 -30
  69. package/dist/cjs/server/index.js.map +1 -1
  70. package/dist/cjs/server/mcp.d.ts.map +1 -1
  71. package/dist/cjs/server/mcp.js +25 -11
  72. package/dist/cjs/server/mcp.js.map +1 -1
  73. package/dist/cjs/server/middleware/hostHeaderValidation.js +1 -1
  74. package/dist/cjs/server/middleware/hostHeaderValidation.js.map +1 -1
  75. package/dist/cjs/server/sse.js +14 -17
  76. package/dist/cjs/server/sse.js.map +1 -1
  77. package/dist/cjs/server/stdio.js +4 -7
  78. package/dist/cjs/server/stdio.js.map +1 -1
  79. package/dist/cjs/server/streamableHttp.d.ts +52 -154
  80. package/dist/cjs/server/streamableHttp.d.ts.map +1 -1
  81. package/dist/cjs/server/streamableHttp.js +78 -653
  82. package/dist/cjs/server/streamableHttp.js.map +1 -1
  83. package/dist/cjs/server/webStandardStreamableHttp.d.ts +267 -0
  84. package/dist/cjs/server/webStandardStreamableHttp.d.ts.map +1 -0
  85. package/dist/cjs/server/webStandardStreamableHttp.js +729 -0
  86. package/dist/cjs/server/webStandardStreamableHttp.js.map +1 -0
  87. package/dist/cjs/server/zod-compat.d.ts +3 -1
  88. package/dist/cjs/server/zod-compat.d.ts.map +1 -1
  89. package/dist/cjs/server/zod-compat.js +11 -19
  90. package/dist/cjs/server/zod-compat.js.map +1 -1
  91. package/dist/cjs/server/zod-json-schema-compat.js +5 -6
  92. package/dist/cjs/server/zod-json-schema-compat.js.map +1 -1
  93. package/dist/cjs/shared/metadataUtils.js +1 -2
  94. package/dist/cjs/shared/metadataUtils.js.map +1 -1
  95. package/dist/cjs/shared/protocol.d.ts +1 -1
  96. package/dist/cjs/shared/protocol.d.ts.map +1 -1
  97. package/dist/cjs/shared/protocol.js +76 -88
  98. package/dist/cjs/shared/protocol.js.map +1 -1
  99. package/dist/cjs/shared/transport.js +1 -1
  100. package/dist/cjs/shared/transport.js.map +1 -1
  101. package/dist/cjs/spec.types.d.ts +315 -26
  102. package/dist/cjs/spec.types.d.ts.map +1 -1
  103. package/dist/cjs/spec.types.js +2 -2
  104. package/dist/cjs/spec.types.js.map +1 -1
  105. package/dist/cjs/types.d.ts +1424 -1240
  106. package/dist/cjs/types.d.ts.map +1 -1
  107. package/dist/cjs/types.js +227 -136
  108. package/dist/cjs/types.js.map +1 -1
  109. package/dist/cjs/validation/ajv-provider.d.ts +1 -1
  110. package/dist/cjs/validation/ajv-provider.d.ts.map +1 -1
  111. package/dist/cjs/validation/ajv-provider.js +4 -5
  112. package/dist/cjs/validation/ajv-provider.js.map +1 -1
  113. package/dist/cjs/validation/cfworker-provider.js +4 -5
  114. package/dist/cjs/validation/cfworker-provider.js.map +1 -1
  115. package/dist/cjs/validation/types.d.ts +12 -2
  116. package/dist/cjs/validation/types.d.ts.map +1 -1
  117. package/dist/esm/client/auth-extensions.js +5 -9
  118. package/dist/esm/client/auth-extensions.js.map +1 -1
  119. package/dist/esm/client/auth.js +30 -37
  120. package/dist/esm/client/auth.js.map +1 -1
  121. package/dist/esm/client/index.d.ts +61 -14
  122. package/dist/esm/client/index.d.ts.map +1 -1
  123. package/dist/esm/client/index.js +118 -37
  124. package/dist/esm/client/index.js.map +1 -1
  125. package/dist/esm/client/middleware.js +3 -3
  126. package/dist/esm/client/middleware.js.map +1 -1
  127. package/dist/esm/client/sse.js +19 -27
  128. package/dist/esm/client/sse.js.map +1 -1
  129. package/dist/esm/client/stdio.js +18 -28
  130. package/dist/esm/client/stdio.js.map +1 -1
  131. package/dist/esm/client/streamableHttp.d.ts.map +1 -1
  132. package/dist/esm/client/streamableHttp.js +40 -50
  133. package/dist/esm/client/streamableHttp.js.map +1 -1
  134. package/dist/esm/client/websocket.js +6 -11
  135. package/dist/esm/client/websocket.js.map +1 -1
  136. package/dist/esm/examples/client/elicitationUrlExample.js +4 -5
  137. package/dist/esm/examples/client/elicitationUrlExample.js.map +1 -1
  138. package/dist/esm/examples/client/simpleOAuthClient.js +3 -3
  139. package/dist/esm/examples/client/simpleOAuthClient.js.map +1 -1
  140. package/dist/esm/examples/client/simpleStreamableHttp.js +7 -9
  141. package/dist/esm/examples/client/simpleStreamableHttp.js.map +1 -1
  142. package/dist/esm/examples/client/simpleTaskInteractiveClient.js +1 -2
  143. package/dist/esm/examples/client/simpleTaskInteractiveClient.js.map +1 -1
  144. package/dist/esm/examples/server/honoWebStandardStreamableHttp.d.ts +10 -0
  145. package/dist/esm/examples/server/honoWebStandardStreamableHttp.d.ts.map +1 -0
  146. package/dist/esm/examples/server/honoWebStandardStreamableHttp.js +56 -0
  147. package/dist/esm/examples/server/honoWebStandardStreamableHttp.js.map +1 -0
  148. package/dist/esm/examples/server/jsonResponseStreamableHttp.js +10 -4
  149. package/dist/esm/examples/server/jsonResponseStreamableHttp.js.map +1 -1
  150. package/dist/esm/examples/server/simpleSseServer.js +6 -3
  151. package/dist/esm/examples/server/simpleSseServer.js.map +1 -1
  152. package/dist/esm/examples/server/simpleStatelessStreamableHttp.js +12 -6
  153. package/dist/esm/examples/server/simpleStatelessStreamableHttp.js.map +1 -1
  154. package/dist/esm/examples/server/simpleStreamableHttp.js +21 -11
  155. package/dist/esm/examples/server/simpleStreamableHttp.js.map +1 -1
  156. package/dist/esm/examples/server/simpleTaskInteractive.js +7 -11
  157. package/dist/esm/examples/server/simpleTaskInteractive.js.map +1 -1
  158. package/dist/esm/examples/server/sseAndStreamableHttpCompatibleServer.js +10 -7
  159. package/dist/esm/examples/server/sseAndStreamableHttpCompatibleServer.js.map +1 -1
  160. package/dist/esm/examples/server/standaloneSseWithGetStreamableHttp.js +1 -1
  161. package/dist/esm/examples/server/standaloneSseWithGetStreamableHttp.js.map +1 -1
  162. package/dist/esm/experimental/tasks/client.js +1 -2
  163. package/dist/esm/experimental/tasks/client.js.map +1 -1
  164. package/dist/esm/experimental/tasks/helpers.js +3 -5
  165. package/dist/esm/experimental/tasks/helpers.js.map +1 -1
  166. package/dist/esm/experimental/tasks/interfaces.d.ts +3 -3
  167. package/dist/esm/experimental/tasks/interfaces.d.ts.map +1 -1
  168. package/dist/esm/experimental/tasks/stores/in-memory.d.ts +1 -1
  169. package/dist/esm/experimental/tasks/stores/in-memory.d.ts.map +1 -1
  170. package/dist/esm/experimental/tasks/stores/in-memory.js +3 -5
  171. package/dist/esm/experimental/tasks/stores/in-memory.js.map +1 -1
  172. package/dist/esm/inMemory.js +5 -7
  173. package/dist/esm/inMemory.js.map +1 -1
  174. package/dist/esm/server/auth/handlers/token.js +1 -1
  175. package/dist/esm/server/auth/handlers/token.js.map +1 -1
  176. package/dist/esm/server/auth/providers/proxyProvider.js +11 -17
  177. package/dist/esm/server/auth/providers/proxyProvider.js.map +1 -1
  178. package/dist/esm/server/auth/router.js +3 -6
  179. package/dist/esm/server/auth/router.js.map +1 -1
  180. package/dist/esm/server/completable.js +1 -1
  181. package/dist/esm/server/completable.js.map +1 -1
  182. package/dist/esm/server/index.d.ts +3 -3
  183. package/dist/esm/server/index.d.ts.map +1 -1
  184. package/dist/esm/server/index.js +20 -30
  185. package/dist/esm/server/index.js.map +1 -1
  186. package/dist/esm/server/mcp.d.ts.map +1 -1
  187. package/dist/esm/server/mcp.js +25 -11
  188. package/dist/esm/server/mcp.js.map +1 -1
  189. package/dist/esm/server/middleware/hostHeaderValidation.js +1 -1
  190. package/dist/esm/server/middleware/hostHeaderValidation.js.map +1 -1
  191. package/dist/esm/server/sse.js +14 -17
  192. package/dist/esm/server/sse.js.map +1 -1
  193. package/dist/esm/server/stdio.js +4 -7
  194. package/dist/esm/server/stdio.js.map +1 -1
  195. package/dist/esm/server/streamableHttp.d.ts +52 -154
  196. package/dist/esm/server/streamableHttp.d.ts.map +1 -1
  197. package/dist/esm/server/streamableHttp.js +78 -650
  198. package/dist/esm/server/streamableHttp.js.map +1 -1
  199. package/dist/esm/server/webStandardStreamableHttp.d.ts +267 -0
  200. package/dist/esm/server/webStandardStreamableHttp.d.ts.map +1 -0
  201. package/dist/esm/server/webStandardStreamableHttp.js +725 -0
  202. package/dist/esm/server/webStandardStreamableHttp.js.map +1 -0
  203. package/dist/esm/server/zod-compat.d.ts +3 -1
  204. package/dist/esm/server/zod-compat.d.ts.map +1 -1
  205. package/dist/esm/server/zod-compat.js +11 -19
  206. package/dist/esm/server/zod-compat.js.map +1 -1
  207. package/dist/esm/server/zod-json-schema-compat.js +5 -6
  208. package/dist/esm/server/zod-json-schema-compat.js.map +1 -1
  209. package/dist/esm/shared/metadataUtils.js +1 -2
  210. package/dist/esm/shared/metadataUtils.js.map +1 -1
  211. package/dist/esm/shared/protocol.d.ts +1 -1
  212. package/dist/esm/shared/protocol.d.ts.map +1 -1
  213. package/dist/esm/shared/protocol.js +77 -89
  214. package/dist/esm/shared/protocol.js.map +1 -1
  215. package/dist/esm/shared/transport.js +1 -1
  216. package/dist/esm/shared/transport.js.map +1 -1
  217. package/dist/esm/spec.types.d.ts +315 -26
  218. package/dist/esm/spec.types.d.ts.map +1 -1
  219. package/dist/esm/spec.types.js +2 -2
  220. package/dist/esm/spec.types.js.map +1 -1
  221. package/dist/esm/types.d.ts +1430 -1246
  222. package/dist/esm/types.d.ts.map +1 -1
  223. package/dist/esm/types.js +220 -130
  224. package/dist/esm/types.js.map +1 -1
  225. package/dist/esm/validation/ajv-provider.d.ts +1 -1
  226. package/dist/esm/validation/ajv-provider.d.ts.map +1 -1
  227. package/dist/esm/validation/ajv-provider.js +3 -4
  228. package/dist/esm/validation/ajv-provider.js.map +1 -1
  229. package/dist/esm/validation/cfworker-provider.js +4 -5
  230. package/dist/esm/validation/cfworker-provider.js.map +1 -1
  231. package/dist/esm/validation/types.d.ts +12 -2
  232. package/dist/esm/validation/types.d.ts.map +1 -1
  233. package/package.json +3 -1
@@ -1,18 +1,23 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
2
+ /**
3
+ * Node.js HTTP Streamable HTTP Server Transport
4
+ *
5
+ * This is a thin wrapper around `WebStandardStreamableHTTPServerTransport` that provides
6
+ * compatibility with Node.js HTTP server (IncomingMessage/ServerResponse).
7
+ *
8
+ * For web-standard environments (Cloudflare Workers, Deno, Bun), use `WebStandardStreamableHTTPServerTransport` directly.
9
+ */
5
10
  Object.defineProperty(exports, "__esModule", { value: true });
6
11
  exports.StreamableHTTPServerTransport = void 0;
7
- const types_js_1 = require("../types.js");
8
- const raw_body_1 = __importDefault(require("raw-body"));
9
- const content_type_1 = __importDefault(require("content-type"));
10
- const node_crypto_1 = require("node:crypto");
11
- const MAXIMUM_MESSAGE_SIZE = '4mb';
12
+ const node_server_1 = require("@hono/node-server");
13
+ const webStandardStreamableHttp_js_1 = require("./webStandardStreamableHttp.js");
12
14
  /**
13
15
  * Server transport for Streamable HTTP: this implements the MCP Streamable HTTP transport specification.
14
16
  * It supports both SSE streaming and direct HTTP responses.
15
17
  *
18
+ * This is a wrapper around `WebStandardStreamableHTTPServerTransport` that provides Node.js HTTP compatibility.
19
+ * It uses the `@hono/node-server` library to convert between Node.js HTTP and Web Standard APIs.
20
+ *
16
21
  * Usage example:
17
22
  *
18
23
  * ```typescript
@@ -44,579 +49,97 @@ const MAXIMUM_MESSAGE_SIZE = '4mb';
44
49
  * - No session validation is performed
45
50
  */
46
51
  class StreamableHTTPServerTransport {
47
- constructor(options) {
48
- var _a, _b;
49
- this._started = false;
50
- this._streamMapping = new Map();
51
- this._requestToStreamMapping = new Map();
52
- this._requestResponseMap = new Map();
53
- this._initialized = false;
54
- this._enableJsonResponse = false;
55
- this._standaloneSseStreamId = '_GET_stream';
56
- this.sessionIdGenerator = options.sessionIdGenerator;
57
- this._enableJsonResponse = (_a = options.enableJsonResponse) !== null && _a !== void 0 ? _a : false;
58
- this._eventStore = options.eventStore;
59
- this._onsessioninitialized = options.onsessioninitialized;
60
- this._onsessionclosed = options.onsessionclosed;
61
- this._allowedHosts = options.allowedHosts;
62
- this._allowedOrigins = options.allowedOrigins;
63
- this._enableDnsRebindingProtection = (_b = options.enableDnsRebindingProtection) !== null && _b !== void 0 ? _b : false;
64
- this._retryInterval = options.retryInterval;
52
+ constructor(options = {}) {
53
+ // Store auth and parsedBody per request for passing through to handleRequest
54
+ this._requestContext = new WeakMap();
55
+ this._webStandardTransport = new webStandardStreamableHttp_js_1.WebStandardStreamableHTTPServerTransport(options);
56
+ // Create a request listener that wraps the web standard transport
57
+ // getRequestListener converts Node.js HTTP to Web Standard and properly handles SSE streaming
58
+ this._requestListener = (0, node_server_1.getRequestListener)(async (webRequest) => {
59
+ // Get context if available (set during handleRequest)
60
+ const context = this._requestContext.get(webRequest);
61
+ return this._webStandardTransport.handleRequest(webRequest, {
62
+ authInfo: context?.authInfo,
63
+ parsedBody: context?.parsedBody
64
+ });
65
+ });
65
66
  }
66
67
  /**
67
- * Starts the transport. This is required by the Transport interface but is a no-op
68
- * for the Streamable HTTP transport as connections are managed per-request.
68
+ * Gets the session ID for this transport instance.
69
69
  */
70
- async start() {
71
- if (this._started) {
72
- throw new Error('Transport already started');
73
- }
74
- this._started = true;
70
+ get sessionId() {
71
+ return this._webStandardTransport.sessionId;
75
72
  }
76
73
  /**
77
- * Validates request headers for DNS rebinding protection.
78
- * @returns Error message if validation fails, undefined if validation passes.
74
+ * Sets callback for when the transport is closed.
79
75
  */
80
- validateRequestHeaders(req) {
81
- // Skip validation if protection is not enabled
82
- if (!this._enableDnsRebindingProtection) {
83
- return undefined;
84
- }
85
- // Validate Host header if allowedHosts is configured
86
- if (this._allowedHosts && this._allowedHosts.length > 0) {
87
- const hostHeader = req.headers.host;
88
- if (!hostHeader || !this._allowedHosts.includes(hostHeader)) {
89
- return `Invalid Host header: ${hostHeader}`;
90
- }
91
- }
92
- // Validate Origin header if allowedOrigins is configured
93
- if (this._allowedOrigins && this._allowedOrigins.length > 0) {
94
- const originHeader = req.headers.origin;
95
- if (originHeader && !this._allowedOrigins.includes(originHeader)) {
96
- return `Invalid Origin header: ${originHeader}`;
97
- }
98
- }
99
- return undefined;
76
+ set onclose(handler) {
77
+ this._webStandardTransport.onclose = handler;
100
78
  }
101
- /**
102
- * Handles an incoming HTTP request, whether GET or POST
103
- */
104
- async handleRequest(req, res, parsedBody) {
105
- var _a;
106
- // Validate request headers for DNS rebinding protection
107
- const validationError = this.validateRequestHeaders(req);
108
- if (validationError) {
109
- res.writeHead(403).end(JSON.stringify({
110
- jsonrpc: '2.0',
111
- error: {
112
- code: -32000,
113
- message: validationError
114
- },
115
- id: null
116
- }));
117
- (_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, new Error(validationError));
118
- return;
119
- }
120
- if (req.method === 'POST') {
121
- await this.handlePostRequest(req, res, parsedBody);
122
- }
123
- else if (req.method === 'GET') {
124
- await this.handleGetRequest(req, res);
125
- }
126
- else if (req.method === 'DELETE') {
127
- await this.handleDeleteRequest(req, res);
128
- }
129
- else {
130
- await this.handleUnsupportedRequest(res);
131
- }
79
+ get onclose() {
80
+ return this._webStandardTransport.onclose;
132
81
  }
133
82
  /**
134
- * Writes a priming event to establish resumption capability.
135
- * Only sends if eventStore is configured (opt-in for resumability) and
136
- * the client's protocol version supports empty SSE data (>= 2025-11-25).
83
+ * Sets callback for transport errors.
137
84
  */
138
- async _maybeWritePrimingEvent(res, streamId, protocolVersion) {
139
- if (!this._eventStore) {
140
- return;
141
- }
142
- // Priming events have empty data which older clients cannot handle.
143
- // Only send priming events to clients with protocol version >= 2025-11-25
144
- // which includes the fix for handling empty SSE data.
145
- if (protocolVersion < '2025-11-25') {
146
- return;
147
- }
148
- const primingEventId = await this._eventStore.storeEvent(streamId, {});
149
- let primingEvent = `id: ${primingEventId}\ndata: \n\n`;
150
- if (this._retryInterval !== undefined) {
151
- primingEvent = `id: ${primingEventId}\nretry: ${this._retryInterval}\ndata: \n\n`;
152
- }
153
- res.write(primingEvent);
85
+ set onerror(handler) {
86
+ this._webStandardTransport.onerror = handler;
154
87
  }
155
- /**
156
- * Handles GET requests for SSE stream
157
- */
158
- async handleGetRequest(req, res) {
159
- // The client MUST include an Accept header, listing text/event-stream as a supported content type.
160
- const acceptHeader = req.headers.accept;
161
- if (!(acceptHeader === null || acceptHeader === void 0 ? void 0 : acceptHeader.includes('text/event-stream'))) {
162
- res.writeHead(406).end(JSON.stringify({
163
- jsonrpc: '2.0',
164
- error: {
165
- code: -32000,
166
- message: 'Not Acceptable: Client must accept text/event-stream'
167
- },
168
- id: null
169
- }));
170
- return;
171
- }
172
- // If an Mcp-Session-Id is returned by the server during initialization,
173
- // clients using the Streamable HTTP transport MUST include it
174
- // in the Mcp-Session-Id header on all of their subsequent HTTP requests.
175
- if (!this.validateSession(req, res)) {
176
- return;
177
- }
178
- if (!this.validateProtocolVersion(req, res)) {
179
- return;
180
- }
181
- // Handle resumability: check for Last-Event-ID header
182
- if (this._eventStore) {
183
- const lastEventId = req.headers['last-event-id'];
184
- if (lastEventId) {
185
- await this.replayEvents(lastEventId, res);
186
- return;
187
- }
188
- }
189
- // The server MUST either return Content-Type: text/event-stream in response to this HTTP GET,
190
- // or else return HTTP 405 Method Not Allowed
191
- const headers = {
192
- 'Content-Type': 'text/event-stream',
193
- 'Cache-Control': 'no-cache, no-transform',
194
- Connection: 'keep-alive'
195
- };
196
- // After initialization, always include the session ID if we have one
197
- if (this.sessionId !== undefined) {
198
- headers['mcp-session-id'] = this.sessionId;
199
- }
200
- // Check if there's already an active standalone SSE stream for this session
201
- if (this._streamMapping.get(this._standaloneSseStreamId) !== undefined) {
202
- // Only one GET SSE stream is allowed per session
203
- res.writeHead(409).end(JSON.stringify({
204
- jsonrpc: '2.0',
205
- error: {
206
- code: -32000,
207
- message: 'Conflict: Only one SSE stream is allowed per session'
208
- },
209
- id: null
210
- }));
211
- return;
212
- }
213
- // We need to send headers immediately as messages will arrive much later,
214
- // otherwise the client will just wait for the first message
215
- res.writeHead(200, headers).flushHeaders();
216
- // Assign the response to the standalone SSE stream
217
- this._streamMapping.set(this._standaloneSseStreamId, res);
218
- // Set up close handler for client disconnects
219
- res.on('close', () => {
220
- this._streamMapping.delete(this._standaloneSseStreamId);
221
- });
222
- // Add error handler for standalone SSE stream
223
- res.on('error', error => {
224
- var _a;
225
- (_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, error);
226
- });
88
+ get onerror() {
89
+ return this._webStandardTransport.onerror;
227
90
  }
228
91
  /**
229
- * Replays events that would have been sent after the specified event ID
230
- * Only used when resumability is enabled
92
+ * Sets callback for incoming messages.
231
93
  */
232
- async replayEvents(lastEventId, res) {
233
- var _a;
234
- if (!this._eventStore) {
235
- return;
236
- }
237
- try {
238
- // If getStreamIdForEventId is available, use it for conflict checking
239
- let streamId;
240
- if (this._eventStore.getStreamIdForEventId) {
241
- streamId = await this._eventStore.getStreamIdForEventId(lastEventId);
242
- if (!streamId) {
243
- res.writeHead(400).end(JSON.stringify({
244
- jsonrpc: '2.0',
245
- error: {
246
- code: -32000,
247
- message: 'Invalid event ID format'
248
- },
249
- id: null
250
- }));
251
- return;
252
- }
253
- // Check conflict with the SAME streamId we'll use for mapping
254
- if (this._streamMapping.get(streamId) !== undefined) {
255
- res.writeHead(409).end(JSON.stringify({
256
- jsonrpc: '2.0',
257
- error: {
258
- code: -32000,
259
- message: 'Conflict: Stream already has an active connection'
260
- },
261
- id: null
262
- }));
263
- return;
264
- }
265
- }
266
- const headers = {
267
- 'Content-Type': 'text/event-stream',
268
- 'Cache-Control': 'no-cache, no-transform',
269
- Connection: 'keep-alive'
270
- };
271
- if (this.sessionId !== undefined) {
272
- headers['mcp-session-id'] = this.sessionId;
273
- }
274
- res.writeHead(200, headers).flushHeaders();
275
- // Replay events - returns the streamId for backwards compatibility
276
- const replayedStreamId = await this._eventStore.replayEventsAfter(lastEventId, {
277
- send: async (eventId, message) => {
278
- var _a;
279
- if (!this.writeSSEEvent(res, message, eventId)) {
280
- (_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, new Error('Failed replay events'));
281
- res.end();
282
- }
283
- }
284
- });
285
- this._streamMapping.set(replayedStreamId, res);
286
- // Set up close handler for client disconnects
287
- res.on('close', () => {
288
- this._streamMapping.delete(replayedStreamId);
289
- });
290
- // Add error handler for replay stream
291
- res.on('error', error => {
292
- var _a;
293
- (_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, error);
294
- });
295
- }
296
- catch (error) {
297
- (_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, error);
298
- }
94
+ set onmessage(handler) {
95
+ this._webStandardTransport.onmessage = handler;
299
96
  }
300
- /**
301
- * Writes an event to the SSE stream with proper formatting
302
- */
303
- writeSSEEvent(res, message, eventId) {
304
- let eventData = `event: message\n`;
305
- // Include event ID if provided - this is important for resumability
306
- if (eventId) {
307
- eventData += `id: ${eventId}\n`;
308
- }
309
- eventData += `data: ${JSON.stringify(message)}\n\n`;
310
- return res.write(eventData);
97
+ get onmessage() {
98
+ return this._webStandardTransport.onmessage;
311
99
  }
312
100
  /**
313
- * Handles unsupported requests (PUT, PATCH, etc.)
101
+ * Starts the transport. This is required by the Transport interface but is a no-op
102
+ * for the Streamable HTTP transport as connections are managed per-request.
314
103
  */
315
- async handleUnsupportedRequest(res) {
316
- res.writeHead(405, {
317
- Allow: 'GET, POST, DELETE'
318
- }).end(JSON.stringify({
319
- jsonrpc: '2.0',
320
- error: {
321
- code: -32000,
322
- message: 'Method not allowed.'
323
- },
324
- id: null
325
- }));
104
+ async start() {
105
+ return this._webStandardTransport.start();
326
106
  }
327
107
  /**
328
- * Handles POST requests containing JSON-RPC messages
108
+ * Closes the transport and all active connections.
329
109
  */
330
- async handlePostRequest(req, res, parsedBody) {
331
- var _a, _b, _c, _d, _e, _f;
332
- try {
333
- // Validate the Accept header
334
- const acceptHeader = req.headers.accept;
335
- // The client MUST include an Accept header, listing both application/json and text/event-stream as supported content types.
336
- if (!(acceptHeader === null || acceptHeader === void 0 ? void 0 : acceptHeader.includes('application/json')) || !acceptHeader.includes('text/event-stream')) {
337
- res.writeHead(406).end(JSON.stringify({
338
- jsonrpc: '2.0',
339
- error: {
340
- code: -32000,
341
- message: 'Not Acceptable: Client must accept both application/json and text/event-stream'
342
- },
343
- id: null
344
- }));
345
- return;
346
- }
347
- const ct = req.headers['content-type'];
348
- if (!ct || !ct.includes('application/json')) {
349
- res.writeHead(415).end(JSON.stringify({
350
- jsonrpc: '2.0',
351
- error: {
352
- code: -32000,
353
- message: 'Unsupported Media Type: Content-Type must be application/json'
354
- },
355
- id: null
356
- }));
357
- return;
358
- }
359
- const authInfo = req.auth;
360
- const requestInfo = { headers: req.headers };
361
- let rawMessage;
362
- if (parsedBody !== undefined) {
363
- rawMessage = parsedBody;
364
- }
365
- else {
366
- const parsedCt = content_type_1.default.parse(ct);
367
- const body = await (0, raw_body_1.default)(req, {
368
- limit: MAXIMUM_MESSAGE_SIZE,
369
- encoding: (_a = parsedCt.parameters.charset) !== null && _a !== void 0 ? _a : 'utf-8'
370
- });
371
- rawMessage = JSON.parse(body.toString());
372
- }
373
- let messages;
374
- // handle batch and single messages
375
- if (Array.isArray(rawMessage)) {
376
- messages = rawMessage.map(msg => types_js_1.JSONRPCMessageSchema.parse(msg));
377
- }
378
- else {
379
- messages = [types_js_1.JSONRPCMessageSchema.parse(rawMessage)];
380
- }
381
- // Check if this is an initialization request
382
- // https://spec.modelcontextprotocol.io/specification/2025-03-26/basic/lifecycle/
383
- const isInitializationRequest = messages.some(types_js_1.isInitializeRequest);
384
- if (isInitializationRequest) {
385
- // If it's a server with session management and the session ID is already set we should reject the request
386
- // to avoid re-initialization.
387
- if (this._initialized && this.sessionId !== undefined) {
388
- res.writeHead(400).end(JSON.stringify({
389
- jsonrpc: '2.0',
390
- error: {
391
- code: -32600,
392
- message: 'Invalid Request: Server already initialized'
393
- },
394
- id: null
395
- }));
396
- return;
397
- }
398
- if (messages.length > 1) {
399
- res.writeHead(400).end(JSON.stringify({
400
- jsonrpc: '2.0',
401
- error: {
402
- code: -32600,
403
- message: 'Invalid Request: Only one initialization request is allowed'
404
- },
405
- id: null
406
- }));
407
- return;
408
- }
409
- this.sessionId = (_b = this.sessionIdGenerator) === null || _b === void 0 ? void 0 : _b.call(this);
410
- this._initialized = true;
411
- // If we have a session ID and an onsessioninitialized handler, call it immediately
412
- // This is needed in cases where the server needs to keep track of multiple sessions
413
- if (this.sessionId && this._onsessioninitialized) {
414
- await Promise.resolve(this._onsessioninitialized(this.sessionId));
415
- }
416
- }
417
- if (!isInitializationRequest) {
418
- // If an Mcp-Session-Id is returned by the server during initialization,
419
- // clients using the Streamable HTTP transport MUST include it
420
- // in the Mcp-Session-Id header on all of their subsequent HTTP requests.
421
- if (!this.validateSession(req, res)) {
422
- return;
423
- }
424
- // Mcp-Protocol-Version header is required for all requests after initialization.
425
- if (!this.validateProtocolVersion(req, res)) {
426
- return;
427
- }
428
- }
429
- // check if it contains requests
430
- const hasRequests = messages.some(types_js_1.isJSONRPCRequest);
431
- if (!hasRequests) {
432
- // if it only contains notifications or responses, return 202
433
- res.writeHead(202).end();
434
- // handle each message
435
- for (const message of messages) {
436
- (_c = this.onmessage) === null || _c === void 0 ? void 0 : _c.call(this, message, { authInfo, requestInfo });
437
- }
438
- }
439
- else if (hasRequests) {
440
- // The default behavior is to use SSE streaming
441
- // but in some cases server will return JSON responses
442
- const streamId = (0, node_crypto_1.randomUUID)();
443
- // Extract protocol version for priming event decision.
444
- // For initialize requests, get from request params.
445
- // For other requests, get from header (already validated).
446
- const initRequest = messages.find(m => (0, types_js_1.isInitializeRequest)(m));
447
- const clientProtocolVersion = initRequest
448
- ? initRequest.params.protocolVersion
449
- : ((_d = req.headers['mcp-protocol-version']) !== null && _d !== void 0 ? _d : types_js_1.DEFAULT_NEGOTIATED_PROTOCOL_VERSION);
450
- if (!this._enableJsonResponse) {
451
- const headers = {
452
- 'Content-Type': 'text/event-stream',
453
- 'Cache-Control': 'no-cache',
454
- Connection: 'keep-alive'
455
- };
456
- // After initialization, always include the session ID if we have one
457
- if (this.sessionId !== undefined) {
458
- headers['mcp-session-id'] = this.sessionId;
459
- }
460
- res.writeHead(200, headers);
461
- await this._maybeWritePrimingEvent(res, streamId, clientProtocolVersion);
462
- }
463
- // Store the response for this request to send messages back through this connection
464
- // We need to track by request ID to maintain the connection
465
- for (const message of messages) {
466
- if ((0, types_js_1.isJSONRPCRequest)(message)) {
467
- this._streamMapping.set(streamId, res);
468
- this._requestToStreamMapping.set(message.id, streamId);
469
- }
470
- }
471
- // Set up close handler for client disconnects
472
- res.on('close', () => {
473
- this._streamMapping.delete(streamId);
474
- });
475
- // Add error handler for stream write errors
476
- res.on('error', error => {
477
- var _a;
478
- (_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, error);
479
- });
480
- // handle each message
481
- for (const message of messages) {
482
- // Build closeSSEStream callback for requests when eventStore is configured
483
- // AND client supports resumability (protocol version >= 2025-11-25).
484
- // Old clients can't resume if the stream is closed early because they
485
- // didn't receive a priming event with an event ID.
486
- let closeSSEStream;
487
- let closeStandaloneSSEStream;
488
- if ((0, types_js_1.isJSONRPCRequest)(message) && this._eventStore && clientProtocolVersion >= '2025-11-25') {
489
- closeSSEStream = () => {
490
- this.closeSSEStream(message.id);
491
- };
492
- closeStandaloneSSEStream = () => {
493
- this.closeStandaloneSSEStream();
494
- };
495
- }
496
- (_e = this.onmessage) === null || _e === void 0 ? void 0 : _e.call(this, message, { authInfo, requestInfo, closeSSEStream, closeStandaloneSSEStream });
497
- }
498
- // The server SHOULD NOT close the SSE stream before sending all JSON-RPC responses
499
- // This will be handled by the send() method when responses are ready
500
- }
501
- }
502
- catch (error) {
503
- // return JSON-RPC formatted error
504
- res.writeHead(400).end(JSON.stringify({
505
- jsonrpc: '2.0',
506
- error: {
507
- code: -32700,
508
- message: 'Parse error',
509
- data: String(error)
510
- },
511
- id: null
512
- }));
513
- (_f = this.onerror) === null || _f === void 0 ? void 0 : _f.call(this, error);
514
- }
110
+ async close() {
111
+ return this._webStandardTransport.close();
515
112
  }
516
113
  /**
517
- * Handles DELETE requests to terminate sessions
114
+ * Sends a JSON-RPC message through the transport.
518
115
  */
519
- async handleDeleteRequest(req, res) {
520
- var _a;
521
- if (!this.validateSession(req, res)) {
522
- return;
523
- }
524
- if (!this.validateProtocolVersion(req, res)) {
525
- return;
526
- }
527
- await Promise.resolve((_a = this._onsessionclosed) === null || _a === void 0 ? void 0 : _a.call(this, this.sessionId));
528
- await this.close();
529
- res.writeHead(200).end();
116
+ async send(message, options) {
117
+ return this._webStandardTransport.send(message, options);
530
118
  }
531
119
  /**
532
- * Validates session ID for non-initialization requests
533
- * Returns true if the session is valid, false otherwise
120
+ * Handles an incoming HTTP request, whether GET or POST.
121
+ *
122
+ * This method converts Node.js HTTP objects to Web Standard Request/Response
123
+ * and delegates to the underlying WebStandardStreamableHTTPServerTransport.
124
+ *
125
+ * @param req - Node.js IncomingMessage, optionally with auth property from middleware
126
+ * @param res - Node.js ServerResponse
127
+ * @param parsedBody - Optional pre-parsed body from body-parser middleware
534
128
  */
535
- validateSession(req, res) {
536
- if (this.sessionIdGenerator === undefined) {
537
- // If the sessionIdGenerator ID is not set, the session management is disabled
538
- // and we don't need to validate the session ID
539
- return true;
540
- }
541
- if (!this._initialized) {
542
- // If the server has not been initialized yet, reject all requests
543
- res.writeHead(400).end(JSON.stringify({
544
- jsonrpc: '2.0',
545
- error: {
546
- code: -32000,
547
- message: 'Bad Request: Server not initialized'
548
- },
549
- id: null
550
- }));
551
- return false;
552
- }
553
- const sessionId = req.headers['mcp-session-id'];
554
- if (!sessionId) {
555
- // Non-initialization requests without a session ID should return 400 Bad Request
556
- res.writeHead(400).end(JSON.stringify({
557
- jsonrpc: '2.0',
558
- error: {
559
- code: -32000,
560
- message: 'Bad Request: Mcp-Session-Id header is required'
561
- },
562
- id: null
563
- }));
564
- return false;
565
- }
566
- else if (Array.isArray(sessionId)) {
567
- res.writeHead(400).end(JSON.stringify({
568
- jsonrpc: '2.0',
569
- error: {
570
- code: -32000,
571
- message: 'Bad Request: Mcp-Session-Id header must be a single value'
572
- },
573
- id: null
574
- }));
575
- return false;
576
- }
577
- else if (sessionId !== this.sessionId) {
578
- // Reject requests with invalid session ID with 404 Not Found
579
- res.writeHead(404).end(JSON.stringify({
580
- jsonrpc: '2.0',
581
- error: {
582
- code: -32001,
583
- message: 'Session not found'
584
- },
585
- id: null
586
- }));
587
- return false;
588
- }
589
- return true;
590
- }
591
- validateProtocolVersion(req, res) {
592
- var _a;
593
- let protocolVersion = (_a = req.headers['mcp-protocol-version']) !== null && _a !== void 0 ? _a : types_js_1.DEFAULT_NEGOTIATED_PROTOCOL_VERSION;
594
- if (Array.isArray(protocolVersion)) {
595
- protocolVersion = protocolVersion[protocolVersion.length - 1];
596
- }
597
- if (!types_js_1.SUPPORTED_PROTOCOL_VERSIONS.includes(protocolVersion)) {
598
- res.writeHead(400).end(JSON.stringify({
599
- jsonrpc: '2.0',
600
- error: {
601
- code: -32000,
602
- message: `Bad Request: Unsupported protocol version (supported versions: ${types_js_1.SUPPORTED_PROTOCOL_VERSIONS.join(', ')})`
603
- },
604
- id: null
605
- }));
606
- return false;
607
- }
608
- return true;
609
- }
610
- async close() {
611
- var _a;
612
- // Close all SSE connections
613
- this._streamMapping.forEach(response => {
614
- response.end();
129
+ async handleRequest(req, res, parsedBody) {
130
+ // Store context for this request to pass through auth and parsedBody
131
+ // We need to intercept the request creation to attach this context
132
+ const authInfo = req.auth;
133
+ // Create a custom handler that includes our context
134
+ const handler = (0, node_server_1.getRequestListener)(async (webRequest) => {
135
+ return this._webStandardTransport.handleRequest(webRequest, {
136
+ authInfo,
137
+ parsedBody
138
+ });
615
139
  });
616
- this._streamMapping.clear();
617
- // Clear any pending responses
618
- this._requestResponseMap.clear();
619
- (_a = this.onclose) === null || _a === void 0 ? void 0 : _a.call(this);
140
+ // Delegate to the request listener which handles all the Node.js <-> Web Standard conversion
141
+ // including proper SSE streaming support
142
+ await handler(req, res);
620
143
  }
621
144
  /**
622
145
  * Close an SSE stream for a specific request, triggering client reconnection.
@@ -624,112 +147,14 @@ class StreamableHTTPServerTransport {
624
147
  * client will reconnect after the retry interval specified in the priming event.
625
148
  */
626
149
  closeSSEStream(requestId) {
627
- const streamId = this._requestToStreamMapping.get(requestId);
628
- if (!streamId)
629
- return;
630
- const stream = this._streamMapping.get(streamId);
631
- if (stream) {
632
- stream.end();
633
- this._streamMapping.delete(streamId);
634
- }
150
+ this._webStandardTransport.closeSSEStream(requestId);
635
151
  }
636
152
  /**
637
153
  * Close the standalone GET SSE stream, triggering client reconnection.
638
154
  * Use this to implement polling behavior for server-initiated notifications.
639
155
  */
640
156
  closeStandaloneSSEStream() {
641
- const stream = this._streamMapping.get(this._standaloneSseStreamId);
642
- if (stream) {
643
- stream.end();
644
- this._streamMapping.delete(this._standaloneSseStreamId);
645
- }
646
- }
647
- async send(message, options) {
648
- let requestId = options === null || options === void 0 ? void 0 : options.relatedRequestId;
649
- if ((0, types_js_1.isJSONRPCResponse)(message) || (0, types_js_1.isJSONRPCError)(message)) {
650
- // If the message is a response, use the request ID from the message
651
- requestId = message.id;
652
- }
653
- // Check if this message should be sent on the standalone SSE stream (no request ID)
654
- // Ignore notifications from tools (which have relatedRequestId set)
655
- // Those will be sent via dedicated response SSE streams
656
- if (requestId === undefined) {
657
- // For standalone SSE streams, we can only send requests and notifications
658
- if ((0, types_js_1.isJSONRPCResponse)(message) || (0, types_js_1.isJSONRPCError)(message)) {
659
- throw new Error('Cannot send a response on a standalone SSE stream unless resuming a previous client request');
660
- }
661
- // Generate and store event ID if event store is provided
662
- // Store even if stream is disconnected so events can be replayed on reconnect
663
- let eventId;
664
- if (this._eventStore) {
665
- // Stores the event and gets the generated event ID
666
- eventId = await this._eventStore.storeEvent(this._standaloneSseStreamId, message);
667
- }
668
- const standaloneSse = this._streamMapping.get(this._standaloneSseStreamId);
669
- if (standaloneSse === undefined) {
670
- // Stream is disconnected - event is stored for replay, nothing more to do
671
- return;
672
- }
673
- // Send the message to the standalone SSE stream
674
- this.writeSSEEvent(standaloneSse, message, eventId);
675
- return;
676
- }
677
- // Get the response for this request
678
- const streamId = this._requestToStreamMapping.get(requestId);
679
- const response = this._streamMapping.get(streamId);
680
- if (!streamId) {
681
- throw new Error(`No connection established for request ID: ${String(requestId)}`);
682
- }
683
- if (!this._enableJsonResponse) {
684
- // For SSE responses, generate event ID if event store is provided
685
- let eventId;
686
- if (this._eventStore) {
687
- eventId = await this._eventStore.storeEvent(streamId, message);
688
- }
689
- if (response) {
690
- // Write the event to the response stream
691
- this.writeSSEEvent(response, message, eventId);
692
- }
693
- }
694
- if ((0, types_js_1.isJSONRPCResponse)(message) || (0, types_js_1.isJSONRPCError)(message)) {
695
- this._requestResponseMap.set(requestId, message);
696
- const relatedIds = Array.from(this._requestToStreamMapping.entries())
697
- .filter(([_, streamId]) => this._streamMapping.get(streamId) === response)
698
- .map(([id]) => id);
699
- // Check if we have responses for all requests using this connection
700
- const allResponsesReady = relatedIds.every(id => this._requestResponseMap.has(id));
701
- if (allResponsesReady) {
702
- if (!response) {
703
- throw new Error(`No connection established for request ID: ${String(requestId)}`);
704
- }
705
- if (this._enableJsonResponse) {
706
- // All responses ready, send as JSON
707
- const headers = {
708
- 'Content-Type': 'application/json'
709
- };
710
- if (this.sessionId !== undefined) {
711
- headers['mcp-session-id'] = this.sessionId;
712
- }
713
- const responses = relatedIds.map(id => this._requestResponseMap.get(id));
714
- response.writeHead(200, headers);
715
- if (responses.length === 1) {
716
- response.end(JSON.stringify(responses[0]));
717
- }
718
- else {
719
- response.end(JSON.stringify(responses));
720
- }
721
- }
722
- else {
723
- // End the SSE stream
724
- response.end();
725
- }
726
- // Clean up
727
- for (const id of relatedIds) {
728
- this._requestResponseMap.delete(id);
729
- this._requestToStreamMapping.delete(id);
730
- }
731
- }
732
- }
157
+ this._webStandardTransport.closeStandaloneSSEStream();
733
158
  }
734
159
  }
735
160
  exports.StreamableHTTPServerTransport = StreamableHTTPServerTransport;