File tree 1 file changed +16
-0
lines changed
1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change 1
1
import shutil
2
2
3
3
import pytest
4
+ from anyio import fail_after
4
5
5
6
from mcp .client .stdio import StdioServerParameters , stdio_client
6
7
from mcp .types import JSONRPCMessage , JSONRPCRequest , JSONRPCResponse
@@ -41,3 +42,18 @@ async def test_stdio_client():
41
42
assert read_messages [1 ] == JSONRPCMessage (
42
43
root = JSONRPCResponse (jsonrpc = "2.0" , id = 2 , result = {})
43
44
)
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