File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed
examples/servers/simple-streamablehttp/mcp_simple_streamablehttp Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -82,6 +82,11 @@ async def call_tool(
8282 level = "info" ,
8383 data = f"Notification { i + 1 } /{ count } from caller: { caller } " ,
8484 logger = "notification_stream" ,
85+ # Associates this notification with the original request
86+ # Ensures notifications are sent to the correct response stream
87+ # Without this, notifications will either go to:
88+ # - a standalone SSE stream (if GET request is supported)
89+ # - nowhere (if GET request isn't supported)
8590 related_request_id = ctx .request_id ,
8691 )
8792 if i < count - 1 : # Don't wait after the last notification
Original file line number Diff line number Diff line change @@ -466,6 +466,7 @@ async def run_stdio_async(self) -> None:
466466 async def run_sse_async (self ) -> None :
467467 """Run the server using SSE transport."""
468468 import uvicorn
469+
469470 starlette_app = self .sse_app ()
470471
471472 config = uvicorn .Config (
@@ -673,7 +674,10 @@ async def log(
673674 **extra: Additional structured data to include
674675 """
675676 await self .request_context .session .send_log_message (
676- level = level , data = message , logger = logger_name
677+ level = level ,
678+ data = message ,
679+ logger = logger_name ,
680+ related_request_id = self .request_id ,
677681 )
678682
679683 @property
You can’t perform that action at this time.
0 commit comments