Skip to main content
Glama

ssh_start_interactive_shell

Start an interactive shell session on a remote server via SSH to execute commands and manage systems with PTY support for terminal simulation.

Instructions

Start an interactive shell session with PTY support for typing simulation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
connectionIdYesSSH connection ID
sessionIdYesUnique identifier for this interactive session
shellNoShell to use (e.g., /bin/bash, /bin/zsh)/bin/bash
colsNoTerminal columns
rowsNoTerminal rows

Implementation Reference

  • The core handler function that executes the ssh_start_interactive_shell tool. It parses input parameters, retrieves the SSH connection, requests an interactive shell with PTY support, sets up event emitters for data and close events, and manages the shell session.
    private async handleStartInteractiveShell(args: unknown) {
      const params = StartInteractiveShellSchema.parse(args);
      
      const ssh = connectionPool.get(params.connectionId);
      if (!ssh) {
        throw new McpError(
          ErrorCode.InvalidParams,
          `Connection ID '${params.connectionId}' not found`
        );
      }
    
      if (shellSessions.has(params.sessionId)) {
        throw new McpError(
          ErrorCode.InvalidParams,
          `Session ID '${params.sessionId}' already exists`
        );
      }
    
      try {
        // Create a shell session through SSH
        const shell = await ssh.requestShell({
          cols: params.cols,
          rows: params.rows,
          term: 'xterm-256color'
        });
    
        const emitter = new EventEmitter();
        const session: ShellSession = {
          shell: shell, // SSH ClientChannel
          ssh,
          emitter,
          buffer: '',
          isActive: true
        };
    
        // Set up data handling
        shell.on('data', (data: Buffer) => {
          const text = data.toString();
          session.buffer += text;
          emitter.emit('data', text);
        });
    
        shell.on('close', () => {
          session.isActive = false;
          emitter.emit('close');
        });
    
        shellSessions.set(params.sessionId, session);
    
        return {
          content: [
            {
              type: 'text',
              text: `Interactive shell session '${params.sessionId}' started successfully\nShell: ${params.shell}\nTerminal: ${params.cols}x${params.rows}`,
            },
          ],
        };
      } catch (error) {
        throw new McpError(
          ErrorCode.InternalError,
          `Failed to start interactive shell: ${error instanceof Error ? error.message : String(error)}`
        );
      }
  • Zod schema defining the input parameters and validation for the ssh_start_interactive_shell tool.
    const StartInteractiveShellSchema = z.object({
      connectionId: z.string().describe('SSH connection ID'),
      sessionId: z.string().describe('Unique identifier for this interactive session'),
      shell: z.string().default('/bin/bash').describe('Shell to use (e.g., /bin/bash, /bin/zsh)'),
      cols: z.number().default(80).describe('Terminal columns'),
      rows: z.number().default(24).describe('Terminal rows')
    });
  • src/index.ts:320-333 (registration)
    Tool registration in the ListTools response, defining name, description, and input schema.
      name: 'ssh_start_interactive_shell',
      description: 'Start an interactive shell session with PTY support for typing simulation',
      inputSchema: {
        type: 'object',
        properties: {
          connectionId: { type: 'string', description: 'SSH connection ID' },
          sessionId: { type: 'string', description: 'Unique identifier for this interactive session' },
          shell: { type: 'string', default: '/bin/bash', description: 'Shell to use (e.g., /bin/bash, /bin/zsh)' },
          cols: { type: 'number', default: 80, description: 'Terminal columns' },
          rows: { type: 'number', default: 24, description: 'Terminal rows' }
        },
        required: ['connectionId', 'sessionId']
      },
    },
  • src/index.ts:497-498 (registration)
    Registration of the tool handler in the CallToolRequest switch statement.
    case 'ssh_start_interactive_shell':
      return await this.handleStartInteractiveShell(args);
  • Interface defining the structure of an interactive shell session, used by the handler.
    interface ShellSession {
      shell: any; // SSH ClientChannel
      ssh: NodeSSH;
      emitter: EventEmitter;
      buffer: string;
      isActive: boolean;
    }
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 minimal behavioral insight. It mentions 'PTY support for typing simulation' which hints at interactive capabilities, but fails to disclose critical traits: whether this spawns a persistent session, requires specific permissions, has rate limits, or how output/input are handled (e.g., via ssh_read_output/ssh_send_input). For a complex interactive tool, this is inadequate.

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 front-loads the core purpose without fluff. Every word earns its place, making it easy to parse quickly. No structural issues or redundancy are present.

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?

For a complex interactive tool with no annotations and no output schema, the description is insufficient. It lacks details on behavioral expectations (e.g., session lifecycle, interaction patterns), error handling, or integration with sibling tools like ssh_send_input. Given the context, it should provide more operational guidance.

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%, providing clear documentation for all 5 parameters. The description adds no additional parameter semantics beyond what the schema already states (e.g., it doesn't explain how sessionId is used or PTY relates to cols/rows). Baseline 3 is appropriate when schema does the heavy lifting.

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 ('Start an interactive shell session') and the resource ('with PTY support for typing simulation'), making the purpose evident. It distinguishes from siblings like ssh_execute (non-interactive) and ssh_connect (connection only), but doesn't explicitly name alternatives. A 5 would require explicit sibling differentiation.

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 no guidance on when to use this tool versus alternatives like ssh_execute for non-interactive commands. It doesn't mention prerequisites (e.g., requiring an established SSH connection via ssh_connect), exclusions, or contextual triggers. Usage is implied but not articulated.

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/mahathirmuh/mcp-ssh-server'

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