read_output
Retrieve terminal output from active processes to monitor command execution results and track ongoing operations in your system.
Instructions
Read new output from a running terminal session.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pid | Yes |
Implementation Reference
- src/tools/execute.ts:30-45 (handler)The core handler function that implements the read_output tool logic. Parses input arguments using the schema, fetches new output for the given PID from the terminal manager, and returns formatted text content.export async function readOutput(args: unknown) { const parsed = ReadOutputArgsSchema.safeParse(args); if (!parsed.success) { throw new Error(`Invalid arguments for read_output: ${parsed.error}`); } const output = terminalManager.getNewOutput(parsed.data.pid); return { content: [{ type: "text", text: output === null ? `No session found for PID ${parsed.data.pid}` : output || 'No new output available' }], }; }
- src/tools/schemas.ts:9-11 (schema)Zod schema defining the input parameters for read_output: requires a numeric PID identifying the terminal session.export const ReadOutputArgsSchema = z.object({ pid: z.number(), });
- src/server.ts:66-71 (registration)Tool registration in the MCP server's ListToolsRequestHandler, specifying name, description, and input schema for read_output.{ name: "read_output", description: "Read new output from a running terminal session.", inputSchema: zodToJsonSchema(ReadOutputArgsSchema), },
- src/server.ts:220-223 (registration)Dispatch handler in the MCP server's CallToolRequestHandler that parses arguments and delegates to the readOutput implementation.case "read_output": { const parsed = ReadOutputArgsSchema.parse(args); return readOutput(parsed); }