Skip to content

Commit e95b00f

Browse files
committed
Merge branch 'main' into ihrpr/use-session-message-for-related-request
2 parents f6cea03 + da0cf22 commit e95b00f

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

src/mcp/server/lowlevel/server.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -480,11 +480,11 @@ async def run(
480480
# but also make tracing exceptions much easier during testing and when using
481481
# in-process servers.
482482
raise_exceptions: bool = False,
483-
# When True, the server runs in standalone mode for stateless deployments where
483+
# When True, the server as stateless deployments where
484484
# clients can perform initialization with any node. The client must still follow
485485
# the initialization lifecycle, but can do so with any available node
486486
# rather than requiring initialization for each connection.
487-
standalone_mode: bool = False,
487+
stateless: bool = False,
488488
):
489489
async with AsyncExitStack() as stack:
490490
lifespan_context = await stack.enter_async_context(self.lifespan(self))
@@ -493,7 +493,7 @@ async def run(
493493
read_stream,
494494
write_stream,
495495
initialization_options,
496-
standalone_mode=standalone_mode,
496+
stateless=stateless,
497497
)
498498
)
499499

src/mcp/server/session.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,17 @@ def __init__(
8686
read_stream: MemoryObjectReceiveStream[SessionMessage | Exception],
8787
write_stream: MemoryObjectSendStream[SessionMessage],
8888
init_options: InitializationOptions,
89-
standalone_mode: bool = False,
89+
stateless: bool = False,
9090
) -> None:
9191
super().__init__(
9292
read_stream, write_stream, types.ClientRequest, types.ClientNotification
9393
)
94-
if standalone_mode:
95-
self._initialization_state = InitializationState.Initialized
96-
else:
97-
self._initialization_state = InitializationState.NotInitialized
94+
self._initialization_state = (
95+
InitializationState.Initialized
96+
if stateless
97+
else InitializationState.NotInitialized
98+
)
99+
98100
self._init_options = init_options
99101
self._incoming_message_stream_writer, self._incoming_message_stream_reader = (
100102
anyio.create_memory_object_stream[ServerRequestResponder](0)

src/mcp/server/streamable_http.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -551,11 +551,9 @@ async def _handle_get_request(self, request: Request, send: Send) -> None:
551551
if not await self._validate_session(request, send):
552552
return
553553
# Handle resumability: check for Last-Event-ID header
554-
if self._event_store:
555-
last_event_id = request.headers.get(LAST_EVENT_ID_HEADER)
556-
if last_event_id:
557-
await self._replay_events(last_event_id, request, send)
558-
return
554+
if last_event_id := request.headers.get(LAST_EVENT_ID_HEADER):
555+
await self._replay_events(last_event_id, request, send)
556+
return
559557

560558
headers = {
561559
"Cache-Control": "no-cache, no-transform",

0 commit comments

Comments
 (0)