- Change fake_streamablehttp_client from async def to regular def
- async with expects an object with __aenter__/__aexit__, not a coroutine
- Add __path__ to make mcp modules look like packages
- Add last_kwargs tracking for header assertions
- Add proper assertions to verify headers are passed/not passed
- This fixes TypeError: 'coroutine' object does not support async context manager protocol
Co-Authored-By: João <joao@crewai.com>
- Remove all patch() calls for module-local names (streamablehttp_client, ClientSession)
- Rely solely on sys.modules stub fixture for mcp module imports
- Patch ClientSession.__init__ directly to configure mock behavior
- This fixes AttributeError issues where patch() tried to access non-existent module attributes
Co-Authored-By: João <joao@crewai.com>
- Add autouse fixture to stub mcp, mcp.client, and mcp.client.streamable_http modules
- Revert patch targets to module-local names (crewai.tools.mcp_tool_wrapper.*)
- This fixes ModuleNotFoundError in CI where mcp package is not installed
- The stub fixture ensures tests can run without requiring the actual mcp package
Co-Authored-By: João <joao@crewai.com>
- Fix event bus API: use register_handler instead of register
- Fix mock import paths: patch mcp.client.streamable_http.streamablehttp_client and mcp.ClientSession at their actual import locations
Co-Authored-By: João <joao@crewai.com>
Implements progress reporting and HTTP headers support for MCP tool integration
to address issue #3797.
Changes:
- Add MCPToolProgressEvent to event system for real-time progress tracking
- Extend MCPToolWrapper to support progress callbacks and event emission
- Add mcp_progress_enabled flag to Agent for opt-in progress notifications
- Add mcp_server_headers to Agent for middleware authentication/tracking
- Thread progress and headers configuration through Agent._get_external_mcp_tools
- Add comprehensive test coverage for progress and headers features
- Update MCP DSL documentation with progress and headers examples
Features:
- Progress notifications emitted as MCPToolProgressEvent via event bus
- Optional progress callback for custom progress handling
- HTTP headers passthrough for authentication and middleware integration
- Agent and task context included in progress events
- Opt-in design ensures backward compatibility
Tests:
- Unit tests for MCPToolWrapper progress and headers functionality
- Integration tests for Agent MCP configuration
- Mock-based tests to avoid network dependencies
Documentation:
- Added Progress Notifications section with examples
- Added Middleware Support with Headers section
- Included complete examples for common use cases
Fixes#3797
Co-Authored-By: João <joao@crewai.com>