Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions python/semantic_kernel/connectors/mcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions python/tests/unit/connectors/mcp/test_mcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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_streamablehttp_client_forwards_zero_timeouts(mock_streamablehttp_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_streamablehttp_client.return_value

mock_streamablehttp_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])
Expand Down
Loading