Execute a single tool and return the result. Args: tool_name: Name of the tool to execute. tool_args: Arguments for the tool. is_catch_exception: Whether to catch exceptions internally (passed to MCP client). Return
(
self,
tool_name: str,
tool_args: Dict[str, Any],
is_catch_exception: bool = False,
)
| 79 | self.submodule_registry: Dict[str, Any] = submodule_registry or {} |
| 80 | |
| 81 | def execute( |
| 82 | self, |
| 83 | tool_name: str, |
| 84 | tool_args: Dict[str, Any], |
| 85 | is_catch_exception: bool = False, |
| 86 | ) -> ToolResult: |
| 87 | """Execute a single tool and return the result. |
| 88 | |
| 89 | Args: |
| 90 | tool_name: Name of the tool to execute. |
| 91 | tool_args: Arguments for the tool. |
| 92 | is_catch_exception: Whether to catch exceptions internally |
| 93 | (passed to MCP client). |
| 94 | |
| 95 | Returns: |
| 96 | ToolResult containing the execution outcome. |
| 97 | """ |
| 98 | is_submodule = tool_name in self.submodule_registry |
| 99 | |
| 100 | try: |
| 101 | output = self.mcp_client.invoke( |
| 102 | tool_name, |
| 103 | tool_args, |
| 104 | is_catch_exception=is_catch_exception, |
| 105 | ) |
| 106 | return ToolResult( |
| 107 | tool_name=tool_name, |
| 108 | tool_args=tool_args, |
| 109 | success=True, |
| 110 | output=output, |
| 111 | is_submodule=is_submodule, |
| 112 | ) |
| 113 | except Exception as e: |
| 114 | return ToolResult( |
| 115 | tool_name=tool_name, |
| 116 | tool_args=tool_args, |
| 117 | success=False, |
| 118 | error=str(e), |
| 119 | is_submodule=is_submodule, |
| 120 | ) |
| 121 | |
| 122 | def is_submodule_tool(self, tool_name: str) -> bool: |
| 123 | """Check if a tool name corresponds to a submodule. |
no test coverage detected