deer-flow/extensions_config.example.json
bjtolo c9a5f23e7b
feat(mcp): add per-server tool_call_timeout for MCP tool calls (#3843)
* feat(mcp): add per-server tool_call_timeout for MCP tool calls

Add a configurable timeout for individual MCP tool calls to prevent
agent runs from blocking indefinitely when an MCP server becomes
unresponsive (e.g., rate-limited HTTP API, hung subprocess).

Uses the MCP SDK's built-in read_timeout_seconds parameter on
ClientSession.call_tool, which handles the timeout within the
session's own task — avoiding cross-task cancellation issues with
the session pool (ref #3379, #3203).

Config field is named tool_call_timeout (not timeout) to avoid
collision with langchain-mcp-adapters' existing timeout field on
HTTP/SSE connections.

Closes #3840

* fix(mcp): read tool_call_timeout from McpServerConfig, not connection dict

The previous implementation put tool_call_timeout into the connection dict
returned by build_server_params, which langchain's create_session then
passed to _create_stdio_session(), causing TypeError. Now reads the timeout
directly from ExtensionsConfig.mcp_servers where the wrapper is built,
keeping it out of the connection dict entirely.

Fixes P1 bug from review on #3843.

* test(mcp): regression test for tool_call_timeout not leaking into connection dict

Adds two tests:
- test_build_server_params_excludes_tool_call_timeout: verifies the connection
  dict returned by build_server_params() does NOT contain tool_call_timeout
- test_stdio_tool_call_timeout_does_not_raise_typeerror: end-to-end test that
  get_mcp_tools() with a stdio server having tool_call_timeout configured loads
  tools without TypeError from _create_stdio_session()

Regression for PR #3843 P1 bug.

* fix(mcp): only pass read_timeout_seconds when tool_call_timeout is set

When tool_call_timeout is None, don't pass read_timeout_seconds=None to
session.call_tool(). This avoids breaking existing tests that assert on
exact call_tool arguments without the extra kwarg.

* docs(mcp): clarify stdio tool timeout
2026-07-03 15:39:12 +08:00

34 lines
748 B
JSON

{
"mcpInterceptors": [
"my_package.mcp.auth:build_auth_interceptor"
],
"mcpServers": {
"github": {
"enabled": false,
"type": "stdio",
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-github"
],
"env": {
"GITHUB_TOKEN": "$GITHUB_TOKEN"
},
"tool_call_timeout": 60,
"description": "GitHub MCP server for repository operations"
},
"postgres": {
"enabled": false,
"type": "stdio",
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-postgres",
"postgresql://localhost/mydb"
],
"env": {},
"description": "PostgreSQL database access"
}
},
"skills": {}
}