keryx 0.36.0 → 0.36.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/util/mcpServer.ts +23 -15
package/package.json
CHANGED
package/util/mcpServer.ts
CHANGED
|
@@ -324,21 +324,29 @@ export async function adoptMcpSession(
|
|
|
324
324
|
const promise = (async () => {
|
|
325
325
|
const mcpServer = createMcpServer();
|
|
326
326
|
api.mcp.mcpServers.push(mcpServer);
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
327
|
+
try {
|
|
328
|
+
const transport = new WebStandardStreamableHTTPServerTransport({
|
|
329
|
+
sessionIdGenerator: () => sessionId,
|
|
330
|
+
enableJsonResponse: true,
|
|
331
|
+
// Local registration only — no hooks, no registry write (see doc above).
|
|
332
|
+
onsessioninitialized: (sid) => {
|
|
333
|
+
api.mcp.transports.set(sid, { transport, clientId });
|
|
334
|
+
},
|
|
335
|
+
onsessionclosed: (sid) => terminateMcpSession(sid, mcpServer),
|
|
336
|
+
});
|
|
337
|
+
transport.onclose = () =>
|
|
338
|
+
forgetMcpSession(transport.sessionId, mcpServer);
|
|
339
|
+
|
|
340
|
+
await mcpServer.connect(transport);
|
|
341
|
+
await driveSyntheticInitialize(transport, protocolVersion);
|
|
342
|
+
return transport;
|
|
343
|
+
} catch (e) {
|
|
344
|
+
// Adoption failed partway (e.g. the synthetic initialize errored) — drop
|
|
345
|
+
// the McpServer we optimistically registered so it can't linger in the
|
|
346
|
+
// broadcast list nor leave a half-initialized transport behind.
|
|
347
|
+
forgetMcpSession(sessionId, mcpServer);
|
|
348
|
+
throw e;
|
|
349
|
+
}
|
|
342
350
|
})();
|
|
343
351
|
|
|
344
352
|
adoptionsInFlight.set(sessionId, promise);
|