1313 python3 tests/test_mcp_server.py TestMCPServer.test_server_connection
1414
1515 # Run with custom server URL (skips auto-start)
16- MCP_SERVER_URL=http://vm-hostname:8080/sse python3 tests/test_mcp_server.py
16+ MCP_SERVER_URL=http://vm-hostname:8080/mcp python3 tests/test_mcp_server.py
1717"""
1818
1919import asyncio
2828
2929try :
3030 from mcp import ClientSession
31- from mcp .client .sse import sse_client
31+ from mcp .client .streamable_http import streamablehttp_client
32+ import httpx
3233except ImportError :
3334 print ("ERROR: MCP client library not installed" )
34- print ("Install with: pip3 install mcp" )
35+ print ("Install with: pip3 install mcp httpx " )
3536 sys .exit (1 )
3637
3738# Suppress async generator cleanup warnings from MCP client library
4041warnings .filterwarnings ("ignore" , message = ".*asynchronous generator.*" )
4142warnings .filterwarnings ("ignore" , message = ".*coroutine.*was never awaited.*" )
4243
43- # Also suppress logging from MCP client SSE reader
44- # The "Error in sse_reader" messages are expected when server closes connection
45- import logging
46- logging .getLogger ("mcp.client.sse" ).setLevel (logging .CRITICAL )
47-
4844
4945# Global server process handle
5046_server_process = None
@@ -238,7 +234,7 @@ class TestMCPServer(unittest.IsolatedAsyncioTestCase):
238234 @classmethod
239235 def setUpClass (cls ):
240236 """Set up test fixtures once for all tests"""
241- cls .server_url = os .getenv ("MCP_SERVER_URL" , "http://localhost:8000/sse " )
237+ cls .server_url = os .getenv ("MCP_SERVER_URL" , "http://localhost:8000/mcp " )
242238 cls .test_release = "4.19.1"
243239
244240 async def asyncSetUp (self ):
@@ -248,9 +244,9 @@ async def asyncSetUp(self):
248244 if _server_process is None and not os .getenv ("MCP_SERVER_URL" ):
249245 self .skipTest ("MCP server is not running" )
250246
251- # Connect to server
252- self .sse_context = sse_client (url = self .server_url )
253- self .read , self .write = await self .sse_context .__aenter__ ()
247+ # Connect to server using HTTP transport
248+ self .http_context = streamablehttp_client (url = self .server_url )
249+ self .read , self .write , _ = await self .http_context .__aenter__ ()
254250
255251 # Create session
256252 self .session_context = ClientSession (self .read , self .write )
@@ -270,7 +266,7 @@ async def asyncTearDown(self):
270266 raise
271267
272268 try :
273- await self .sse_context .__aexit__ (None , None , None )
269+ await self .http_context .__aexit__ (None , None , None )
274270 except RuntimeError as e :
275271 if "cancel scope" not in str (e ):
276272 raise
@@ -296,7 +292,6 @@ async def test_list_tools(self):
296292 expected_tools = [
297293 'oar_get_release_metadata' ,
298294 'mcp_cache_stats' ,
299- 'oar_check_greenwave_cvp_tests' ,
300295 'oar_is_release_shipped' ,
301296 'oar_get_release_status' ,
302297 ]
@@ -379,7 +374,7 @@ class TestMCPServerConcurrency(unittest.IsolatedAsyncioTestCase):
379374 @classmethod
380375 def setUpClass (cls ):
381376 """Set up test fixtures"""
382- cls .server_url = os .getenv ("MCP_SERVER_URL" , "http://localhost:8000/sse " )
377+ cls .server_url = os .getenv ("MCP_SERVER_URL" , "http://localhost:8000/mcp " )
383378
384379 async def test_concurrent_client_connections (self ):
385380 """Test that multiple clients can connect simultaneously"""
@@ -390,7 +385,7 @@ async def test_concurrent_client_connections(self):
390385
391386 async def connect_client (client_id ):
392387 """Connect a single client and call cache_stats"""
393- async with sse_client (url = self .server_url ) as (read , write ):
388+ async with streamablehttp_client (url = self .server_url ) as (read , write , _ ):
394389 async with ClientSession (read , write ) as session :
395390 await session .initialize ()
396391
@@ -425,7 +420,7 @@ async def test_concurrent_tool_calls_different_clients(self):
425420
426421 async def client_workflow (client_id , tool_name ):
427422 """Single client making a tool call"""
428- async with sse_client (url = self .server_url ) as (read , write ):
423+ async with streamablehttp_client (url = self .server_url ) as (read , write , _ ):
429424 async with ClientSession (read , write ) as session :
430425 await session .initialize ()
431426
@@ -468,7 +463,7 @@ async def test_thread_pool_isolation(self):
468463
469464 async def get_cache_stats (_client_id ):
470465 """Get cache stats from single client"""
471- async with sse_client (url = self .server_url ) as (read , write ):
466+ async with streamablehttp_client (url = self .server_url ) as (read , write , _ ):
472467 async with ClientSession (read , write ) as session :
473468 await session .initialize ()
474469 result = await session .call_tool ('mcp_cache_stats' , arguments = {})
@@ -491,7 +486,7 @@ class TestMCPServerErrorHandling(unittest.IsolatedAsyncioTestCase):
491486 @classmethod
492487 def setUpClass (cls ):
493488 """Set up test fixtures"""
494- cls .server_url = os .getenv ("MCP_SERVER_URL" , "http://localhost:8000/sse " )
489+ cls .server_url = os .getenv ("MCP_SERVER_URL" , "http://localhost:8000/mcp " )
495490
496491 async def test_invalid_release_version (self ):
497492 """Test handling of invalid release version"""
@@ -500,7 +495,7 @@ async def test_invalid_release_version(self):
500495 if _server_process is None and not os .getenv ("MCP_SERVER_URL" ):
501496 self .skipTest ("MCP server is not running" )
502497
503- async with sse_client (url = self .server_url ) as (read , write ):
498+ async with streamablehttp_client (url = self .server_url ) as (read , write , _ ):
504499 async with ClientSession (read , write ) as session :
505500 await session .initialize ()
506501
@@ -533,7 +528,7 @@ class TestMCPServerStateBoxIntegration(unittest.IsolatedAsyncioTestCase):
533528 @classmethod
534529 def setUpClass (cls ):
535530 """Set up test fixtures"""
536- cls .server_url = os .getenv ("MCP_SERVER_URL" , "http://localhost:8000/sse " )
531+ cls .server_url = os .getenv ("MCP_SERVER_URL" , "http://localhost:8000/mcp " )
537532 # Use a test release version
538533 cls .test_release = "4.20.5"
539534
@@ -549,7 +544,7 @@ async def test_statebox_task_update_with_timestamps(self):
549544 from oar .core .statebox import StateBox
550545 from datetime import datetime , timezone
551546
552- async with sse_client (url = self .server_url ) as (read , write ):
547+ async with streamablehttp_client (url = self .server_url ) as (read , write , _ ):
553548 async with ClientSession (read , write ) as session :
554549 await session .initialize ()
555550
0 commit comments