Skip to content

Commit 17ae44c

Browse files
committed
1 parent 1364b7a commit 17ae44c

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/mcp/client/session.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ async def initialize(self) -> types.InitializeResult:
140140
)
141141
),
142142
types.InitializeResult,
143+
cancellable=False
143144
)
144145

145146
if result.protocolVersion not in SUPPORTED_PROTOCOL_VERSIONS:

src/mcp/shared/session.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ async def send_request(
216216
result_type: type[ReceiveResultT],
217217
request_read_timeout_seconds: timedelta | None = None,
218218
metadata: MessageMetadata = None,
219+
cancellable: bool = True,
219220
) -> ReceiveResultT:
220221
"""
221222
Sends a request and wait for a response. Raises an McpError if the
@@ -260,7 +261,7 @@ async def send_request(
260261
with anyio.fail_after(timeout) as scope:
261262
response_or_error = await response_stream_reader.receive()
262263

263-
if scope.cancel_called:
264+
if cancellable and scope.cancel_called:
264265
with anyio.CancelScope(shield=True):
265266
notification = CancelledNotification(
266267
method="notifications/cancelled",

0 commit comments

Comments
 (0)