MCP ExplorerExplorer

iTerm

@ferrislucason 12 days ago
347 MIT
FreeCommunity
System Tools
#iTerm#server#automation
Integration with iTerm2 terminal emulator for macOS, enabling LLMs to execute and monitor terminal commands.

Overview

What is iTerm

iterm-mcp is a Model Context Protocol server that enables interaction with iTerm sessions through a language model. It allows models to execute and manage terminal commands while providing real-time feedback.

Use cases

iterm-mcp can be used for interacting with terminal-based applications, automating command-line tasks, querying terminal output, and executing multi-step processes where real-time monitoring and control is required.

How to use

Users need to configure the iterm-mcp server in their Claude Desktop setup by adding a specific JSON configuration. After that, it can be run using npx, allowing the model to take over the terminal session efficiently.

Key features

Key features of iterm-mcp include efficient token utilization for output inspection, natural integration with iTerm for user interaction, full terminal control including REPL support, and minimal dependency requirements for easy installation.

Where to use

iterm-mcp is particularly useful in environments where command-line interfaces are frequently used, such as software development, system administration, and automating scripts in macOS systems with iTerm2.

Content

iterm-mcp

A Model Context Protocol server that provides access to your iTerm session.

Main Image

Features

Efficient Token Use: iterm-mcp gives the model the ability to inspect only the output that the model is interested in. The model typically only wants to see the last few lines of output even for long running commands.

Natural Integration: You share iTerm with the model. You can ask questions about what’s on the screen, or delegate a task to the model and watch as it performs each step.

Full Terminal Control and REPL support: The model can start and interact with REPL’s as well as send control characters like ctrl-c, ctrl-z, etc.

Easy on the Dependencies: iterm-mcp is built with minimal dependencies and is runnable via npx. It’s designed to be easy to add to Claude Desktop and other MCP clients. It should just work.

Safety Considerations

  • The user is responsible for using the tool safely.
  • No built-in restrictions: iterm-mcp makes no attempt to evaluate the safety of commands that are executed.
  • Models can behave in unexpected ways. The user is expected to monitor activity and abort when appropriate.
  • For multi-step tasks, you may need to interrupt the model if it goes off track. Start with smaller, focused tasks until you’re familiar with how the model behaves.

Tools

  • write_to_terminal - Writes to the active iTerm terminal, often used to run a command. Returns the number of lines of output produced by the command.
  • read_terminal_output - Reads the requested number of lines from the active iTerm terminal.
  • send_control_character - Sends a control character to the active iTerm terminal.

Requirements

  • iTerm2 must be running
  • Node version 18 or greater

Installation

To use with Claude Desktop, add the server config:

On macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
On Windows: %APPDATA%/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "iterm-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "iterm-mcp"
      ]
    }
  }
}

Installing via Smithery

To install iTerm for Claude Desktop automatically via Smithery:

npx -y @smithery/cli install iterm-mcp --client claude

smithery badge

Development

Install dependencies:

yarn install

Build the server:

yarn run build

For development with auto-rebuild:

yarn run watch

Debugging

Since MCP servers communicate over stdio, debugging can be challenging. We recommend using the MCP Inspector, which is available as a package script:

yarn run inspector
yarn debug <command>

The Inspector will provide a URL to access debugging tools in your browser.

Tools

write_to_terminal
Writes text to the active iTerm terminal - often used to run a command in the terminal
read_terminal_output
Reads the output from the active iTerm terminal
send_control_character
Sends a control character to the active iTerm terminal (e.g., Control-C, or special sequences like ']' for telnet escape)

Comments