Skip to content

Conversation

devin-ai-integration[bot]
Copy link
Contributor

Fix: Add connect_timeout parameter to get_mcp_tools method

Summary

Fixes issue #3463 by adding an optional connect_timeout parameter to the get_mcp_tools method in @CrewBase. This allows users to configure connection timeouts when connecting to MCP servers, preventing timeout errors that were occurring with the default 30-second limit.

Key Changes:

  • Added connect_timeout: Optional[int] = 30 parameter to get_mcp_tools() method
  • Added Optional to typing imports in crew_base.py
  • Pass connect_timeout to MCPServerAdapter constructor
  • Added comprehensive test coverage for timeout functionality
  • Maintains full backward compatibility with existing code

Review & Testing Checklist for Human

  • Verify MCPServerAdapter API compatibility - Confirm that MCPServerAdapter(server_params, connect_timeout=timeout) is the correct constructor signature (my tests use mocks so this wasn't verified locally)
  • Test with actual MCP servers - My tests use mocks; please test with real MCP server connections to ensure timeout works in practice and reproduces the original issue from [BUG] get_mcp_tools in @CrewBase hits a timeout #3463
  • Validate timeout behavior with cached adapters - The MCPServerAdapter is cached per CrewBase instance, so connect_timeout only applies during first initialization. Verify this behavior is intuitive to users
  • Confirm 30-second default timeout is appropriate - This matches the closed PR Fix: Add connect_timeout parameter to get_mcp_tools method #3327 but may need adjustment based on real-world usage patterns
  • Verify backward compatibility - Test existing code that calls get_mcp_tools() without timeout parameter continues working unchanged

Recommended Test Plan:

  1. Test crew.get_mcp_tools() without timeout parameter (should use 30s default)
  2. Test crew.get_mcp_tools(connect_timeout=60) with custom timeout
  3. Test with multiple MCP servers to reproduce original timeout issue
  4. Verify existing MCP workflows continue to work unchanged

Notes

- Add Optional import to crew_base.py for type annotation
- Modify get_mcp_tools to accept connect_timeout parameter with 30s default
- Pass connect_timeout to MCPServerAdapter constructor
- Update existing test to verify default timeout is passed
- Add test for custom timeout values
- Add test for backward compatibility

Fixes issue #3463 where @crewbase users couldn't configure MCP server connection timeouts

Co-Authored-By: João <[email protected]>
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

- Add ClassVar import to tests for proper type annotations
- Add type ignore comment for crewai_tools import to suppress mypy error
- Fix line length violations by breaking long assert statements
- Add ClassVar annotations for mutable class attributes in test classes

Co-Authored-By: João <[email protected]>
Copy link
Contributor Author

Closing due to inactivity for more than 7 days. Configure here.

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.

0 participants