@@ -22,7 +22,7 @@ async def test_list_tools():
22
22
assert len (tools ) == 1
23
23
tool = tools [0 ]
24
24
assert isinstance (tool , Tool )
25
- assert tool .name == "execute "
25
+ assert tool .name == "shell_execute "
26
26
assert tool .description
27
27
assert tool .inputSchema ["type" ] == "object"
28
28
assert "command" in tool .inputSchema ["properties" ]
@@ -35,7 +35,7 @@ async def test_list_tools():
35
35
async def test_call_tool_valid_command (monkeypatch ):
36
36
"""Test execution of a valid command"""
37
37
monkeypatch .setenv ("ALLOW_COMMANDS" , "echo" )
38
- result = await call_tool ("execute " , {"command" : ["echo" , "hello world" ]})
38
+ result = await call_tool ("shell_execute " , {"command" : ["echo" , "hello world" ]})
39
39
assert len (result ) == 1
40
40
assert isinstance (result [0 ], TextContent )
41
41
assert result [0 ].type == "text"
@@ -46,7 +46,9 @@ async def test_call_tool_valid_command(monkeypatch):
46
46
async def test_call_tool_with_stdin (monkeypatch ):
47
47
"""Test command execution with stdin"""
48
48
monkeypatch .setenv ("ALLOW_COMMANDS" , "cat" )
49
- result = await call_tool ("execute" , {"command" : ["cat" ], "stdin" : "test input" })
49
+ result = await call_tool (
50
+ "shell_execute" , {"command" : ["cat" ], "stdin" : "test input" }
51
+ )
50
52
assert len (result ) == 1
51
53
assert isinstance (result [0 ], TextContent )
52
54
assert result [0 ].type == "text"
@@ -58,7 +60,7 @@ async def test_call_tool_invalid_command(monkeypatch):
58
60
"""Test execution of an invalid command"""
59
61
monkeypatch .setenv ("ALLOW_COMMANDS" , "echo" )
60
62
with pytest .raises (RuntimeError ) as excinfo :
61
- await call_tool ("execute " , {"command" : ["invalid_command" ]})
63
+ await call_tool ("shell_execute " , {"command" : ["invalid_command" ]})
62
64
assert "Command not allowed: invalid_command" in str (excinfo .value )
63
65
64
66
@@ -74,15 +76,15 @@ async def test_call_tool_unknown_tool():
74
76
async def test_call_tool_invalid_arguments ():
75
77
"""Test calling a tool with invalid arguments"""
76
78
with pytest .raises (RuntimeError ) as excinfo :
77
- await call_tool ("execute " , "not a dict" )
79
+ await call_tool ("shell_execute " , "not a dict" )
78
80
assert "Arguments must be a dictionary" in str (excinfo .value )
79
81
80
82
81
83
@pytest .mark .asyncio
82
84
async def test_call_tool_empty_command ():
83
85
"""Test execution with empty command"""
84
86
with pytest .raises (RuntimeError ) as excinfo :
85
- await call_tool ("execute " , {"command" : []})
87
+ await call_tool ("shell_execute " , {"command" : []})
86
88
assert "No command provided" in str (excinfo .value )
87
89
88
90
@@ -92,7 +94,7 @@ async def test_call_tool_with_directory(temp_test_dir, monkeypatch):
92
94
"""Test command execution in a specific directory"""
93
95
monkeypatch .setenv ("ALLOW_COMMANDS" , "pwd" )
94
96
result = await call_tool (
95
- "execute " , {"command" : ["pwd" ], "directory" : temp_test_dir }
97
+ "shell_execute " , {"command" : ["pwd" ], "directory" : temp_test_dir }
96
98
)
97
99
assert len (result ) == 1
98
100
assert isinstance (result [0 ], TextContent )
@@ -111,13 +113,17 @@ async def test_call_tool_with_file_operations(temp_test_dir, monkeypatch):
111
113
f .write ("test content" )
112
114
113
115
# Test ls command
114
- result = await call_tool ("execute" , {"command" : ["ls" ], "directory" : temp_test_dir })
116
+ result = await call_tool (
117
+ "shell_execute" , {"command" : ["ls" ], "directory" : temp_test_dir }
118
+ )
119
+ assert isinstance (result [0 ], TextContent )
115
120
assert "test.txt" in result [0 ].text
116
121
117
122
# Test cat command
118
123
result = await call_tool (
119
- "execute " , {"command" : ["cat" , "test.txt" ], "directory" : temp_test_dir }
124
+ "shell_execute " , {"command" : ["cat" , "test.txt" ], "directory" : temp_test_dir }
120
125
)
126
+ assert isinstance (result [0 ], TextContent )
121
127
assert result [0 ].text .strip () == "test content"
122
128
123
129
@@ -127,7 +133,7 @@ async def test_call_tool_with_nonexistent_directory(monkeypatch):
127
133
monkeypatch .setenv ("ALLOW_COMMANDS" , "ls" )
128
134
with pytest .raises (RuntimeError ) as excinfo :
129
135
await call_tool (
130
- "execute " , {"command" : ["ls" ], "directory" : "/nonexistent/directory" }
136
+ "shell_execute " , {"command" : ["ls" ], "directory" : "/nonexistent/directory" }
131
137
)
132
138
assert "Directory does not exist: /nonexistent/directory" in str (excinfo .value )
133
139
@@ -143,7 +149,7 @@ async def test_call_tool_with_file_as_directory(temp_test_dir, monkeypatch):
143
149
f .write ("test content" )
144
150
145
151
with pytest .raises (RuntimeError ) as excinfo :
146
- await call_tool ("execute " , {"command" : ["ls" ], "directory" : test_file })
152
+ await call_tool ("shell_execute " , {"command" : ["ls" ], "directory" : test_file })
147
153
assert f"Not a directory: { test_file } " in str (excinfo .value )
148
154
149
155
@@ -157,5 +163,8 @@ async def test_call_tool_with_nested_directory(temp_test_dir, monkeypatch):
157
163
os .mkdir (nested_dir )
158
164
nested_real_path = os .path .realpath (nested_dir )
159
165
160
- result = await call_tool ("execute" , {"command" : ["pwd" ], "directory" : nested_dir })
166
+ result = await call_tool (
167
+ "shell_execute" , {"command" : ["pwd" ], "directory" : nested_dir }
168
+ )
169
+ assert isinstance (result [0 ], TextContent )
161
170
assert result [0 ].text .strip () == nested_real_path
0 commit comments