Skip to main content
Glama

runRemoteCommand

Execute shell commands on remote SSH hosts to manage systems, run scripts, or perform administrative tasks securely through the MCP SSH Agent interface.

Instructions

Executes a shell command on an SSH host

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
hostAliasYesAlias or hostname of the SSH host
commandYesThe shell command to execute

Implementation Reference

  • The main handler function for the 'runRemoteCommand' tool. It connects to the specified SSH host using the SSHClient class, executes the given command remotely, and returns the stdout, stderr, and exit code.
    async runRemoteCommand(hostAlias: string, command: string): Promise<CommandResult> { try { // First connect to the host await this.connectToHost(hostAlias); // Execute the command const result = await this.ssh.execCommand(command); return { stdout: result.stdout, stderr: result.stderr, code: result.code || 0 }; } catch (error) { console.error(`Error executing command on ${hostAlias}:`, error); return { stdout: '', stderr: error instanceof Error ? error.message : String(error), code: 1 }; } finally { this.ssh.dispose(); } }
  • Type definition for the output of runRemoteCommand, defining the structure of CommandResult returned by the tool.
    export interface CommandResult { stdout: string; stderr: string; code: number; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/AiondaDotCom/mcp-ssh'

If you have feedback or need assistance with the MCP directory API, please join our Discord server