iterm2-mcp
Provides full control over iTerm2 terminal emulator on macOS, including managing windows/tabs/sessions, sending commands and control characters, reading screen content, and accessing session variables.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@iterm2-mcp run ls -la in the current terminal"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
iterm2-mcp
An MCP server that provides full control over iTerm2.
Prerequisites
iTerm2 running on macOS.
Preferences > General > Magic > "Enable Python API" must be checked.
Install iTerm2 shell integration in your shell.
run_commandand session variables likepath/jobNamedepend on it. Without it,run_commandfalls back to its timeout.
The first time the server connects, iTerm2 will prompt you to approve the binary. Approve once; subsequent launches are automatic.
Related MCP server: iTerm MCP Server
Install
uv tool install iterm2-mcpOr from source:
git clone https://github.com/lorencarvalho/iterm2-mcp.git
cd iterm2-mcp
uv syncRegister with Claude
Claude Code:
claude mcp add iterm2 -- uvx iterm2-mcpClaude Desktop — add to ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"iterm2": {
"command": "uvx",
"args": ["iterm2-mcp"]
}
}
}Security
This server can type into terminals, run commands, and close sessions — anything you can do in iTerm2. Only connect it to MCP clients you trust. It has no sandboxing beyond what iTerm2 itself provides.
Tools
Most tools accept an optional session_id — omit it to target the currently active
session.
Tool | Purpose |
| Tree of windows/tabs/sessions with IDs |
| ID and name of the focused session |
| Bring a session to the foreground |
| Send text (optionally with newline) |
| Send Ctrl-C, Ctrl-D, Ctrl-Z, ESC, etc. |
| Send a raw ANSI escape (e.g. |
| Read the visible screen as plain text |
| Current cursor |
| Send a command and wait for |
| Open a new iTerm2 window |
| Open a new tab |
| Split a pane horizontally or vertically |
| Close a specific session |
| Rename a session |
| Set the iTerm2 badge text |
| Clear screen and scrollback |
| Enumerate iTerm2 profiles |
| Read an iTerm2 session variable |
Development
uv sync
uv run ruff check
uv run ruff format
uv run ty checkLicense
MIT
Available Tools
18 toolsclear_bufferA
Clear both the visible screen and the scrollback buffer.
Uses the iTerm2-proprietary OSC 1337 ; ClearScrollback control sequence
(https://iterm2.com/documentation-escape-codes.html).
:param session_id: Target session UUID. Defaults to the active session.
Inputs: session_id. Returns: result
close_sessionB
Close a specific session.
:param session_id: The session UUID to close. :param force: If True, skip iTerm2's "running process" confirmation prompt.
Inputs: session_id (required), force. Returns: result
create_tabB
Create a new tab in a window.
:param window_id: Target window ID. Defaults to the current window. :param command: Optional shell command to run in the new tab's session. :param profile: Name of the iTerm2 profile to use.
Inputs: command, profile, window_id. Returns: result
create_windowA
Create a new iTerm2 window.
:param command: Optional shell command to run in the new session. :param profile: Name of the iTerm2 profile to use. Defaults to the default profile.
Inputs: command, profile. Returns: result
focus_sessionB
Bring a session to the foreground.
:param session_id: The session UUID to activate. Its window is raised and its tab/pane is selected.
Inputs: session_id (required). Returns: result
get_active_sessionA
Return the ID and name of the currently focused iTerm2 session.
Inputs: no named parameters. Returns: result
get_cursor_positionA
Return the cursor coordinates x, y within the visible screen.
:param session_id: Target session UUID. Defaults to the active session.
Inputs: session_id. Returns: result
get_variableA
Read an iTerm2 session variable.
Commonly useful names: jobName, jobPid, path (requires shell
integration), username, hostname, rows, columns,
autoName. Prefix with user. for variables set via iTerm2 custom
control sequences.
:param name: The variable name to read. :param session_id: Target session UUID. Defaults to the active session.
Inputs: name (required), session_id. Returns: result
list_profilesA
List all iTerm2 profiles with their names and GUIDs.
Inputs: no named parameters. Returns: result
list_sessionsA
List all iTerm2 windows, tabs, and sessions.
Returns a tree with session IDs that can be passed to other tools. The
* marker shows the currently focused window, tab, and session.
Inputs: no named parameters. Returns: result
read_screenA
Read the visible contents of an iTerm2 session as plain text.
ANSI escape codes are stripped. Trailing blank lines are trimmed.
:param session_id: Target session UUID. Defaults to the active session. :param max_lines: If set, return only the last N lines.
Inputs: max_lines, session_id. Returns: result
run_commandA
Run a command and wait for it to finish, returning the resulting screen.
Completion is detected via iTerm2's PromptMonitor COMMAND_END
notification, which requires iTerm2 shell integration to be installed in
the target shell. If the prompt-end event does not arrive within
timeout_seconds, the current screen is returned with a [timeout]
marker.
:param command: The command line to run.
:param session_id: Target session UUID. Defaults to the active session.
:param timeout_seconds: How long to wait for COMMAND_END before
giving up.
Inputs: command (required), session_id, timeout_seconds. Returns: result
send_control_characterA
Send a control character to an iTerm2 session.
Supported values: any single letter A-Z (Ctrl-A through Ctrl-Z),
ESC/ESCAPE for Escape (0x1B), and ] for the telnet escape
(0x1D).
:param letter: The control key name; see above for accepted forms. :param session_id: Target session UUID. Defaults to the active session.
Inputs: letter (required), session_id. Returns: result
send_escape_sequenceA
Send a raw escape sequence to an iTerm2 session.
Python string escapes in sequence are interpreted before sending, so
values like \x1b[2J (clear screen) or \x1b[H (cursor home) work
as expected.
:param sequence: The escape sequence string. :param session_id: Target session UUID. Defaults to the active session.
Inputs: sequence (required), session_id. Returns: result
set_badgeA
Set the iTerm2 session badge (translucent overlay text).
The profile's Badge field must reference \(user.badge) for the value
to show up; this is the default in stock profiles.
:param badge: Text to display as the badge. :param session_id: Target session UUID. Defaults to the active session.
Inputs: badge (required), session_id. Returns: result
set_session_nameB
Set the title/name of an iTerm2 session.
:param name: The new session name. :param session_id: Target session UUID. Defaults to the active session.
Inputs: name (required), session_id. Returns: result
split_paneA
Split an iTerm2 pane horizontally or vertically.
:param session_id: Session UUID to split. Defaults to the active session. :param vertical: If True, split left/right; if False, split top/bottom. :param profile: Name of the iTerm2 profile to use for the new pane. :param command: Optional command to run in the new pane after the split.
Inputs: command, profile, vertical, session_id. Returns: result
write_to_terminalA
Send text to an iTerm2 session.
:param text: The characters to send.
:param session_id: Target session UUID. Defaults to the active session.
:param add_newline: If True (the default), appends \n so commands
execute. Set to False to type without submitting, e.g. when filling an
interactive prompt.
Inputs: text (required), session_id, add_newline. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 18 tools
Each tool targets a distinct action (e.g., clear, close, create, focus, get, list, read, run, send, set, split, write). Even closely related tools like write_to_terminal and send_control_character have clear differentiation through descriptions.
All tool names follow a consistent verb_noun pattern in snake_case (e.g., clear_buffer, create_tab, get_variable, set_badge). No mixing of conventions or ambiguous prefixes.
18 tools is slightly above the typical 5-15 range, but each tool has a well-defined purpose covering window, tab, session, and terminal operations. No obvious bloat.
Covers core CRUD and lifecycle operations for sessions/tabs/windows, plus screen reading, command execution, variable access, and profile listing. Minor gaps like missing pane resizing or session info retrieval, but nothing critical for automation.
Maintenance
Related MCP Connectors
Connect ChatGPT and Claude to your Mac, Windows or Linux with secure MCP remote access.
Termalin's hosted MCP server. Claude, ChatGPT or any MCP client runs commands, moves files over SFTP, queries databases and reads server metrics and monitoring alerts on your servers, keylessly through Termalin Connectors: no SSH key is handed over and no inbound port is opened. Per-host command policy and an audit log. Needs a termal.in Pro or Team account (new accounts start with a 14-day Pro trial).
Shared memory MCP server for Claude Code, Codex, Gemini CLI and Cursor. Cited, editable.
Augments MCP Server - A comprehensive framework documentation provider for Claude Code
Related MCP Servers
- AlicenseAqualityDmaintenanceThis MCP server enables users to execute shell commands in the current iTerm2 session through integration with Claude Desktop, facilitating seamless command execution via the Model Context Protocol.3178 npm572MIT
- AlicenseAqualityDmaintenanceA Model Context Protocol server that enables AI assistants to interact with iTerm2 terminals, allowing creation and management of terminal sessions, command execution, and reading terminal output.578 npm14ISC
- AlicenseAqualityDmaintenanceAn 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.402MIT
- FlicenseBqualityCmaintenanceAn MCP server that exposes iTerm2 tab control as native tools, designed for the conductor pattern where one Claude/Codex session drives sibling tabs.7-