Skip to main content
Glama

read_terminal_output

Extract terminal output from iTerm to analyze command results or error messages. Specify how many lines to read for focused debugging or monitoring.

Instructions

Reads the output from the active iTerm terminal

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
linesOfOutputYesThe number of lines of output to read.

Implementation Reference

  • MCP server handler for the 'read_terminal_output' tool. Extracts 'linesOfOutput' from arguments (default 25), calls TtyOutputReader.call(), and returns the output as text content.
    case "read_terminal_output": {
      const linesOfOutput = Number(request.params.arguments?.linesOfOutput) || 25
      const output = await TtyOutputReader.call(linesOfOutput)
    
      return {
        content: [{
          type: "text",
          text: output
        }]
      };
    }
  • Schema definition for the 'read_terminal_output' tool, specifying input as object with required 'linesOfOutput' number.
    name: "read_terminal_output",
    description: "Reads the output from the active iTerm terminal",
    inputSchema: {
      type: "object",
      properties: {
        linesOfOutput: {
          type: "number",
          description: "The number of lines of output to read."
        },
      },
      required: ["linesOfOutput"]
    }
  • src/index.ts:26-72 (registration)
    Tool registration in ListToolsRequestSchema handler, where 'read_terminal_output' is listed among available tools.
      return {
        tools: [
          {
            name: "write_to_terminal",
            description: "Writes text to the active iTerm terminal - often used to run a command in the terminal",
            inputSchema: {
              type: "object",
              properties: {
                command: {
                  type: "string",
                  description: "The command to run or text to write to the terminal"
                },
              },
              required: ["command"]
            }
          },
          {
            name: "read_terminal_output",
            description: "Reads the output from the active iTerm terminal",
            inputSchema: {
              type: "object",
              properties: {
                linesOfOutput: {
                  type: "number",
                  description: "The number of lines of output to read."
                },
              },
              required: ["linesOfOutput"]
            }
          },
          {
            name: "send_control_character",
            description: "Sends a control character to the active iTerm terminal (e.g., Control-C)",
            inputSchema: {
              type: "object",
              properties: {
                letter: {
                  type: "string",
                  description: "The letter corresponding to the control character (e.g., 'C' for Control-C)"
                },
              },
              required: ["letter"]
            }
          }
        ]
      };
    });
  • Core helper method TtyOutputReader.call() that retrieves full terminal buffer and returns the last N lines (or all if unspecified). Called directly by the tool handler.
    export default class TtyOutputReader {
      static async call(linesOfOutput?: number) {
        const buffer = await this.retrieveBuffer();
        if (!linesOfOutput) {
          return buffer;
        }
        const lines = buffer.split('\n');
        return lines.slice(-linesOfOutput - 1).join('\n');
      }
  • Supporting helper TtyOutputReader.retrieveBuffer() that uses AppleScript via osascript to fetch the full contents of the current iTerm2 session.
      static async retrieveBuffer(): Promise<string> {
        const ascript = `
          tell application "iTerm2"
            tell front window
              tell current session of current tab
                set numRows to number of rows
                set allContent to contents
                return allContent
              end tell
            end tell
          end tell
        `;
        
        const { stdout: finalContent } = await execPromise(`osascript -e '${ascript}'`);
        return finalContent.trim();
      }
    }
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 doesn't disclose whether this requires specific permissions, how it handles errors (e.g., if no terminal is active), what format the output returns, or any rate limits. The description only states what it does, not how it behaves.

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's front-loaded and appropriately sized for a simple tool, with zero wasted information.

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 and no output schema, the description is incomplete for a tool that interacts with a terminal. It lacks details on behavioral traits (e.g., error handling, output format), usage context, and doesn't compensate for the absence of structured data, making it insufficient for reliable agent 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?

The input schema has 100% description coverage, fully documenting the single parameter 'linesOfOutput'. The description adds no additional parameter semantics beyond what the schema provides, so it meets the baseline score of 3 for high schema coverage without extra value.

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 ('Reads') and target resource ('output from the active iTerm terminal'), making the purpose immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'write_to_terminal' or 'send_control_character', which would require mentioning it's for reading rather than writing or control operations.

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., having an active terminal), exclusions, or comparisons to sibling tools, leaving the agent to infer usage context solely from the tool name and description.

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/lite/iterm-mcp'

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