File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change 11import shutil
22
33import pytest
4+ from anyio import fail_after
45
56from mcp .client .stdio import StdioServerParameters , stdio_client
67from mcp .types import JSONRPCMessage , JSONRPCRequest , JSONRPCResponse
@@ -41,3 +42,18 @@ async def test_stdio_client():
4142 assert read_messages [1 ] == JSONRPCMessage (
4243 root = JSONRPCResponse (jsonrpc = "2.0" , id = 2 , result = {})
4344 )
45+
46+
47+ @pytest .mark .anyio
48+ async def test_stdio_client_bad_path ():
49+ """Check that the connection doesn't hang if process errors."""
50+ server_parameters = StdioServerParameters (
51+ command = "uv" , args = ["run" , "non-existent-file.py" ]
52+ )
53+
54+ try :
55+ with fail_after (1 ):
56+ async with stdio_client (server_parameters ) as (read_stream , write_stream ):
57+ pass
58+ except TimeoutError :
59+ pytest .fail ("The connection hung." )
You can’t perform that action at this time.
0 commit comments