Describe the bug
According to the MCP specs:
"SDKs and other middleware SHOULD allow these timeouts to be configured on a per-request basis."
But looking at the code the timeouts are set at the session level and not easily configured on a per-request basis as the specs recommend:
asyncdefsend_request(
self,
request: SendRequestT,
result_type: type[ReceiveResultT],
) ->ReceiveResultT:
...
try:
withanyio.fail_after(
Noneifself._read_timeout_secondsisNoneelseself._read_timeout_seconds.total_seconds()
):
response_or_error=awaitresponse_stream_reader.receive()
exceptTimeoutError:
raiseMcpError(
ErrorData(
code=httpx.codes.REQUEST_TIMEOUT,
message=(
f"Timed out while waiting for response to "f"{request.__class__.__name__}. Waited "f"{self._read_timeout_seconds} seconds."
),
)
)see
Suggestion
Add an optional argument request_read_timeout_seconds and rename current _read_timeout_seconds into session_read_timeout_seconds if request_read_timeout_seconds is set it would override the session one.
I will publish a small PR in that sense.
Describe the bug
According to the MCP specs:
But looking at the code the timeouts are set at the session level and not easily configured on a per-request basis as the specs recommend:
see
Suggestion
Add an optional argument
request_read_timeout_secondsand rename current _read_timeout_seconds intosession_read_timeout_secondsifrequest_read_timeout_secondsis set it would override the session one.I will publish a small PR in that sense.