Skip to content

Framework for orchestrating role-playing, autonomous AI agents. By fostering collaborative intelligence, CrewAI empowers agents to work together seamlessly, tackling complex tasks.

fix: remove invalid param from sse client (#3980)

Greyson LaLondebed9a3847a18
diff --git a/lib/crewai/src/crewai/mcp/transports/sse.py b/lib/crewai/src/crewai/mcp/transports/sse.py
index ce418c51f..c2184e7d0 100644
--- a/lib/crewai/src/crewai/mcp/transports/sse.py
+++ b/lib/crewai/src/crewai/mcp/transports/sse.py
@@ -66,7 +66,6 @@ class SSETransport(BaseTransport):
self._transport_context = sse_client(
self.url,
headers=self.headers if self.headers else None,
- terminate_on_close=True,
)
read, write = await self._transport_context.__aenter__()
diff --git a/lib/crewai/tests/mcp/test_sse_transport.py b/lib/crewai/tests/mcp/test_sse_transport.py
new file mode 100644
index 000000000..a714c6ce7
--- /dev/null
+++ b/lib/crewai/tests/mcp/test_sse_transport.py
@@ -0,0 +1,22 @@
+"""Tests for SSE transport."""
+
+import pytest
+
+from crewai.mcp.transports.sse import SSETransport
+
+
+async def test_sse_transport_connect_does_not_pass_invalid_args():
+ """Test that SSETransport.connect() doesn't pass invalid args to sse_client.
+
+ The sse_client function does not accept terminate_on_close parameter.
+ """
+ transport = SSETransport(
+ url="http://localhost:9999/sse",
+ headers={"Authorization": "Bearer test"},
+ )
+
+ with pytest.raises(ConnectionError) as exc_info:
+ await transport.connect()
+
+ assert "unexpected keyword argument" not in str(exc_info.value)
\ No newline at end of file