Fix OAuth MCP server timeouts with fastmcp 3.x compatibility#2189
Draft
jpshackelford wants to merge 1 commit intomainfrom
Draft
Fix OAuth MCP server timeouts with fastmcp 3.x compatibility#2189jpshackelford wants to merge 1 commit intomainfrom
jpshackelford wants to merge 1 commit intomainfrom
Conversation
This PR addresses issue #2184 where OAuth-based MCP servers (e.g., Notion) timeout after upgrading to v1.12 due to fastmcp dependency upgrade. Changes: - Upgrade fastmcp dependency from >=2.11.3 to >=3.0.0 - Add configurable mcp_timeout field to Agent class (default: 60s) - Update create_mcp_tools() to: - Use 60s default timeout (up from 30s) - Pass init_timeout to fastmcp Client for better OAuth support - Replace hardcoded 30s timeout in Agent.initialize() with mcp_timeout OAuth-based MCP servers often require longer timeouts for browser-based authentication flows. The new mcp_timeout field allows users to configure this value according to their needs. Fixes #2184 Co-authored-by: openhands <openhands@all-hands.dev>
Contributor
API breakage checks (Griffe)Result: Passed |
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR addresses issue #2184 where OAuth-based MCP servers (e.g., Notion) timeout after upgrading from v1.11 to v1.12. The root cause was that the
fastmcpdependency was automatically upgraded to v3.x, and the hardcoded 30-second timeout was insufficient for OAuth servers that need browser-based authentication flows.Alternative approach to PR #2185 - Instead of pinning fastmcp to v2.x, this PR updates the SDK to be compatible with fastmcp 3.x and adds configurable timeout support.
Changes
Upgrade fastmcp dependency (
openhands-sdk/pyproject.toml)>=2.11.3to>=3.0.0Add configurable
mcp_timeoutfield (agent/base.py)mcp_timeoutfield on Agent classUpdate
create_mcp_tools()(mcp/utils.py)init_timeoutto fastmcp Client constructor for better OAuth supportUse configurable timeout in Agent (
agent/base.py)30withself.mcp_timeoutininitialize()Added tests
mcp_timeoutfield serialization/deserializationinit_timeoutbeing passed to MCPClient constructorMigration
For users experiencing timeouts, you can now configure the timeout:
Or directly when calling
create_mcp_tools:Fixes #2184
Checklist
@jpshackelford can click here to continue refining the PR
Agent Server images for this PR
• GHCR package: https://github.com/OpenHands/agent-sdk/pkgs/container/agent-server
Variants & Base Images
eclipse-temurin:17-jdknikolaik/python-nodejs:python3.12-nodejs22golang:1.21-bookwormPull (multi-arch manifest)
# Each variant is a multi-arch manifest supporting both amd64 and arm64 docker pull ghcr.io/openhands/agent-server:6ffa25c-pythonRun
All tags pushed for this build
About Multi-Architecture Support
6ffa25c-python) is a multi-arch manifest supporting both amd64 and arm646ffa25c-python-amd64) are also available if needed