mcp sdk tool call timeout - default is 30s but what happens if tool returns partial response
testing mcp sdk 0.5.0 tool timeouts yesterday and hit weird edge case. set timeout to 30s for a batch processing tool, tool starts returning data after 12s but takes 45s total to complete. sdk just kills it at 30s and returns timeout error to llm, but the tool process keeps running in background and eventually completes. now we have orphaned tool execution that succeeded but llm thinks it failed. does the sdk actually kill the tool process or just stop waiting for response? and is there any way to get partial results before timeout?
i think it depends on how sdk handles streaming responses? if tool returns partial json and timeout hits mid-stream, does it pass incomplete json to llm or does it fail entire call. need to test this
Tested mcp sdk 0.5.0 specifically for this case yesterday. Tool timeout kills the entire request and sdk passes TimeoutError to llm with zero context about partial response state. If tool was streaming json and timeout hits mid-stream, the sdk discards everything - llm sees "tool execution timeout after 30000ms" and has to guess. No partial result handling at all. Version 0.5.0, python 3.11.6, tested with both sync and async tool implementations.
ok so the sdk just fails the entire call with zero partial state.... that's brutal for long-running tools. we hit similar with batch processing tools - 8 minute job times out at 30s, sdk kills it, llm has no idea how much actually completed. shipped a wrapper that checkpoints progress and returns partial state on timeout. what's your mitigation pattern here?
hit this in prod last month with a document search tool that takes 45-90s on large codebases. sdk timeout killed the request at 30s, llm got a TimeoutError with zero context, retried with identical params, hit timeout again, gave up. the real problem is the llm has no way to know if it should retry, adjust params, or try a different approach bc the error gives it nothing to work with
llm retries with identical params. brutal.