i

iTerm自动化助手

@ferrislucas/iterm-mcp
0 Stars 400 次浏览 ferrislucas 更新于 2026-08-23

此MCP服务器通过与Claude Desktop集成,使用户能够在当前的iTerm2会话中执行shell命令,通过模型上下文协议实现无缝的命令执行。

MCP 服务配置

复制以下 JSON 到 OPClaw 或其他 MCP 客户端的配置文件中即可使用

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

可用工具 (3 个)

该服务在 MCP 协议中暴露的工具,AI 可按需调用

write_to_terminal 1 个参数 需填 1 项

Writes text to the active iTerm terminal - often used to run a command in the terminal

必填参数:command

read_terminal_output 1 个参数 需填 1 项

Reads the output from the active iTerm terminal

必填参数:linesOfOutput

send_control_character 1 个参数 需填 1 项

Sends a control character to the active iTerm terminal (e.g., Control-C)

必填参数:letter

服务介绍

iterm-mcp

一个提供访问你的iTerm会话的Model Context Protocol服务器。

主图

特性

高效的令牌使用: iterm-mcp赋予模型只检查其感兴趣的输出的能力。即使对于长时间运行的命令,模型通常也只希望看到最后几行输出。

自然集成: 你可以与模型共享iTerm。你可以询问屏幕上显示的内容,或将任务委托给模型,并观察它执行每一步的过程。

完整的终端控制和REPL支持: 模型可以启动并与REPL交互,以及发送如ctrl-c、ctrl-z等控制字符。

依赖少: iterm-mcp构建时依赖项极少,并且可以通过npx运行。设计上易于添加到Claude Desktop及其他MCP客户端中。它应该可以直接工作。

安全注意事项

  • 用户负责安全地使用该工具。
  • 无内置限制:iterm-mcp不会尝试评估所执行命令的安全性。
  • 模型可能表现出意外行为。用户应监控活动并在适当时候中断。
  • 对于多步骤任务,如果模型偏离轨道,你可能需要中断模型。从较小、集中的任务开始,直到你熟悉模型的行为方式为止。

工具

  • write_to_terminal - 向活动的iTerm终端写入内容,常用于运行命令。返回由命令产生的输出行数。
  • read_terminal_output - 从活动的iTerm终端读取指定数量的行。
  • send_control_character - 向活动的iTerm终端发送控制字符。

要求

  • 必须正在运行iTerm2
  • Node版本18或更高

安装

要与Claude Desktop一起使用,请添加服务器配置:

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

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

通过Smithery安装

要通过Smithery自动为Claude Desktop安装iTerm:

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

smithery徽章

开发

安装依赖项:

yarn install

构建服务器:

yarn run build

带有自动重建功能的开发:

yarn run watch

调试

由于MCP服务器通过stdio进行通信,调试可能会比较困难。我们推荐使用MCP Inspector,这是一个包脚本可用的工具:

yarn run inspector
yarn debug <command>

Inspector将提供一个URL,在浏览器中访问调试工具。

相关 MCP 服务