Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ app.post('/mcp', async (req, res) => {
// New initialization request
transport = new StreamableHTTPServerTransport({
sessionIdGenerator: () => randomUUID(),
onsessioninitialized: (sessionId) => {
onSessionInitialized: (sessionId) => {
// Store the transport by session ID
transports[sessionId] = transport;
},
Expand Down
2 changes: 1 addition & 1 deletion src/examples/server/jsonResponseStreamableHttp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ app.post('/mcp', async (req: Request, res: Response) => {
transport = new StreamableHTTPServerTransport({
sessionIdGenerator: () => randomUUID(),
enableJsonResponse: true, // Enable JSON response mode
onsessioninitialized: (sessionId) => {
onSessionInitialized: (sessionId) => {
// Store the transport by session ID when session is initialized
// This avoids race conditions where requests might come in before the session is stored
console.log(`Session initialized with ID: ${sessionId}`);
Expand Down
2 changes: 1 addition & 1 deletion src/examples/server/simpleStreamableHttp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ const mcpPostHandler = async (req: Request, res: Response) => {
transport = new StreamableHTTPServerTransport({
sessionIdGenerator: () => randomUUID(),
eventStore, // Enable resumability
onsessioninitialized: (sessionId) => {
onSessionInitialized: (sessionId) => {
// Store the transport by session ID when session is initialized
// This avoids race conditions where requests might come in before the session is stored
console.log(`Session initialized with ID: ${sessionId}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ app.all('/mcp', async (req: Request, res: Response) => {
transport = new StreamableHTTPServerTransport({
sessionIdGenerator: () => randomUUID(),
eventStore, // Enable resumability
onsessioninitialized: (sessionId) => {
onSessionInitialized: (sessionId) => {
// Store the transport by session ID when session is initialized
console.log(`StreamableHTTP session initialized with ID: ${sessionId}`);
transports[sessionId] = transport;
Expand Down
4 changes: 2 additions & 2 deletions src/examples/server/standaloneSseWithGetStreamableHttp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ app.post('/mcp', async (req: Request, res: Response) => {
// New initialization request
transport = new StreamableHTTPServerTransport({
sessionIdGenerator: () => randomUUID(),
onsessioninitialized: (sessionId) => {
onSessionInitialized: (sessionId) => {
// Store the transport by session ID when session is initialized
// This avoids race conditions where requests might come in before the session is stored
console.log(`Session initialized with ID: ${sessionId}`);
Expand All @@ -63,7 +63,7 @@ app.post('/mcp', async (req: Request, res: Response) => {
// Connect the transport to the MCP server
await server.connect(transport);

// Handle the request - the onsessioninitialized callback will store the transport
// Handle the request - the onSessionInitialized callback will store the transport
await transport.handleRequest(req, res, req.body);
return; // Already handled
} else {
Expand Down
12 changes: 6 additions & 6 deletions src/server/streamableHttp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export interface StreamableHTTPServerTransportOptions {
* and need to keep track of them.
* @param sessionId The generated session ID
*/
onsessioninitialized?: (sessionId: string) => void;
onSessionInitialized?: (sessionId: string) => void;

/**
* If true, the server will return JSON responses instead of starting an SSE stream.
Expand Down Expand Up @@ -126,7 +126,7 @@ export class StreamableHTTPServerTransport implements Transport {
private _enableJsonResponse: boolean = false;
private _standaloneSseStreamId: string = '_GET_stream';
private _eventStore?: EventStore;
private _onsessioninitialized?: (sessionId: string) => void;
private _onSessionInitialized?: (sessionId: string) => void;
private _allowedHosts?: string[];
private _allowedOrigins?: string[];
private _enableDnsRebindingProtection: boolean;
Expand All @@ -140,7 +140,7 @@ export class StreamableHTTPServerTransport implements Transport {
this.sessionIdGenerator = options.sessionIdGenerator;
this._enableJsonResponse = options.enableJsonResponse ?? false;
this._eventStore = options.eventStore;
this._onsessioninitialized = options.onsessioninitialized;
this._onSessionInitialized = options.onSessionInitialized;
this._allowedHosts = options.allowedHosts;
this._allowedOrigins = options.allowedOrigins;
this._enableDnsRebindingProtection = options.enableDnsRebindingProtection ?? false;
Expand Down Expand Up @@ -443,10 +443,10 @@ export class StreamableHTTPServerTransport implements Transport {
this.sessionId = this.sessionIdGenerator?.();
this._initialized = true;

// If we have a session ID and an onsessioninitialized handler, call it immediately
// If we have a session ID and an onSessionInitialized handler, call it immediately
// This is needed in cases where the server needs to keep track of multiple sessions
if (this.sessionId && this._onsessioninitialized) {
this._onsessioninitialized(this.sessionId);
if (this.sessionId && this._onSessionInitialized) {
this._onSessionInitialized(this.sessionId);
}

}
Expand Down