MCPcopy Create free account
hub / github.com/OpenBMB/ChatDev / execute_tool

Method execute_tool

runtime/node/agent/tool/tool_manager.py:147–174  ·  view source on GitHub ↗

Execute a tool using the provided configuration.

(
        self,
        tool_name: str,
        arguments: Dict[str, Any],
        tool_config: ToolingConfig,
        *,
        tool_context: Dict[str, Any] | None = None,
    )

Source from the content-addressed store, hash-verified

145 return specs
146
147 async def execute_tool(
148 self,
149 tool_name: str,
150 arguments: Dict[str, Any],
151 tool_config: ToolingConfig,
152 *,
153 tool_context: Dict[str, Any] | None = None,
154 ) -> Any:
155 """Execute a tool using the provided configuration."""
156 if tool_config.type == "function":
157 config = tool_config.as_config(FunctionToolConfig)
158 if not config:
159 raise ValueError("Function tooling configuration missing")
160 return self._execute_function_tool(tool_name, arguments, config, tool_context)
161
162 if tool_config.type == "mcp_remote":
163 config = tool_config.as_config(McpRemoteConfig)
164 if not config:
165 raise ValueError("MCP remote configuration missing")
166 return await self._execute_mcp_remote_tool(tool_name, arguments, config, tool_context)
167
168 if tool_config.type == "mcp_local":
169 config = tool_config.as_config(McpLocalConfig)
170 if not config:
171 raise ValueError("MCP local configuration missing")
172 return await self._execute_mcp_local_tool(tool_name, arguments, config, tool_context)
173
174 raise ValueError(f"Unsupported tool type: {tool_config.type}")
175
176 def _build_function_specs(self, config: FunctionToolConfig) -> List[ToolSpec]:
177 self._ensure_functions_loaded(config.auto_load)

Callers 1

_execute_tool_batchMethod · 0.80

Calls 4

as_configMethod · 0.45

Tested by

no test coverage detected