Skip to main content
Glama
widjis
by widjis

ssh_read_output

Retrieve command execution results from an active SSH shell session by specifying the session ID and optional timeout settings.

Instructions

Read output from an interactive shell session

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sessionIdYesInteractive session ID
timeoutNoTimeout in milliseconds to wait for output
clearBufferNoClear the output buffer after reading

Implementation Reference

  • Handler function that reads output from an interactive SSH shell session buffer, with optional timeout and buffer clearing.
    private async handleReadOutput(args: unknown) {
      const params = ReadOutputSchema.parse(args);
      
      const session = shellSessions.get(params.sessionId);
      if (!session) {
        throw new McpError(
          ErrorCode.InvalidParams,
          `Session ID '${params.sessionId}' not found`
        );
      }
    
      try {
        // Wait for output with timeout
        const output = await new Promise<string>((resolve, reject) => {
          const timeout = setTimeout(() => {
            resolve(session.buffer);
          }, params.timeout);
    
          if (session.buffer) {
            clearTimeout(timeout);
            resolve(session.buffer);
          } else {
            session.emitter.once('data', () => {
              clearTimeout(timeout);
              resolve(session.buffer);
            });
          }
        });
    
        const result = output;
        
        if (params.clearBuffer) {
          session.buffer = '';
        }
    
        return {
          content: [
            {
              type: 'text',
              text: `Output from session '${params.sessionId}':\n${result}`,
            },
          ],
        };
      } catch (error) {
        throw new McpError(
          ErrorCode.InternalError,
          `Failed to read output: ${error instanceof Error ? error.message : String(error)}`
        );
      }
    }
  • Zod schema for validating input parameters to the ssh_read_output tool.
    const ReadOutputSchema = z.object({
      sessionId: z.string().describe('Interactive session ID'),
      timeout: z.number().default(5000).describe('Timeout in milliseconds to wait for output'),
      clearBuffer: z.boolean().default(true).describe('Clear the output buffer after reading')
    });
  • src/index.ts:347-358 (registration)
    Tool registration in the listTools response, including name, description, and input schema.
    {
      name: 'ssh_read_output',
      description: 'Read output from an interactive shell session',
      inputSchema: {
        type: 'object',
        properties: {
          sessionId: { type: 'string', description: 'Interactive session ID' },
          timeout: { type: 'number', default: 5000, description: 'Timeout in milliseconds to wait for output' },
          clearBuffer: { type: 'boolean', default: true, description: 'Clear the output buffer after reading' }
        },
        required: ['sessionId']
      },
  • src/index.ts:501-502 (registration)
    Switch case in CallToolRequest handler that routes to the ssh_read_output handler function.
    case 'ssh_read_output':
      return await this.handleReadOutput(args);
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 reading output but doesn't disclose what happens on timeout, how output is formatted, whether it's blocking/non-blocking, or error conditions. This is inadequate for a tool that interacts with live shell 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 directly states the tool's function without unnecessary words. It's appropriately sized and front-loaded with the core purpose.

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 tool that reads from interactive sessions with no annotations and no output schema, the description is insufficient. It doesn't explain return values, error handling, or important behavioral aspects like what 'output' includes (stdout, stderr, both). More context is needed given the complexity.

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 all three parameters. The description adds no additional parameter context beyond implying a session exists, which is already covered by the sessionId parameter's description. 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 ('Read output') and resource ('from an interactive shell session'), making the purpose immediately understandable. It doesn't explicitly differentiate from siblings like ssh_execute or ssh_send_input, but the focus on reading output from an existing session is reasonably distinct.

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. It doesn't mention prerequisites (e.g., needing an active session via ssh_start_interactive_shell), exclusions, or comparisons to non-interactive execution tools like ssh_execute.

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