Fix SSE transport invalid parameter issue (#3938) #3940
Closed
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.
Fix SSE transport invalid parameter issue (#3938)
Summary
Fixes #3938 by removing the invalid
terminate_on_closeparameter from the SSE transport'ssse_client()call. This parameter is only valid for streamable HTTP transport (per the MCP SDK documentation), not for SSE transport, and was causing crashes when agents tried to connect to MCP servers using SSE transport.Changes:
terminate_on_close=Truefromsse_client()call inSSETransport.connect()Agent._get_native_mcp_tools()raises properRuntimeErrorinstead ofUnboundLocalErrorwhen connection failsVerification:
terminate_on_closeis only used in HTTP transport (where it's valid) and MCPToolWrapper (also valid)Review & Testing Checklist for Human
terminate_on_closedoesn't break any existing SSE transport use cases beyond fixing the crashsse_clientfunction. Verify this accurately represents the SDK's behavior and that the test fixtures properly clean upsys.modulesNotes
tests/llms/openai/test_openai.py::test_multiple_openai_calls_in_crewwith a directory cleanup error). This appears unrelated to the SSE transport changes as it's in the OpenAI test suite and involves a different storage directory. All other CI checks passed (lint, type-checker across all Python versions, CodeQL).autousefixtures to isolateCREWAI_STORAGE_DIRin the new test modules as a defensive measure to prevent any potential test interference.terminate_on_closefor SSE transport, which aligns with the issue report and SDK documentation.Link to Devin run: https://app.devin.ai/sessions/d3870992d8df48bb82c99e260c70f9d3
Requested by: João (joao@crewai.com)