MCP Hub
Back to servers

it2mcp

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.

glama
Updated
Mar 13, 2026

it2mcp

MCP server for controlling iTerm2 from AI assistants, editors, and other MCP clients.

Built on iTerm2's official Python API, it2mcp exposes 40 tools for managing sessions, windows, tabs, profiles, and more — with a security model that keeps you in control.

Prerequisites

  • macOS with iTerm2 installed
  • Python 3.10+
  • uv (recommended) or pip
  • iTerm2's Python API enabled: Preferences → General → Magic → Enable Python API

Installation

git clone https://github.com/youruser/it2mcp.git
cd it2mcp
uv sync

Usage

Add to Claude Code

claude mcp add -s user it2mcp -- uv --directory /path/to/it2mcp run it2mcp

Add to other MCP clients

Add to your MCP client configuration:

{
  "mcpServers": {
    "it2mcp": {
      "command": "uv",
      "args": ["--directory", "/path/to/it2mcp", "run", "it2mcp"]
    }
  }
}

Run standalone

uv run it2mcp

Security

it2mcp ships secure by default. Two mechanisms protect your terminal sessions:

Session tagging

Sessions must be explicitly tagged before MCP can interact with them. Untagged sessions are invisible to all tools except session_list (which shows their mcp_enabled status so you know what to tag).

Tag a session (run this in the session's terminal):

# Using the it2 CLI
it2 session set-var user.mcp_enabled true

# Or using iTerm2's escape sequence (no dependencies)
printf '\033]1337;SetUserVar=%s=%s\007' mcp_enabled $(echo -n true | base64)

Untag a session:

it2 session set-var user.mcp_enabled false

Tags are not persistent — they reset when the session ends. This is intentional: you opt in per-session, per-lifetime.

Permission tiers

Tools are grouped into three tiers:

TierToolsDescription
readsession_list, session_read, session_get_variable, tab_list, window_list, app_get_focus, profile_list, profile_show, app_version, app_theme, window_arrange_listObservation only
interactsession_send, session_run, session_split, session_clear, session_focus, session_set_name, session_set_variable, tab_new, tab_select, tab_next, tab_prev, tab_move, window_new, window_focus, window_move, window_resize, window_fullscreen, window_arrange_save, window_arrange_restore, app_activate, broadcast_on, broadcast_off, broadcast_add, profile_apply, batch, send_keystrokesCan send input and modify layout
destructivesession_close, session_restart, tab_close, window_closeCan terminate sessions and close windows

By default, only read is enabled.

Audit log

Every tool invocation is logged to ~/.local/share/it2mcp/audit.jsonl with timestamp, tool name, parameters, and result.

Configuration

Create ~/.config/it2mcp/config.yaml:

# Which permission tiers to enable
permissions:
  - read
  - interact
  # - destructive

# Require sessions to have user.mcp_enabled set (default: true)
require_tag: true

# Audit log path (set to null to disable)
audit_log: ~/.local/share/it2mcp/audit.jsonl

Override the config path with the IT2MCP_CONFIG environment variable.

Tools

Session

ToolTierDescription
session_listreadList all sessions with IDs, names, sizes, and mcp_enabled status
session_readreadRead visible screen contents
session_get_variablereadGet a session variable (e.g. path, name, tty)
session_sendinteractSend text without pressing Enter
session_runinteractExecute a command (text + Enter)
session_splitinteractSplit into a new pane
session_clearinteractClear screen (Ctrl+L)
session_focusinteractActivate a specific session
session_set_nameinteractSet session name
session_set_variableinteractSet a session variable
session_closedestructiveClose a session
session_restartdestructiveRestart a session

Window

ToolTierDescription
window_listreadList all windows with positions and sizes
window_arrange_listreadList saved window arrangements
window_newinteractCreate a new window
window_focusinteractActivate a specific window
window_moveinteractMove window to screen position
window_resizeinteractResize a window
window_fullscreeninteractSet fullscreen on/off/toggle
window_arrange_saveinteractSave current arrangement
window_arrange_restoreinteractRestore a saved arrangement
window_closedestructiveClose a window

Tab

ToolTierDescription
tab_listreadList all tabs with IDs and active state
tab_newinteractCreate a new tab
tab_selectinteractSelect tab by ID or index
tab_nextinteractSwitch to next tab
tab_previnteractSwitch to previous tab
tab_moveinteractMove tab to its own window
tab_closedestructiveClose a tab

App

ToolTierDescription
app_get_focusreadGet focused window/tab/session info
app_versionreadGet iTerm2 version
app_themereadGet or set theme
app_activateinteractBring iTerm2 to front

Broadcast

ToolTierDescription
broadcast_oninteractEnable broadcasting to all sessions in current tab
broadcast_offinteractDisable broadcasting
broadcast_addinteractCreate broadcast group with specific sessions

Profile

ToolTierDescription
profile_listreadList all profiles
profile_showreadShow profile details
profile_applyinteractApply a profile to a session

Batch

ToolTierDescription
batchinteractExecute multiple operations in a single iTerm2 connection

The batch tool accepts a list of operations and runs them sequentially over one connection. Supports a sleep operation for timing between steps. Each operation's tier is checked individually.

[
  {"op": "session_run", "command": "echo hello"},
  {"op": "sleep", "seconds": 1.0},
  {"op": "session_read"}
]

Acknowledgments

Built on top of it2 by @mkusaka — a powerful CLI for controlling iTerm2 via its Python API. it2mcp wraps the same underlying iterm2 Python API and was heavily inspired by it2's command structure.

License

MIT

Reviews

No reviews yet

Sign in to write a review