MCPcopy
hub / github.com/HKUDS/DeepCode / handle_call_tool

Function handle_call_tool

tools/command_executor.py:91–113  ·  view source on GitHub ↗

处理工具调用 / Handle tool calls

(name: str, arguments: dict)

Source from the content-addressed store, hash-verified

89
90@app.call_tool()
91async def handle_call_tool(name: str, arguments: dict) -> list[types.TextContent]:
92 """
93 处理工具调用 / Handle tool calls
94 """
95 try:
96 if name == "execute_commands":
97 return await execute_command_batch(
98 arguments.get("commands", ""), arguments.get("working_directory", ".")
99 )
100 elif name == "execute_single_command":
101 return await execute_single_command(
102 arguments.get("command", ""), arguments.get("working_directory", ".")
103 )
104 else:
105 raise ValueError(f"未知工具 / Unknown tool: {name}")
106
107 except Exception as e:
108 return [
109 types.TextContent(
110 type="text",
111 text=f"工具执行错误 / Error executing tool {name}: {str(e)}",
112 )
113 ]
114
115
116async def execute_command_batch(

Callers

nothing calls this directly

Calls 3

execute_command_batchFunction · 0.85
execute_single_commandFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected