33without requiring a prior initial state fetch, and returns JSON.
44"""
55
6+ import asyncio
7+ import subprocess
8+ import sys
69import time
7- from multiprocessing import Process
810
911import httpx
1012import pytest
1315from eval_protocol .types import MCPSession
1416
1517
16- def _run_airline_server ():
17- import os
18+ @pytest .mark .asyncio
19+ async def test_tool_call_returns_json_without_prior_initial_state ():
20+ port = "9780"
1821
19- python_version = os . environ . get ( "PYTHON_VERSION" , "3.10" ). replace ( "." , "" )
20- port = str ( 9780 + int ( python_version [ - 1 :]))
21- os . environ [ "PORT" ] = port
22- from eval_protocol . mcp_servers . tau2 . tau2_mcp import AirlineDomainMcp
22+ # Create server script to run as subprocess instead of multiprocessing
23+ server_script = """
24+ import sys
25+ import os
2326
24- server = AirlineDomainMcp ( seed = None )
25- server . run ( transport = "streamable-http" )
27+ port = "9780"
28+ os.environ["PORT"] = port
2629
30+ from eval_protocol.mcp_servers.tau2.tau2_mcp import AirlineDomainMcp
2731
28- @ pytest . mark . asyncio
29- async def test_tool_call_returns_json_without_prior_initial_state ():
30- import os
32+ server = AirlineDomainMcp(seed=None)
33+ server.run(transport="streamable-http")
34+ """
3135
32- proc = Process ( target = _run_airline_server , daemon = True )
33- proc . start ( )
36+ # Start server as subprocess instead of multiprocessing.Process
37+ proc = subprocess . Popen ([ sys . executable , "-c" , server_script ] )
3438
35- try :
36- python_version = os .environ .get ("PYTHON_VERSION" , "3.10" ).replace ("." , "" )
37- port = str (9780 + int (python_version [- 1 :]))
39+ # Give server time to start
40+ await asyncio .sleep (3 )
3841
42+ try :
3943 base_url = f"http://127.0.0.1:{ port } /mcp"
4044 client = httpx .Client (timeout = 1.0 )
4145 start_time = time .time ()
@@ -51,7 +55,7 @@ async def test_tool_call_returns_json_without_prior_initial_state():
5155 pass
5256 time .sleep (0.2 )
5357 else :
54- pytest .fail ("Server did not start on port 9780 in time" )
58+ pytest .fail (f "Server did not start on port { port } in time" )
5559
5660 assert ready_time is not None , "Server did not return a successful status before exiting loop"
5761 assert ready_time - start_time < 20 , f"Server took too long to respond: { ready_time - start_time :.2f} s"
@@ -71,4 +75,4 @@ async def test_tool_call_returns_json_without_prior_initial_state():
7175 await mgr .close_session (session )
7276 finally :
7377 proc .terminate ()
74- proc .join (timeout = 5 )
78+ proc .wait (timeout = 5 )
0 commit comments