Repository navigation
How to control when timeout occurs? #1207
Replies: 5 comments 2 replies
|
Timeouts are controlled on the client side, not the server side. This is necessary because a misbehaving server may never respond (even if it "meant to"). You may want to consider prefetching the resource, or introducing some kind of multi-step loading, like:
Though this question did make me think that we could support auto-extending timeouts when progress notifications are used, which doesn't currently happen. |
|
Thanks tons for the response about timeouts! Reading the MCP Python SDK documentation, I see examples of progress tracking using request_context.meta.progressToken, but when I tried this it turned out these objects (context and progressToken) are None when accessed through server.request_context. Is this because progress notification support needs to be implemented on the client side first? The documentation suggests this functionality but if I understand correctly, I should focus on implementing the multi-step approach you suggested instead of trying to use progress notifications at this point? |
This comment was marked as spam.
This comment was marked as spam.
|
The original answer is still correct about one important boundary: the server cannot extend a timeout chosen by the client. However, MCP 2025-11-25 added an experimental protocol-native option for this exact class of long-running work: Tasks. If both sides support it, the flow is now:
This prevents the 20–40 second upstream call from having to fit inside one synchronous request timeout, while keeping cancellation, deferred result retrieval, and reconnection semantics in the protocol. A couple of practical details:
So the implementation choice is:
Official references: |
|
We've limited Discussions in this repository to meeting notes and are closing this thread. To continue the conversation, pick a channel from Contributor Communication. Thanks for posting. |
Uh oh!
There was an error while loading. Please reload this page.
Pre-submission Checklist
Question Category
Your Question
Using Python SDK how can I set how long MCP implementation should wait for the response from an external resource? I am building an mcp server which talks to a resource that sometimes takes about 20-40 seconds to respond, so the response is never returned because a timeout occurs. Looked at the docs but I don't see indication how to do this.
All reactions