Skip to content

Commit 8c51d39

Browse files
chulkileequuu
andauthored
Add sessionIdGenerator config (#121)
* add sessionIdGenerator config * Changeset --------- Co-authored-by: Andrew Qu <qual1337@gmail.com>
1 parent 72f6001 commit 8c51d39

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

.changeset/wide-points-search.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"mcp-handler": patch
3+
---
4+
5+
Allow passing in sessionIdGenerator for stateful sessions

src/handler/mcp-api-handler.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,11 @@ export type Config = {
126126
* @default false
127127
*/
128128
disableSse?: boolean;
129+
130+
/**
131+
* sessionIdGenerator for the streamable HTTP transport
132+
*/
133+
sessionIdGenerator?: undefined;
129134
};
130135

131136
/**
@@ -248,6 +253,7 @@ export function initializeMcpApiHandler(
248253
maxDuration,
249254
verboseLogs,
250255
disableSse,
256+
sessionIdGenerator,
251257
} = config;
252258

253259
const {
@@ -273,7 +279,7 @@ export function initializeMcpApiHandler(
273279

274280
let statelessServer: McpServer;
275281
const statelessTransport = new StreamableHTTPServerTransport({
276-
sessionIdGenerator: undefined,
282+
sessionIdGenerator: sessionIdGenerator,
277283
});
278284

279285
// Start periodic cleanup if not already running

0 commit comments

Comments
 (0)