iTerm2 MCP Server
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 Server list all my terminal panes"
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 Server
An MCP (Model Context Protocol) server that allows AI assistants like Claude to read the contents of iTerm2 terminal panes. This enables AI assistants to see what's happening in your other terminal windows and tabs.
Features
List all panes: See all open iTerm2 windows, tabs, and panes with their working directories and running jobs
Read pane contents: Get the screen buffer text from any pane
Current pane detection: Automatically detects which pane the server is running in
Status checking: Verify that iTerm2 Python API is properly configured
Related MCP server: Enhanced iTerm MCP Server
Prerequisites
macOS with iTerm2 installed
Node.js >= 18.0.0
Python 3 with the
iterm2package:pip install iterm2iTerm2 Python API enabled:
Open iTerm2 > Settings (Cmd+,)
Go to General > Magic
Check Enable Python API
Restart iTerm2
Installation
Using npx (recommended)
npx iterm2-mcp-serverGlobal installation
npm install -g iterm2-mcp-server
iterm2-mcp-serverConfiguration
Claude Desktop
Add to your Claude Desktop configuration file (~/Library/Application Support/Claude/claude_desktop_config.json):
{
"mcpServers": {
"iterm2": {
"command": "npx",
"args": ["iterm2-mcp-server"]
}
}
}Claude Code
Add the MCP server using the CLI:
claude mcp add --scope user iterm2 -- npx github:sumchattering/iterm2-mcp-serverThis installs it globally so it's available in all your projects. You can verify it's working:
claude mcp listYou should see: iterm2: npx github:sumchattering/iterm2-mcp-server - ✓ Connected
Available Tools
iterm2_list_panes
List all iTerm2 windows, tabs, and panes with their shorthand IDs, names, working directories, and running jobs.
iterm2_read_pane
Read the screen buffer contents of a specific pane.
Parameters:
session_id(required): The pane ID using shorthand liket3p1(tab 3, pane 1) orw1t3p1
iterm2_send_text
Send text or commands to an iTerm2 pane as if typed by the user.
Parameters:
session_id(required): The pane ID (e.g.,t3p1)text(required): The text or command to sendnewline(optional, default: true): Whether to press Enter after the text
iterm2_send_control_character
Send control characters like Ctrl+C, Ctrl+D, Ctrl+Z, or Ctrl+L to an iTerm2 pane.
Parameters:
session_id(required): The pane ID (e.g.,t3p1)control(required):c(Ctrl+C),d(Ctrl+D),z(Ctrl+Z),l(Ctrl+L)
iterm2_split_pane
Split an iTerm2 pane horizontally or vertically, creating a new pane.
Parameters:
session_id(required): The pane ID to split (e.g.,t3p1)vertical(optional, default: false): If true, split vertically (side by side)
iterm2_current_pane
Get information about the current iTerm2 pane where Claude Code is running.
iterm2_status
Check if iTerm2 Python API is properly configured and ready to use.
iterm2_enable_api
Enable the iTerm2 Python API in preferences. Note: iTerm2 must be restarted after enabling.
Pane IDs
Panes are identified using shorthand IDs that match iTerm2's UI (1-based indexing):
t3p1- Tab 3, Pane 1 (assumes Window 1)t3p2- Tab 3, Pane 2w1t3p1- Window 1, Tab 3, Pane 1 (explicit window)w2t1p1- Window 2, Tab 1, Pane 1
Use iterm2_list_panes to see all available panes and their IDs.
Using with Claude Code
Once installed, Claude Code can see and interact with your terminal panes. Here are effective ways to use it:
Asking about panes
"What's in tab 3?" - Claude will read the contents of tab 3
"What's running in the pane next to you?" - Claude can identify adjacent panes
"Show me all my terminal tabs" - Lists all panes with their shorthand IDs
"What's the output of my server?" - Claude can find and read server output
Running commands in other panes
"Run
npm testin t3p1" - Sends command to specific pane"Stop the process in tab 4" - Sends Ctrl+C to interrupt
"Clear the terminal in t2p1" - Sends Ctrl+L
Working with multiple panes
"Split my terminal and run the dev server in the new pane"
"What errors are showing in my other terminals?"
"Compare the output in tab 2 and tab 3"
Tips for effective queries
Be specific about location: "tab 3" or "t3p1" is clearer than "the other terminal"
Reference the pane list: Ask Claude to list panes first if you're unsure of the layout
Use relative references: "the pane next to you" or "the tab on the left" work too
Troubleshooting
"Connection failed" error
Make sure iTerm2 is running
Verify Python API is enabled: iTerm2 > Settings > General > Magic > Enable Python API
Restart iTerm2 after enabling the API (Cmd+Q, then reopen)
"iterm2 module not installed"
Install the Python package:
pip install iterm2"Not running in an iTerm2 session"
The MCP server needs to be started from within an iTerm2 terminal for current pane detection to work.
How It Works
This MCP server uses the iTerm2 Python API to communicate with iTerm2 via a WebSocket connection. The server:
Receives tool calls from the AI assistant via MCP
Executes Python scripts that use the
iterm2libraryReturns formatted results back to the assistant
Development
# Clone the repository
git clone https://github.com/sumchattering/iterm2-mcp-server.git
cd iterm2-mcp-server
# Install dependencies
npm install
# Build
npm run build
# Run locally
npm startLicense
MIT License - see LICENSE for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Future Improvements
The following features are being considered for future releases. Feedback welcome!
Create tab/window:
iterm2_create_tabanditerm2_create_windowtoolsClose pane:
iterm2_close_panetool to close panes programmaticallyFocus pane:
iterm2_focus_paneto bring a specific pane to the foregroundWait for prompt:
iterm2_wait_for_promptto wait until a command finishes executingSet pane title: Ability to set custom titles for panes
Performance optimization: Persistent Python process instead of spawning per request
Available Tools
9 toolsiterm2_current_paneB
Get information about the current iTerm2 pane where the MCP server is running
Inputs: no named parameters.
iterm2_enable_apiA
Enable the iTerm2 Python API in preferences. Note: iTerm2 must be restarted after enabling.
Inputs: no named parameters.
iterm2_list_panesA
List all iTerm2 windows, tabs, and panes with their shorthand IDs (like t5p2), names, working directories, and running jobs. Shows which pane you are in. Use these shorthand IDs with other tools.
Inputs: no named parameters.
iterm2_read_paneC
Read the screen buffer contents of a specific iTerm2 pane. Returns the visible text in the terminal.
Inputs: session_id (required).
iterm2_send_control_characterA
Send control characters like Ctrl+C, Ctrl+D, Ctrl+Z, or Ctrl+L to an iTerm2 pane. Useful for interrupting processes or clearing the screen.
Inputs: control (required), session_id (required).
iterm2_send_textA
Send text/commands to an iTerm2 pane as if typed by the user. Can optionally press Enter after the text.
Inputs: text (required), session_id (required), newline.
iterm2_side_paneA
Get the side pane in the current tab. Returns the pane to the right of the current pane, or the left if current is rightmost. Useful for interacting with an adjacent terminal pane.
Inputs: no named parameters.
iterm2_split_paneA
Split an iTerm2 pane horizontally or vertically, creating a new pane. Returns the session ID of the newly created pane.
Inputs: session_id (required), vertical.
iterm2_statusA
Check if iTerm2 Python API is properly configured and ready to use
Inputs: no named parameters.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 9 tools
Each tool has a clearly distinct purpose: listing, reading, sending text, sending control characters, splitting panes, checking status, enabling API, getting current/side panes. While iterm2_side_pane and iterm2_current_pane both relate to pane location, their functions (getting adjacent pane vs. current pane info) are distinct enough not to cause confusion. No two tools appear to do the same thing.
All tools follow the iterm2_ prefix with verb_noun naming (send_text, send_control_character, split_pane, list_panes, read_pane, current_pane, side_pane, status, enable_api). There are minor deviations like iterm2_status and iterm2_enable_api where the noun is less explicit, but the pattern is largely consistent and predictable.
9 tools is well within the ideal 3-15 range for an MCP server focused on terminal pane control. Each tool serves a clear need for interacting with iTerm2 panes: discovery, inspection, and manipulation, without excessive bloat or redundancy.
The tool surface covers the core iTerm2 interaction workflows: setup (enable_api, status), discovery (list_panes, current_pane, side_pane), inspection (read_pane), and control (send_text, send_control_character, split_pane). Minor gaps include the absence of tools to close/resize/select panes or navigate between tabs/windows, but the core lifecycle of viewing, writing to, and creating panes is well covered.
Maintenance
Related MCP Connectors
Use your Mac, Windows or Linux computer from ChatGPT, Claude or Codex: files, commands, documents.
- DNS-DATA RemoteDeprecatedcom.dns-data
Connect AI assistants to authorized Windows and macOS devices for files, commands, and management.
Connect ChatGPT, Claude, Cursor or VS Code to your Windows PC: files, terminal, browser, apps.
Operate Linux, macOS and Windows from your LLM. Every action runs through an auditable allowlist.
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables AI assistants to manage local tmux sessions, including creating and controlling sessions, windows, and panes, sending commands, and capturing terminal output.167 npmDo What The F*ck You Want To Public
- AlicenseNot gradedqualityDmaintenanceProvides advanced iTerm2 terminal automation using Python API integration, enabling AI assistants to create and manage terminal sessions, split panes, execute commands, broadcast to multiple panes, and monitor terminal state in real-time.10 npm5MIT
- AlicenseAqualityDmaintenanceAllows AI assistants to create, manage, and interact with tmux sessions, windows, and panes programmatically.1928 PyPIMIT
- AlicenseNot gradedqualityDmaintenanceControls iTerm2 terminal sessions with multi-pane support, allowing parallel command execution, session management, and role-based access for AI orchestration.4MIT