Skip to content

Fix MCP call_tool ignoring per-server tool_timeout#1175

Open
PaoloC68 wants to merge 1 commit intoagent0ai:developmentfrom
PaoloC68:fix/mcp-per-server-tool-timeout
Open

Fix MCP call_tool ignoring per-server tool_timeout#1175
PaoloC68 wants to merge 1 commit intoagent0ai:developmentfrom
PaoloC68:fix/mcp-per-server-tool-timeout

Conversation

@PaoloC68
Copy link

@PaoloC68 PaoloC68 commented Mar 1, 2026

Summary

  • call_tool in MCPClientBase always used the global mcp_client_tool_timeout setting, ignoring the per-server tool_timeout override
  • This caused tools with long execution times (e.g., Perplexity deep research at 5-20 min) to timeout prematurely at the global default (120s), even when the server config specified a higher timeout
  • Applied the same resolution pattern already used for SSE/HTTP transport connections (line ~1110): prefer per-server tool_timeout, fall back to global setting

The Bug

# BEFORE (line 984) - always uses global timeout
read_timeout_seconds=timedelta(seconds=set["mcp_client_tool_timeout"])

# AFTER - per-server override takes precedence
tool_timeout = self.server.tool_timeout or set["mcp_client_tool_timeout"]
read_timeout_seconds=timedelta(seconds=tool_timeout)

The per-server tool_timeout was already being used for the transport-level SSE read timeout, but not for the actual MCP protocol call_tool operation. This one-line fix makes them consistent.

Impact

Any MCP server with a custom tool_timeout in its config was silently having that value ignored during tool execution. Only the transport connection respected it.

Testing

  • Verified the fix resolves Perplexity deep research timeouts (configured tool_timeout: 1200 for 20-minute research queries)
  • No changes to behavior for servers without a custom tool_timeout (falls back to global as before)

The call_tool method always used the global mcp_client_tool_timeout
setting, ignoring the per-server tool_timeout override. This caused
tools with long execution times (e.g. Perplexity deep research) to
timeout prematurely at the global default (120s) even when the server
config specified a higher timeout.

Apply the same resolution pattern already used for SSE/HTTP transport
connections (line 1110): prefer per-server tool_timeout, fall back to
global setting.
@PaoloC68 PaoloC68 force-pushed the fix/mcp-per-server-tool-timeout branch from de59f95 to 2708025 Compare March 12, 2026 10:58
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

Successfully merging this pull request may close these issues.

1 participant