Skip to content

SDKs and other middleware SHOULD allow these timeouts to be configured on a per-request basis. #600

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
grll opened this issue Apr 29, 2025 · 1 comment

Comments

@grll
Copy link
Contributor

grll commented Apr 29, 2025

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:

async def send_request(
   self,
   request: SendRequestT,
   result_type: type[ReceiveResultT],
) -> ReceiveResultT:
    ...
        try:
            with anyio.fail_after(
                None
                if self._read_timeout_seconds is None
                else self._read_timeout_seconds.total_seconds()
            ):
                response_or_error = await response_stream_reader.receive()
        except TimeoutError:
            raise McpError(
                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.

@grll
Copy link
Contributor Author

grll commented Apr 29, 2025

also maybe on another note but I find calling the argument read_timeout_seconds and using a timedelta a bit odd, I would expect an int to be passed for "seconds"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant