Execute Command
execute_commandRun commands on an SSH host through a persistent session; long-running tasks switch to async tracking, and sudo or network-device enable mode can be handled automatically.
Instructions
Execute a command on an SSH host using a persistent session.
Starts synchronously and waits for completion. If the command doesn't complete within the timeout, it automatically transitions to async mode and returns a command ID for tracking.
The host parameter can be either a hostname/IP or an SSH config alias. If an SSH config alias is provided, configuration will be read from ~/.ssh/config.
For network devices (routers, switches), use enable_password to automatically enter privileged/enable mode before executing commands.
For Unix/Linux hosts requiring sudo, use sudo_password to automatically handle the sudo password prompt. The command will be automatically prefixed with 'sudo' if not already present.
Advanced Features:
Automatic timeout handling with async transition
Interactive command support with input capability
Command interruption (Ctrl+C) for stuck processes
Session persistence across multiple commands
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"host": "<host>",
"command": "<command>"
},
"name": "execute_command"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| host | Yes | Hostname, IP address, or SSH config alias (e.g., "myserver") | |
| port | No | SSH port (optional, will use SSH config or default 22) | |
| command | Yes | Command to execute | |
| timeout | No | Timeout in seconds for command execution (default: 30) | |
| password | No | Password (optional) | |
| username | No | SSH username (optional, will use SSH config or current user) | |
| key_filename | No | Path to SSH key file (optional, will use SSH config) | |
| sudo_password | No | Password for sudo commands on Unix/Linux hosts (optional) | |
| enable_command | No | Command to enter enable mode (default: "enable") | enable |
| enable_password | No | Enable mode password for network devices (optional) |