async def test_sse_connection_timeout():
    """Test that SSE connection timeout is handled gracefully."""
    # Create a mock MCPClient
    mock_client = mock.MagicMock(spec=MCPClient)

    # Configure the mock to raise a TimeoutError when connect_http is called
    async def mock_connect_http(*args, **kwargs):
        await asyncio.sleep(0.1)  # Simulate some delay
        raise asyncio.TimeoutError('Connection timed out')

    mock_client.connect_http.side_effect = mock_connect_http
    mock_client.disconnect = mock.AsyncMock()

    # Mock the MCPClient constructor to return our mock
    with mock.patch('openhands.mcp.utils.MCPClient', return_value=mock_client):
        # Create a list of server URLs to test
        servers = [
            MCPSSEServerConfig(url='http://server1:8080'),
            MCPSSEServerConfig(url='http://server2:8080'),
        ]

        # Call create_mcp_clients with the server URLs
        clients = await create_mcp_clients(sse_servers=servers, shttp_servers=[])

        # Verify that no clients were successfully connected
        assert len(clients) == 0

        # Verify that connect_http was called for each server
        assert mock_client.connect_http.call_count == 2
Test that SSE connection timeout is handled gracefully.
tests/unit/test_mcp_timeout.py