Skip to content

Commit 87722f8

Browse files
committed
add constant for request cancelled and use it in case of cancelled task
1 parent 2a24e0c commit 87722f8

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/mcp/shared/session.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
ServerNotification,
3030
ServerRequest,
3131
ServerResult,
32+
REQUEST_CANCELLED,
3233
)
3334

3435
SendRequestT = TypeVar("SendRequestT", ClientRequest, ServerRequest)
@@ -279,7 +280,7 @@ async def send_request(
279280
)
280281

281282
raise McpError(
282-
ErrorData(code=32601, message="Request cancelled")
283+
ErrorData(code=REQUEST_CANCELLED, message="Request cancelled")
283284
)
284285

285286
except TimeoutError:

src/mcp/types.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ class JSONRPCResponse(BaseModel):
146146
METHOD_NOT_FOUND = -32601
147147
INVALID_PARAMS = -32602
148148
INTERNAL_ERROR = -32603
149+
REQUEST_CANCELLED = -32604
149150

150151

151152
class ErrorData(BaseModel):

0 commit comments

Comments
 (0)