Skip to main content
Glama
jackyxhb

Infer MCP Server

by jackyxhb

sshExecute

Execute commands on remote servers via SSH using configured profiles. Run scripts, manage infrastructure, and perform administrative tasks securely from the Infer MCP Server interface.

Instructions

Execute a command on a remote server via SSH using a configured profile

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
profileYesSSH credential profile to use
commandYesCommand to execute
cwdNoWorking directory on remote host
envNoEnvironment variables for the command
timeoutMsNoExecution timeout in milliseconds
maxOutputBytesNoMaximum bytes to capture from stdout/stderr

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
signalNo
stderrYes
stdoutYes
exitCodeYes
truncatedYes
durationMsYes

Implementation Reference

  • The asynchronous handler function for the 'sshExecute' tool. It processes input arguments, sets up progress reporting, executes the SSH command using executeSshCommand from sshService, and returns the structured output including stdout, stderr, exit code, etc.
    async (args, extra) => {
      const progress = createProgressReporter(extra, "sshExecute");
      const total = 1;
    
      progress?.({ progress: 0, total, message: "Scheduling SSH command" });
    
      const options: SshCommandOptions = {
        cwd: args.cwd,
        env: args.env,
        timeoutMs: args.timeoutMs,
        maxOutputBytes: args.maxOutputBytes,
        signal: extra.signal,
        onProgress: (update) => {
          progress?.({
            progress: update.progress,
            total,
            message: update.message
          });
        }
      };
    
      const result: SshCommandResult = await executeSshCommand(
        args.profile,
        args.command,
        options,
        {
          requestId: String(extra.requestId),
          tool: "sshExecute"
        }
      );
    
      const structuredContent: Record<string, unknown> = {
        stdout: result.stdout,
        stderr: result.stderr,
        truncated: result.truncated,
        exitCode: result.exitCode,
        signal: result.signal,
        durationMs: result.durationMs
      };
    
      return {
        content: [],
        structuredContent
      };
    }
  • Zod schemas defining the input parameters (profile, command, cwd, env, timeoutMs, maxOutputBytes) and output shape (stdout, stderr, truncated, exitCode, signal, durationMs) for the sshExecute tool.
    const SshExecuteInputSchema = z.object({
      profile: z.string().describe("SSH credential profile to use"),
      command: z.string().min(1).describe("Command to execute"),
      cwd: z.string().optional().describe("Working directory on remote host"),
      env: z.record(z.string(), z.string()).optional().describe("Environment variables for the command"),
      timeoutMs: z.number().int().positive().optional().describe("Execution timeout in milliseconds"),
      maxOutputBytes: z
        .number()
        .int()
        .positive()
        .optional()
        .describe("Maximum bytes to capture from stdout/stderr")
    });
    
    const SshExecuteOutputShape = {
      stdout: z.string(),
      stderr: z.string(),
      truncated: z.object({ stdout: z.boolean(), stderr: z.boolean() }),
      exitCode: z.number().nullable(),
      signal: z.string().optional(),
      durationMs: z.number().int().nonnegative()
    };
    
    export const SshExecuteOutputSchema = z.object(SshExecuteOutputShape);
  • The registerSshTool function that registers the 'sshExecute' tool on the MCP server, specifying the tool name, description, input/output schemas, and the handler function.
    export function registerSshTool(server: McpServer): void {
      server.registerTool(
        "sshExecute",
        {
          description: "Execute a command on a remote server via SSH using a configured profile",
          inputSchema: SshExecuteInputSchema.shape,
          outputSchema: SshExecuteOutputShape
        },
        async (args, extra) => {
          const progress = createProgressReporter(extra, "sshExecute");
          const total = 1;
    
          progress?.({ progress: 0, total, message: "Scheduling SSH command" });
    
          const options: SshCommandOptions = {
            cwd: args.cwd,
            env: args.env,
            timeoutMs: args.timeoutMs,
            maxOutputBytes: args.maxOutputBytes,
            signal: extra.signal,
            onProgress: (update) => {
              progress?.({
                progress: update.progress,
                total,
                message: update.message
              });
            }
          };
    
          const result: SshCommandResult = await executeSshCommand(
            args.profile,
            args.command,
            options,
            {
              requestId: String(extra.requestId),
              tool: "sshExecute"
            }
          );
    
          const structuredContent: Record<string, unknown> = {
            stdout: result.stdout,
            stderr: result.stderr,
            truncated: result.truncated,
            exitCode: result.exitCode,
            signal: result.signal,
            durationMs: result.durationMs
          };
    
          return {
            content: [],
            structuredContent
          };
        }
      );
    }
  • The top-level registerTools function that invokes registerSshTool to register the sshExecute tool along with other tools.
    export function registerTools(server: McpServer): void {
      registerSshTool(server);
      registerDbTool(server);
      registerTrainingTool(server);
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure but only states the basic action. It fails to mention critical aspects like security implications, permission requirements, potential side effects (e.g., command execution risks), or error handling, which are essential for a tool that executes commands remotely.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose without unnecessary words. It is appropriately sized and front-loaded, making it easy to understand quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (remote command execution with 6 parameters) and the presence of an output schema (which handles return values), the description is minimally adequate. However, it lacks details on behavioral traits and usage guidelines, which are crucial for safe and effective use, leaving gaps in completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, so the schema fully documents all parameters. The description does not add any additional meaning or context beyond what the schema provides, such as examples or usage notes for parameters like 'profile' or 'timeoutMs'.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Execute a command') and resource ('on a remote server via SSH using a configured profile'), distinguishing it from sibling tools like dbQuery and trainClassifier which involve database operations and machine learning tasks respectively.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives or any prerequisites. The description lacks context about suitable scenarios or exclusions, leaving the agent without usage direction.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/jackyxhb/InferMCPServer'

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