read-output
Retrieve terminal output using the terminal ID to monitor or process session results in iTerm2 via the MCP server.
Instructions
Read the output from a specific terminal
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| terminalId | Yes | ID of the terminal to read output from |
Implementation Reference
- index.js:166-190 (handler)The handler function that executes the logic for the 'read-output' tool. It fetches the terminal by ID, retrieves and clears its output buffer, and returns the output as structured content or an error message if the terminal is not found.async ({ terminalId }) => { const terminal = terminals.get(terminalId); if (!terminal) { return { content: [ { type: "text", text: `Terminal ${terminalId} not found`, }, ], }; } const output = terminal.output.join(""); terminal.output.length = 0; // Clear the output buffer return { content: [ { type: "text", text: output || "No output available", }, ], }; }
- index.js:163-165 (schema)The input schema for the 'read-output' tool, specifying the required 'terminalId' parameter as a string using Zod validation.{ terminalId: z.string().describe("ID of the terminal to read output from"), },
- index.js:160-191 (registration)The registration of the 'read-output' tool using server.tool(), including name, description, schema, and handler function.server.tool( "read-output", "Read the output from a specific terminal", { terminalId: z.string().describe("ID of the terminal to read output from"), }, async ({ terminalId }) => { const terminal = terminals.get(terminalId); if (!terminal) { return { content: [ { type: "text", text: `Terminal ${terminalId} not found`, }, ], }; } const output = terminal.output.join(""); terminal.output.length = 0; // Clear the output buffer return { content: [ { type: "text", text: output || "No output available", }, ], }; } );