Skip to main content
Glama
bvisible

MCP SSH Manager

ssh_session_send

Execute commands in active SSH sessions to manage remote servers, automate tasks, and control deployments through the MCP SSH Manager.

Instructions

Send a command to an existing SSH session

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sessionYesSession ID from ssh_session_start
commandYesCommand to execute in the session
timeoutNoCommand timeout in milliseconds (default: 30000)

Implementation Reference

  • The 'ssh_session_send' tool is registered/listed in the 'sessions' group within the central tool registry manifest used for conditional registration and validation.
    sessions: [
      'ssh_session_start',
      'ssh_session_send',
      'ssh_session_list',
      'ssh_session_close'
    ],
  • Core implementation for executing/sending commands in a persistent SSH session. This is the primary logic behind the ssh_session_send tool: sends command via shell.write, waits for prompt, parses output, handles state/context.
    async execute(command, options = {}) {
      if (this.state !== SESSION_STATES.READY) {
        throw new Error(`Session ${this.id} is not ready (state: ${this.state})`);
      }
    
      this.state = SESSION_STATES.BUSY;
      this.lastActivity = new Date();
    
      try {
        // Clear buffers
        this.outputBuffer = '';
        this.errorBuffer = '';
    
        // Add to history unless silent
        if (!options.silent) {
          this.context.history.push({
            command,
            timestamp: new Date(),
            cwd: this.context.cwd
          });
    
          logger.info(`Session ${this.id} executing`, {
            command: command.substring(0, 100),
            server: this.serverName
          });
        }
    
        // Send command
        this.shell.write(command + '\n');
    
        // Wait for command to complete
        await this.waitForPrompt(options.timeout || 30000);
    
        // Parse output (remove command echo and prompt)
        let output = this.outputBuffer;
    
        // Remove the command echo (first line)
        const lines = output.split('\n');
        if (lines[0].includes(command)) {
          lines.shift();
        }
    
        // Remove the prompt (last line)
        const lastLine = lines[lines.length - 1];
        if (lastLine.match(/[$#>]\s*$/)) {
          lines.pop();
        }
    
        output = lines.join('\n').trim();
    
        // Check for command success (basic heuristic)
        const success = !this.errorBuffer && !output.includes('command not found');
    
        // Update context if command might have changed it
        if (command.startsWith('cd ') || command.startsWith('export ')) {
          await this.updateContext();
        }
    
        this.state = SESSION_STATES.READY;
    
        return {
          success,
          output,
          error: this.errorBuffer,
          session: this.id
        };
    
      } catch (error) {
        this.state = SESSION_STATES.ERROR;
        logger.error(`Session ${this.id} execution failed`, {
          command,
          error: error.message
        });
        throw error;
      }
    }
  • Retrieves an active SSH session by ID, which would be called by the ssh_session_send handler to access the session before sending a command.
    export function getSession(sessionId) {
      const session = sessions.get(sessionId);
    
      if (!session) {
        throw new Error(`Session ${sessionId} not found`);
      }
    
      if (session.state === SESSION_STATES.CLOSED) {
        throw new Error(`Session ${sessionId} is closed`);
      }
    
      return session;
    }
Behavior2/5

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

With no annotations provided, the description carries full burden but offers limited behavioral insight. It mentions sending a command to an existing session but doesn't disclose critical traits like authentication needs, error handling, output format, or side effects (e.g., session persistence). This is inadequate for a tool that likely involves remote execution and potential security implications.

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, direct sentence with zero wasted words, front-loading the core action and resource. It efficiently communicates the essential purpose without unnecessary elaboration, making it easy for an agent to parse quickly.

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

Completeness2/5

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

Given no annotations, no output schema, and a tool that interacts with SSH sessions (implying complexity like remote execution, timeouts, and potential errors), the description is incomplete. It lacks details on return values, error conditions, prerequisites, or behavioral nuances, leaving significant gaps for an agent to operate effectively.

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?

Schema description coverage is 100%, so the schema fully documents parameters (session ID, command, timeout). The description adds no additional semantic context beyond implying 'session' comes from 'ssh_session_start', which is minimal value. Baseline 3 is appropriate as the schema does the heavy lifting, but the description doesn't compensate with extra insights.

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

Purpose4/5

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

The description clearly states the action ('Send a command') and target resource ('to an existing SSH session'), making the purpose immediately understandable. However, it doesn't differentiate from similar siblings like 'ssh_execute' or 'ssh_execute_sudo', which could also involve sending commands via SSH, leaving some ambiguity about when to choose this specific tool.

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?

The description provides minimal guidance by mentioning 'an existing SSH session', implying it requires a session started via 'ssh_session_start'. However, it lacks explicit when-to-use advice, alternatives (e.g., vs. 'ssh_execute'), or exclusions, leaving the agent to infer usage context without clear 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/bvisible/mcp-ssh-manager'

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