Skip to main content
Glama

iterm-logs-mcp

Local MCP server exposing iTerm2 tab/session logs to any MCP-capable agent. Reads terminal state via AppleScript — the agent decides which tab to read by matching on cwd/job, no built-in fuzzy-matching logic on the server side.

macOS + iTerm2 only. Local stdio server — not deployed anywhere.

Tools

  • list_iterm_tabs() — enumerates every open window/tab/session: session_id, window_index, tab_index, name, tty, cwd, job.

  • get_iterm_tab_logs(session_id, max_lines=500) — returns the last max_lines lines of scrollback for that session.

  • send_iterm_command(session_id, command, press_enter=True) — types command into that session and presses Enter (unless press_enter=False). Doesn't wait for output; follow up with get_iterm_tab_logs. This runs arbitrary commands in your real terminals — keep the tool on "ask" in your MCP client rather than auto-approving it.

  • open_iterm_window(cwd=None) — opens a new iTerm2 window with the default profile and returns its session_id. If cwd is given, cds into it first.

  • open_iterm_tab(session_id, cwd=None) — opens a new tab in the existing window containing that session and returns the new tab's session_id. If cwd is given, cds into it first.

  • stop_iterm_process(session_id, timeout=5.0, force=False) — sends Ctrl-C to that session and waits up to timeout seconds for it to return to its shell. With force=True, anything still running afterwards gets SIGTERM. Returns stopped, the method used, and any remaining processes. Running state comes from the tty's foreground process group (ps), not iTerm2's jobName, which can read zsh while a child is still running.

  • close_iterm_window(session_id, force=False) — closes the whole window containing that session, all tabs included. Refuses and lists the busy sessions if any tab is still running something, unless force=True.

  • close_iterm_tab(session_id, force=False) — closes the tab containing that session, split panes included; other tabs stay open, and closing a window's last tab closes the window. Refuses and lists the busy sessions if the tab is still running something, unless force=True.

Related MCP server: it2mcp

First run

The first AppleScript call against iTerm2 triggers a one-time macOS Automation permission prompt for whichever process runs this script (Terminal, iTerm2, or your MCP client host). Grant it once in System Settings → Privacy & Security → Automation.

Run it

uv run --directory /path/to/iterm-logs-mcp server.py

Register with Claude Code

claude mcp add iterm-logs -- uv run --directory /path/to/iterm-logs-mcp server.py

Register with Claude Desktop

Add to claude_desktop_config.json:

{
  "mcpServers": {
    "iterm-logs": {
      "command": "uv",
      "args": [
        "run",
        "--directory",
        "/path/to/iterm-logs-mcp",
        "server.py"
      ]
    }
  }
}

Available Tools

2 tools
get_iterm_tab_logsA

Get scrollback/log contents for one iTerm2 session, identified by the session_id returned from list_iterm_tabs. Returns the last max_lines lines.

Inputs: session_id (required), max_lines. Returns: result

list_iterm_tabsA

List every open iTerm2 window/tab/session with its cwd and running job, so the caller can pick which one to read logs from.

Inputs: no named parameters. Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.4/5.0

    Scored across 2 tools

    Disambiguation5/5

    The two tools have clearly distinct purposes: one lists all open tabs with session IDs, the other retrieves logs for a specific session. There is no overlap or confusion.

    Naming Consistency5/5

    Both names follow a consistent verb_noun pattern in snake_case: list_iterm_tabs and get_iterm_tab_logs. The naming is clear and predictable.

    Tool Count3/5

    With only 2 tools, the set is minimal but covers the basic workflow of listing tabs and retrieving logs. However, it feels thin for a server claiming to provide log access, and could benefit from additional filtering or search tools.

    Completeness4/5

    The tool surface covers the core use case of listing tabs and reading logs. Minor gaps exist, such as no tool for retrieving full logs without a line limit or for searching within logs, but these are not critical.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      D
      maintenance
      An MCP server that enables AI agents to control the macOS Terminal.app using AppleScript and the zmx session manager. It allows agents to send keystrokes, type text, and capture screen output in real-time.
      -
    • A
      license
      A
      quality
      D
      maintenance
      An MCP server that enables AI assistants to control iTerm2 sessions, windows, tabs, and profiles using the official iTerm2 Python API. It includes a security model with session tagging and tiered permissions to ensure safe and controlled terminal interactions.
      40
      2
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      An MCP server that provides full control over iTerm2 terminal sessions on macOS. It enables users to manage windows, tabs, and panes, run commands, read screen content, and interact with terminal sessions through Claude.
      18
      163 PyPI
      1
      MIT