it2mcp
Provides comprehensive tools for managing iTerm2 terminal sessions, windows, tabs, and profiles, including the ability to read screen contents, execute commands, and control window layouts.
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., "@it2mcp list my open sessions and read the content of the active one"
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.
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
Related MCP server: Terminally MCP
Installation
git clone https://github.com/youruser/it2mcp.git
cd it2mcp
uv syncUsage
Add to Claude Code
claude mcp add -s user it2mcp -- uv --directory /path/to/it2mcp run it2mcpAdd 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 it2mcpSecurity
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 falseTags 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:
Tier | Tools | Description |
read |
| Observation only |
interact |
| Can send input and modify layout |
destructive |
| Can 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.jsonlOverride the config path with the IT2MCP_CONFIG environment variable.
Tools
Session
Tool | Tier | Description |
| read | List all sessions with IDs, names, sizes, and |
| read | Read visible screen contents |
| read | Get a session variable (e.g. |
| interact | Send text without pressing Enter |
| interact | Execute a command (text + Enter) |
| interact | Split into a new pane |
| interact | Clear screen (Ctrl+L) |
| interact | Activate a specific session |
| interact | Set session name |
| interact | Set a session variable |
| destructive | Close a session |
| destructive | Restart a session |
Window
Tool | Tier | Description |
| read | List all windows with positions and sizes |
| read | List saved window arrangements |
| interact | Create a new window |
| interact | Activate a specific window |
| interact | Move window to screen position |
| interact | Resize a window |
| interact | Set fullscreen on/off/toggle |
| interact | Save current arrangement |
| interact | Restore a saved arrangement |
| destructive | Close a window |
Tab
Tool | Tier | Description |
| read | List all tabs with IDs and active state |
| interact | Create a new tab |
| interact | Select tab by ID or index |
| interact | Switch to next tab |
| interact | Switch to previous tab |
| interact | Move tab to its own window |
| destructive | Close a tab |
App
Tool | Tier | Description |
| read | Get focused window/tab/session info |
| read | Get iTerm2 version |
| read | Get or set theme |
| interact | Bring iTerm2 to front |
Broadcast
Tool | Tier | Description |
| interact | Enable broadcasting to all sessions in current tab |
| interact | Disable broadcasting |
| interact | Create broadcast group with specific sessions |
Profile
Tool | Tier | Description |
| read | List all profiles |
| read | Show profile details |
| interact | Apply a profile to a session |
Batch
Tool | Tier | Description |
| interact | Execute 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
Available Tools
40 toolsapp_activateA
Activate iTerm2 (bring to front).
Inputs: no named parameters. Returns: result
app_get_focusA
Get information about the currently focused window, tab, and session.
Inputs: no named parameters. Returns: result
app_themeA
Get or set the iTerm2 theme.
Args: value: Theme to set. One of: light, dark, light-hc, dark-hc, automatic, minimal. Omit to get the current theme.
Inputs: value. Returns: result
app_versionB
Get the iTerm2 version.
Inputs: no named parameters. Returns: result
batchA
Execute a batch of iTerm2 operations sequentially within a single connection.
Each operation is a dict with an "op" field naming the operation, plus any parameters for that operation. A special "sleep" operation pauses between steps.
Args: operations: List of operation dicts. Each must have an "op" field. Available ops: session_send, session_run, session_read, session_split, session_close, session_focus, session_clear, session_set_name, session_list, session_get_variable, session_set_variable, session_restart, window_new, window_close, window_focus, tab_new, tab_close, tab_select, tab_next, tab_prev, app_activate, broadcast_on, broadcast_off, send_keystrokes, profile_apply, sleep.
Sleep op: {"op": "sleep", "seconds": 0.5} or {"op": "sleep", "ms": 500}
Example batch:
[
{"op": "session_run", "command": "echo hello"},
{"op": "sleep", "seconds": 1.0},
{"op": "session_read"},
{"op": "session_send", "text": "world"}
]
stop_on_error: If true, abort the batch on the first error.Returns: JSON array of results, one per operation, with index, op name, and result or error.
Inputs: operations (required), stop_on_error. Returns: result
broadcast_addC
Create a broadcast group with specific sessions.
Args: session_ids: List of session IDs to include in the broadcast group.
Inputs: session_ids (required). Returns: result
broadcast_offB
Disable input broadcasting.
Inputs: no named parameters. Returns: result
broadcast_onB
Enable input broadcasting to all sessions in the current tab.
Inputs: no named parameters. Returns: result
profile_applyB
Apply an iTerm2 profile to a session.
Args: name: The profile name to apply. session_id: Target session ID. Omit for the active session.
Inputs: name (required), session_id. Returns: result
profile_listA
List all iTerm2 profiles with their GUIDs and names.
Inputs: no named parameters. Returns: result
profile_showB
Show detailed information about an iTerm2 profile.
Args: name: The profile name.
Inputs: name (required). Returns: result
session_clearA
Clear the screen of an iTerm2 session (sends Ctrl+L).
Args: session_id: Target session ID. Omit for the active session.
Inputs: session_id. Returns: result
session_closeA
Close an iTerm2 session.
Args: session_id: Target session ID. Omit for the active session.
Inputs: session_id. Returns: result
session_focusB
Focus (activate) a specific iTerm2 session.
Args: session_id: The session ID to focus.
Inputs: session_id (required). Returns: result
session_get_variableB
Get the value of an iTerm2 session variable.
Args: variable: The variable name (e.g. "session.name", "session.path"). session_id: Target session ID. Omit for the active session.
Inputs: variable (required), session_id. Returns: result
session_listA
List all iTerm2 sessions with their IDs, names, titles, sizes, TTYs, and mcp_enabled status.
Shows all sessions regardless of mcp_enabled status so you can see which sessions need to be tagged. Only mcp_enabled sessions can be targeted by other tools.
To enable a session for MCP access, run in that session's terminal: it2 session set-var user.mcp_enabled true
Inputs: no named parameters. Returns: result
session_readA
Read the visible screen contents of an iTerm2 session.
Args: session_id: Target session ID. Omit for the active session. lines: Number of lines to return from the bottom. Omit for all visible lines.
Inputs: session_id, lines. Returns: result
session_restartB
Restart an iTerm2 session.
Args: session_id: Target session ID. Omit for the active session.
Inputs: session_id. Returns: result
session_runA
Execute a command in an iTerm2 session (sends text + Enter).
Args: command: The command string to execute. session_id: Target session ID. Omit for the active session. all_sessions: If true, run in every session.
Inputs: command (required), session_id, all_sessions. Returns: result
session_sendB
Send text to an iTerm2 session without pressing Enter.
Args: text: The text to send. session_id: Target session ID. Omit for the active session. all_sessions: If true, send to every session.
Inputs: text (required), session_id, all_sessions. Returns: result
session_set_nameB
Set the name of an iTerm2 session.
Args: name: The new session name. session_id: Target session ID. Omit for the active session.
Inputs: name (required), session_id. Returns: result
session_set_variableC
Set the value of an iTerm2 session variable.
Args: variable: The variable name. value: The value to set. session_id: Target session ID. Omit for the active session.
Inputs: variable (required), value (required), session_id. Returns: result
session_splitA
Split an iTerm2 session into a new pane.
Args: vertical: If true, split vertically (side by side). Default is horizontal (top/bottom). session_id: Target session ID. Omit for the active session. profile: Profile name to use for the new pane.
Inputs: vertical, session_id, profile. Returns: result
tab_closeB
Close an iTerm2 tab.
Args: tab_id: The tab ID to close. Omit for the current tab.
Inputs: tab_id. Returns: result
tab_listA
List all iTerm2 tabs with their IDs, window IDs, indices, session counts, and active state.
Args: window_id: Only list tabs from this window. Omit for all windows.
Inputs: window_id. Returns: result
tab_moveA
Move a tab to its own new window.
Args: tab_id: The tab ID to move. Omit for the current tab.
Inputs: tab_id. Returns: result
tab_newA
Create a new tab in an iTerm2 window.
Args: profile: Profile name for the new tab. window_id: Window ID to create the tab in. Omit for the current window. command: Command to run in the new tab.
Inputs: profile, window_id, command. Returns: result
tab_nextA
Switch to the next tab in the current window.
Inputs: no named parameters. Returns: result
tab_prevA
Switch to the previous tab in the current window.
Inputs: no named parameters. Returns: result
tab_selectB
Select a tab by its ID or numeric index.
Args: tab_id_or_index: Tab ID string, or a numeric index (0-based). window_id: Window ID for index-based selection. Omit for the current window.
Inputs: tab_id_or_index (required), window_id. Returns: result
window_arrange_listB
List all saved window arrangements.
Inputs: no named parameters. Returns: result
window_arrange_restoreB
Restore a saved window arrangement.
Args: name: Name of the arrangement to restore.
Inputs: name (required). Returns: result
window_arrange_saveB
Save the current window arrangement.
Args: name: Name for the saved arrangement.
Inputs: name (required). Returns: result
window_closeA
Close an iTerm2 window.
Args: window_id: The window ID to close. Omit for the current window.
Inputs: window_id. Returns: result
window_focusB
Focus (activate) a specific iTerm2 window.
Args: window_id: The window ID to focus.
Inputs: window_id (required). Returns: result
window_fullscreenA
Set fullscreen state for an iTerm2 window.
Args: state: One of "on", "off", or "toggle". window_id: The window ID. Omit for the current window.
Inputs: state (required), window_id. Returns: result
window_listA
List all iTerm2 windows with their IDs, tab counts, positions, sizes, and fullscreen state.
Inputs: no named parameters. Returns: result
window_moveA
Move an iTerm2 window to a specific screen position.
Args: x: X coordinate (pixels from left). y: Y coordinate (pixels from top). window_id: The window ID. Omit for the current window.
Inputs: x (required), y (required), window_id. Returns: result
window_newA
Create a new iTerm2 window.
Args: profile: Profile name to use. Omit for the default profile. command: Command to run in the new window.
Inputs: profile, command. Returns: result
window_resizeB
Resize an iTerm2 window.
Args: width: New width in pixels. height: New height in pixels. window_id: The window ID. Omit for the current window.
Inputs: width (required), height (required), window_id. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 40 tools
Every tool has a distinct purpose with clear boundaries between them. Tools are organized by resource (app, session, tab, window, profile, broadcast) and action (activate, get, set, list, close, etc.), with no overlap that would cause confusion. For example, session_run and session_send are clearly differentiated by whether they press Enter.
Tool names follow a highly consistent verb_noun pattern throughout, with clear prefixes for resource types (e.g., session_, tab_, window_). All names use snake_case uniformly, and verbs are appropriately chosen for each action (e.g., list, get, set, create, close).
With 40 tools, the count is borderline high for typical MCP servers, though it covers a comprehensive terminal emulator interface. The batch tool consolidates many operations, but the total still feels heavy. It's not extreme, but could be overwhelming for agents.
The tool set provides complete CRUD and lifecycle coverage for iTerm2's domain, including app management, session/tab/window operations, profile handling, broadcasting, and batch execution. No obvious gaps exist; agents can perform all expected terminal emulator tasks from creation to destruction and monitoring.
Maintenance
Related MCP Connectors
Remote MCP server exposing your Node Command fleet (files, shell, processes, browser) to AI hosts.
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
Nifty's MCP server — exposes tasks, projects, messages, and files as tools for AI agents.
MCP server for secureFlows: token-free URL builders and integration-linting tools for AI agents.
Related MCP Servers
- 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
- AlicenseNot gradedqualityDmaintenanceAn MCP server that gives AI assistants the ability to create, manage, and control terminal sessions through a safe, isolated tmux environment.1ISC
- AlicenseAqualityBmaintenanceAn 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.18163 PyPI1MIT
- FlicenseNot gradedqualityDmaintenanceAn MCP server that exposes iTerm2 tab control as native tools, designed for the conductor pattern where one Claude/Codex session drives sibling tabs.-