@@ -24,6 +24,13 @@ def mcp_config_file(tmp_path: Path) -> Path:
2424 "args" : ["-m" , "my_server" ],
2525 "env" : {"DEBUG" : "true" },
2626 },
27+ "stdio_server_with_full_command" : {
28+ "command" : "python -m my_server" ,
29+ },
30+ "stdio_server_with_full_command_and_explicit_args" : {
31+ "command" : "python -m my_server" , # Two args here: -m and my_server
32+ "args" : ["--debug" ], # One explicit arg here: --debug
33+ },
2734 "http_streamable" : {
2835 "url" : "https://api.example.com/mcp" ,
2936 "headers" : {"Authorization" : "Bearer token123" },
@@ -49,7 +56,45 @@ def test_stdio_server(mcp_config_file: Path):
4956 assert stdio_server .args == ["-m" , "my_server" ]
5057 assert stdio_server .env == {"DEBUG" : "true" }
5158 assert stdio_server .type == "stdio" # Should be automatically inferred
52-
59+
60+ # In this case, effective_command and effective_args are the same as command
61+ # and args.
62+ # But later on, we will see a test where the command is specified as a
63+ # single string, and we expect the command to be split into command and args
64+ assert stdio_server .effective_command == "python"
65+ assert stdio_server .effective_args == ["-m" , "my_server" ]
66+
67+
68+ def test_stdio_server_with_full_command_should_be_split (mcp_config_file : Path ):
69+ """This test should fail - it expects the command to be split into command and args."""
70+ config = MCPServersConfig .from_file (mcp_config_file )
71+
72+ stdio_server = config .servers ["stdio_server_with_full_command" ]
73+ assert isinstance (stdio_server , StdioServerConfig )
74+
75+ # This is how the command was specified
76+ assert stdio_server .command == "python -m my_server"
77+
78+ # This is how the command is split into command and args
79+ assert stdio_server .effective_command == "python"
80+ assert stdio_server .effective_args == ["-m" , "my_server" ]
81+
82+
83+ def test_stdio_server_with_full_command_and_explicit_args (mcp_config_file : Path ):
84+ """Test that effective_args combines parsed command args with explicit args."""
85+ config = MCPServersConfig .from_file (mcp_config_file )
86+
87+ stdio_server = config .servers ["stdio_server_with_full_command_and_explicit_args" ]
88+ assert isinstance (stdio_server , StdioServerConfig )
89+
90+ # Test original values
91+ assert stdio_server .command == "python -m my_server"
92+ assert stdio_server .args == ["--debug" ]
93+
94+ # Test effective values - should combine parsed command args with explicit args
95+ assert stdio_server .effective_command == "python"
96+ assert stdio_server .effective_args == ["-m" , "my_server" , "--debug" ]
97+
5398
5499def test_streamable_http_server (mcp_config_file : Path ):
55100 config = MCPServersConfig .from_file (mcp_config_file )
0 commit comments