Skip to main content
Glama
widjis
by widjis

ssh_start_interactive_shell

Start an interactive shell session on a remote SSH server to execute commands with terminal emulation and PTY support for typing 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 main handler function for the ssh_start_interactive_shell tool. It parses input using StartInteractiveShellSchema, validates SSH connection and session ID uniqueness, requests an interactive shell via node-ssh with PTY settings, sets up event handlers for data and close events, stores the session in shellSessions map, and returns success message.
    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 for the ssh_start_interactive_shell tool, including connectionId (required), sessionId (required), shell, cols, and rows with defaults and descriptions.
    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:319-333 (registration)
    Tool registration in the ListTools response, defining name 'ssh_start_interactive_shell', description, and inputSchema matching the Zod 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)
    Dispatch in the CallToolRequest handler switch statement that routes calls to ssh_start_interactive_shell to the handleStartInteractiveShell method.
    case 'ssh_start_interactive_shell':
      return await this.handleStartInteractiveShell(args);
  • Global shellSessions Map that stores active interactive shell sessions, used by the handler.
    const shellSessions = new Map<string, ShellSession>();
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. It mentions 'PTY support for typing simulation,' hinting at interactive capabilities, but fails to describe critical behaviors such as session lifecycle management, how output is handled (e.g., via ssh_read_output), or potential side effects like resource consumption. This leaves significant gaps for a tool that initiates interactive sessions.

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 ('Start an interactive shell session') and adds a key feature ('with PTY support for typing simulation') without unnecessary details. Every word earns its place, making it highly concise and well-structured.

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 the complexity of starting an interactive shell session, no annotations, and no output schema, the description is incomplete. It lacks information on return values, error handling, session management dependencies (e.g., on ssh_read_output for reading output), and behavioral nuances, leaving the agent under-informed for effective tool invocation.

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%, with each parameter clearly documented in the input schema (e.g., connectionId as 'SSH connection ID,' shell with default '/bin/bash'). The description adds no additional parameter semantics beyond implying interactive use, so it meets the baseline score of 3 where the 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 specifies key functionality ('with PTY support for typing simulation'), which distinguishes it from non-interactive execution tools like ssh_execute. However, it doesn't explicitly differentiate from all sibling tools, such as ssh_close_interactive_shell, which is related but opposite in purpose.

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 or ssh_connect for establishing connections. It lacks context about prerequisites (e.g., needing an active SSH connection via connectionId) or exclusions, leaving the agent to infer usage from parameter names alone.

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

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