Initialize the execute tool command.
(self)
| 31 | """Command to execute a tool with parameters.""" |
| 32 | |
| 33 | def __init__(self) -> None: |
| 34 | """Initialize the execute tool command.""" |
| 35 | super().__init__() |
| 36 | self._name: str = "execute" |
| 37 | self._description: str = "Execute a tool with parameters" |
| 38 | self._modes: CommandMode = CommandMode.INTERACTIVE | CommandMode.CHAT |
| 39 | self._aliases: list[str] = ["exec", "run"] |
| 40 | self._parameters: list[CommandParameter] = [ |
| 41 | CommandParameter( |
| 42 | name="tool", |
| 43 | type=str, |
| 44 | help="Name of the tool to execute", |
| 45 | required=False, |
| 46 | ), |
| 47 | CommandParameter( |
| 48 | name="params", |
| 49 | type=str, |
| 50 | help="Tool parameters as JSON string", |
| 51 | required=False, |
| 52 | ), |
| 53 | CommandParameter( |
| 54 | name="server", |
| 55 | type=str, |
| 56 | help="Server to use (if multiple available)", |
| 57 | required=False, |
| 58 | ), |
| 59 | ] |
| 60 | self._help_text: str = """ |
| 61 | Execute a tool with JSON parameters. |
| 62 | |
| 63 | Usage: |
| 64 | execute # List all available tools |
| 65 | execute <tool_name> # Show tool parameters and format |
| 66 | execute <tool_name> '<json>' # Execute tool with parameters |
| 67 | |
| 68 | IMPORTANT: Parameters must be in JSON format! |
| 69 | |
| 70 | Examples: |
| 71 | execute # See what tools are available |
| 72 | execute echo_text # See what parameters echo_text needs |
| 73 | execute echo_text '{"message": "Hello"}' # Execute with JSON parameters |
| 74 | execute list_tables '{}' # Execute tool with no parameters |
| 75 | |
| 76 | Common Mistakes to Avoid: |
| 77 | ❌ execute echo_text "hello" # Wrong: Not JSON format |
| 78 | ✅ execute echo_text '{"message": "hello"}' # Correct: Proper JSON |
| 79 | |
| 80 | Tips: |
| 81 | • Always use JSON format: '{"key": "value"}' |
| 82 | • Use single quotes around JSON to avoid escaping |
| 83 | • Use '{}' for tools with no required parameters |
| 84 | • Check parameters first with: execute <tool_name> |
| 85 | """ |
| 86 | self._requires_context: bool = True |
| 87 | |
| 88 | @property |
| 89 | def name(self) -> str: |
nothing calls this directly
no test coverage detected