Skip to main content
Glama
ferrislucas

iTerm MCP Server

by ferrislucas

read_terminal_output

Extract specific lines of terminal output from the active iTerm session to analyze or process command results. Integrates with iTerm MCP Server for efficient shell command execution.

Instructions

Reads the output from the active iTerm terminal

Input Schema

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

Implementation Reference

  • The handler for the 'read_terminal_output' tool. It extracts the number of lines requested, calls TtyOutputReader.call to get the output, and returns it 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
        }]
      };
    }
  • src/index.ts:42-55 (registration)
    Registration of the 'read_terminal_output' tool in the list of available tools, including its name, description, and input schema.
    {
      name: "read_terminal_output",
      description: "Reads the output from the active iTerm terminal",
      inputSchema: {
        type: "object",
        properties: {
          linesOfOutput: {
            type: "integer",
            description: "The number of lines of output to read."
          },
        },
        required: ["linesOfOutput"]
      }
    },
  • The TtyOutputReader.call static method, which retrieves the terminal buffer and returns the last N lines if specified.
    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');
    }
  • The TtyOutputReader.retrieveBuffer static method, which uses AppleScript via osascript to fetch the contents of the current iTerm 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 the full burden of behavioral disclosure. It states the tool reads output but does not mention critical behaviors such as whether it requires specific permissions, if it's read-only (implied but not stated), potential errors (e.g., no active terminal), or rate limits. This leaves significant gaps in understanding how the tool 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 is front-loaded and appropriately sized, making it easy to parse quickly.

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

Completeness3/5

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

Given the tool's low complexity (one parameter, no output schema, no annotations), the description is minimally adequate. It covers the basic purpose but lacks details on behavior, error handling, and usage context, which are important for a tool interacting with a terminal environment.

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 schema description coverage is 100%, with the parameter 'linesOfOutput' fully documented in the schema. The description does not add any additional meaning or context beyond what the schema provides, such as default values or usage examples, so it meets the baseline for high schema coverage.

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 resource ('output from the active iTerm terminal'), making the purpose specific and understandable. However, it does not 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 inputs.

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?

No guidance is provided on when to use this tool versus alternatives. The description lacks context about prerequisites (e.g., requires an active iTerm session) or exclusions, leaving the agent without explicit usage instructions.

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

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

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