Skip to main content
Glama

iTerm MCP Server

by ferrislucas
TtyOutputReader.ts878 B
import { exec } from 'node:child_process'; import { promisify } from 'node:util'; const execPromise = promisify(exec); 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'); } 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(); } }

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