iTerm2 MCP Server for Multiple Sessions
Manage multiple iTerm2 sessions with an MCP server for seamless terminal integration and centralized session control.
npx -y @rishabkoul/iTerm-MCP-ServerOverview
This MCP (Model Context Protocol) server lets you manage multiple iTerm2 sessions from a single, external process. It implements a centralized control layer that can create, route input to, and monitor several iTerm2 terminal sessions at once. The server is intended for workflows that need coordinated terminal control: demos, classroom/live-coding setups, integration tests, orchestration scripts, and automation hooks.
Running an MCP server alongside iTerm2 lets external tools send commands or snippets into one or more terminal sessions, query session state, and handle session lifecycle events. Instead of manually switching windows or copying text, you can integrate your tooling (CI, web apps, bots) with iTerm2 using a consistent API so multiple interactive shells can be driven programmatically and reproducibly.
Features
- Centralized control of multiple iTerm2 sessions
- Create and destroy sessions programmatically
- Send commands or text to individual sessions or broadcast to many
- Query session metadata (id, title, working directory, PID)
- Simple JSON-based API (HTTP/WebSocket/CLI adapters possible)
- Optional authentication and origin restrictions
- Logging and session activity history for auditing and replay
- Lightweight: designed to run alongside existing iTerm2 setups
Installation / Configuration
The repository contains a small server you can run locally or inside a container. Typical installation steps:
- Clone the repository:
- Create a Python virtual environment and install dependencies:
- Start the server (example command — actual entrypoint may vary):
# Example: run server with default config
Example YAML configuration (config.yml):
# config.yml
socket_path: "/tmp/iterm-mcp.sock" # path used by iTerm2 or local adapter
http_port: 8765 # optional HTTP API port
log_level: "info"
allowed_origins:
- "http://localhost:3000"
auth_token: "changeme" # optional API token
Run with explicit config:
Docker example:
Note: The exact file names and flags in the repo may differ. Check the repository root for the main script and README for the authoritative command names.
Available Tools / Resources
The server typically exposes a small set of API endpoints or message types for controlling sessions. Example endpoints and payloads:
List sessions
- GET /sessions
- Response:
Create a session
- POST /sessions
- Request:
- Response:
Send input to a session
- POST /sessions/{id}/send
- Request:
Broadcast to multiple sessions
- POST /broadcast
- Request:
WebSocket endpoint (optional) for real-time session events and output streaming:
- ws://localhost:8765/mcp
- Messages are JSON objects containing event, session id and payload.
These examples show typical patterns; check the repository for exact API and authentication mechanisms.
Use Cases
Live demos and presentations
- Launch one session per demo target, then use the server to step through commands across windows in a reproducible order. Example: broadcast a command to set up environments across multiple panes at once.
Teaching and onboarding
- Instructors can prepare multiple pre-configured shells and push code snippets or exercises to students’ terminals (or to multiple panes) so everyone follows the same sequence.
Cross-environment test orchestration