Skip to content

Commit 6665645

Browse files
committed
Fix shouldupgradetostreaming
Signed-off-by: Marcos Candeia <[email protected]>
1 parent 8337b3f commit 6665645

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

mcp/stateless.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
} from "@modelcontextprotocol/sdk/types.js";
66
import { ServerSentEventStream } from "@std/http";
77

8+
const SSE_STREAM_METHODS = ["notifications/initialized"];
89
/**
910
* Server transport for Stateless HTTP: this will handle messages over plain HTTP requests
1011
* with optional SSE upgrade for streaming responses.
@@ -79,7 +80,8 @@ export class StatelessServerTransport implements Transport {
7980
private shouldUpgradeToStreaming(message: JSONRPCMessage): boolean {
8081
// Implement logic to determine if streaming is needed
8182
// For example, based on method name or parameters
82-
return message.method === "notifications/initialized"; // Default to non-streaming
83+
return "method" in message && typeof message.method === "string" &&
84+
SSE_STREAM_METHODS.includes(message.method);
8385
}
8486

8587
start(): Promise<void> {

0 commit comments

Comments
 (0)