From a05c6a15f4451ac105180ae263fad851e313d15e Mon Sep 17 00:00:00 2001 From: King Star Date: Sat, 15 Aug 2026 06:46:26 +0800 Subject: [PATCH 1/2] fix(python): preserve zero MCP streamable HTTP timeouts --- python/semantic_kernel/connectors/mcp.py | 4 ++-- python/tests/unit/connectors/mcp/test_mcp.py | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/python/semantic_kernel/connectors/mcp.py b/python/semantic_kernel/connectors/mcp.py index 789461b2c805..4554d6a900a4 100644 --- a/python/semantic_kernel/connectors/mcp.py +++ b/python/semantic_kernel/connectors/mcp.py @@ -886,9 +886,9 @@ def get_mcp_client(self) -> _AsyncGeneratorContextManager[Any, None]: } if self.headers: args["headers"] = self.headers - if self.timeout: + if self.timeout is not None: args["timeout"] = self.timeout - if self.sse_read_timeout: + if self.sse_read_timeout is not None: args["sse_read_timeout"] = self.sse_read_timeout if self.terminate_on_close is not None: args["terminate_on_close"] = self.terminate_on_close diff --git a/python/tests/unit/connectors/mcp/test_mcp.py b/python/tests/unit/connectors/mcp/test_mcp.py index b4623489de12..4471e9408e28 100644 --- a/python/tests/unit/connectors/mcp/test_mcp.py +++ b/python/tests/unit/connectors/mcp/test_mcp.py @@ -377,6 +377,24 @@ async def test_with_kwargs_streamablehttp(mock_session, mock_client, list_tool_c assert len(loaded_plugin.functions["func2"].parameters) == 0 +@patch("semantic_kernel.connectors.mcp.streamablehttp_client") +def test_streamable_http_client_forwards_zero_timeouts(mock_client): + plugin = MCPStreamableHttpPlugin( + name="TestMCPPlugin", + url="http://localhost:8080/mcp", + timeout=0.0, + sse_read_timeout=0.0, + ) + + assert plugin.get_mcp_client() is mock_client.return_value + + mock_client.assert_called_once_with( + url="http://localhost:8080/mcp", + timeout=0.0, + sse_read_timeout=0.0, + ) + + async def test_kernel_as_mcp_server(kernel: "Kernel", decorated_native_function, custom_plugin_class): kernel.add_plugin(custom_plugin_class, "test") kernel.add_functions("test", [decorated_native_function]) From d2df9eae6f2865a8b170127507ec26e0b6f1658c Mon Sep 17 00:00:00 2001 From: King Star Date: Sun, 30 Aug 2026 23:57:11 +0800 Subject: [PATCH 2/2] test(python): align streamable HTTP mock naming Signed-off-by: King Star --- python/tests/unit/connectors/mcp/test_mcp.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/python/tests/unit/connectors/mcp/test_mcp.py b/python/tests/unit/connectors/mcp/test_mcp.py index 4471e9408e28..c8688bc451ac 100644 --- a/python/tests/unit/connectors/mcp/test_mcp.py +++ b/python/tests/unit/connectors/mcp/test_mcp.py @@ -378,7 +378,7 @@ async def test_with_kwargs_streamablehttp(mock_session, mock_client, list_tool_c @patch("semantic_kernel.connectors.mcp.streamablehttp_client") -def test_streamable_http_client_forwards_zero_timeouts(mock_client): +def test_streamablehttp_client_forwards_zero_timeouts(mock_streamablehttp_client): plugin = MCPStreamableHttpPlugin( name="TestMCPPlugin", url="http://localhost:8080/mcp", @@ -386,9 +386,9 @@ def test_streamable_http_client_forwards_zero_timeouts(mock_client): sse_read_timeout=0.0, ) - assert plugin.get_mcp_client() is mock_client.return_value + assert plugin.get_mcp_client() is mock_streamablehttp_client.return_value - mock_client.assert_called_once_with( + mock_streamablehttp_client.assert_called_once_with( url="http://localhost:8080/mcp", timeout=0.0, sse_read_timeout=0.0,