Skip to main content
Glama
Ar9av

termmirror

by Ar9av

termmirror

一个 MCP 服务器,让 AI 智能体获得真正的交互式终端会话——同时提供一个实时网页视图,人类可以观看这些会话并在其中输入。

大多数智能体工具只能运行会自动退出的命令。任何会提示输入、重绘画面或等待按键的程序都无法企及:安装程序、带有密码质询的 sshpdbvim、软件包管理器的配置界面——以及另一个智能体的 CLI。termmirror 保持真正的 PTY 会话开启,让智能体可以像人一样操作它们,一次一个按键,同时人类可以在旁观看,并在需要时介入。

一个智能体在浏览器中实时驱动另一个智能体的 CLI

一个智能体通过 termmirror 驱动 Claude Code 会话——它接受了信任提示,问了一个问题,并从屏幕上读到了答案。浏览器视图是实时的,在其中的输入会直接进入同一个终端。

一个逐键驱动的 vim 会话

同样的工具下的全屏 TUI:智能体打开了 vim,移动到文件末尾,进入插入模式,并输入了一行。

功能

  • 真正的 PTY 会话。node-pty 提供支持,并带有一个持有屏幕状态的无头终端模拟器。不依赖 tmux 或其他外部依赖。

  • 为 TUI 而生。 备用屏幕检测、控制键和导航键的按键编码,以及可将软换行还原的回滚功能。

  • 可靠的等待。 wait 会在程序作出响应并且稳定下来后返回,因此你读到的屏幕反映的是你的输入,而不是输入之前的状态。

  • 实时网页视图。 任何会话在运行过程中都可以在浏览器中观看。在页面中键入会直接进入 PTY,因此人类可以接管并交还控制权。

  • 智能体到智能体。 其设计使得一个智能体可以通过多轮对话驱动另一个智能体的 CLI。

Related MCP server: ddx-term-mcp

系统要求

  • Node.js 20 或更高版本

  • macOS 或 Linux

安装

git clone https://github.com/Ar9av/termmirror.git
cd termmirror
npm install && npm run build

向 Claude Code 注册服务器:

claude mcp add termmirror -- node /absolute/path/to/termmirror/dist/src/index.js

任何 MCP 客户端都可以使用;服务器通过 stdio 通信。

用法

三个工具,按以下顺序使用:

send_input  →  wait  →  read_screen

read_screen 返回当前屏幕的样子——一张屏幕截图,而不是所有打印内容的日志。wait 才是让它值得一读的原因:它会阻塞,直到程序作出响应并安静下来,因此你看到的是按键之后的状态。

工具

工具

描述

create_session

启动一个会话(默认为 $SHELL,也可以是任何命令),并返回其 id 及一个用于观看的 URL。

send_input

向会话输入文本,可选择按 Enter 提交。

send_keys

发送 ctrl+cescapetab、方向键、f1f12alt+X 等按键。

read_screen

以纯文本形式返回可见屏幕;scrollback 可获取历史记录。

wait

等待会话响应并稳定(idle),或等待文本出现(pattern)。

list_sessions

列出所有会话(存活或已退出)及其观看 URL。

resize

更改终端尺寸。

kill_session

终止会话。

等待

idle 是默认选项,也是大多数情况下的正确选择。交互式程序在运行时会持续重绘,当轮到您时便静默,因此静默是一个可靠的完成信号——包括对于那些没有可匹配提示的旋转指示器和 TUI 也是如此。对于较慢的操作,请增大 timeout

no_output 结果表示自您输入以来没有任何返回:程序要么正在忙碌而保持静默,要么输入从未被记录。

当预期文本已知时,请使用 pattern。它会匹配整个屏幕,包括您自己回显的输入,因此请等待程序打印的内容,而不是您刚刚输入的标记。

观看会话

第一个会话会在 7878 端口启动一个本地 Web 服务器。打开 create_session 返回的 URL 即可实时观看该会话。在页面中键入会直接写入 PTY,这样人类就可以输入密码或回答不应由智能体处理的提示,然后交还控制权——无需交接协议,只是从另一端使用同一个终端。

变量

作用

TERMINAL_UI_PORT

网页视图的端口(默认 78780 会选择空闲端口)。

TERMINAL_NO_UI

设置为 1 可完全禁用网页视图。

示例

node examples/drive-claude.mjs "what is 2+2? reply with just the number"

一个智能体启动 claude,接受其信任提示,问了一个问题,并从屏幕上读出了答案——这些工具与 MCP 接口暴露的工具相同,只是逐项写出。

开发

npm run build    # compile TypeScript to dist/
npm test         # build, then run the test suite

该测试套件涵盖了服务器其余部分所依赖的等待语义、按键编码、回滚、网页视图的实时流和接管输入,以及通过真实 MCP 协议进行的端到端运行。

关于名称的说明

这个包名为 termmirror,有两个 m。alias/termirror/ 是一个依赖它的存根包,因此单个 m 的拼写也能解析到正确的位置。

许可证

MIT

A
license - permissive license
Not graded
quality - not tested
B
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • A
    license
    Not graded
    quality
    C
    maintenance
    Provides AI agents with fully interactive terminal sessions, including TUI support, keyboard control, and screen capture across Windows, Linux, and Mac.
    MIT
  • A
    license
    Not graded
    quality
    B
    maintenance
    Enables AI agents to execute commands in a shared tmux session that is simultaneously visible to a human via a web-based terminal UI.
    1
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    Enables AI agents to interact with interactive CLI processes via a real PTY, allowing them to send keystrokes, read screen output, and handle interactive prompts.
    6
    1
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables AI agents to spawn and interact with real terminal sessions, capturing screenshots of rendered TUI output and sharing live sessions for debugging.
    3
    1
    MIT

View all related MCP servers

Related MCP Connectors

  • Operate Linux, macOS and Windows from your LLM. Every action runs through an auditable allowlist.

  • Let AI operate servers without SSH. Choose actions, approve risky changes, and audit every step.

  • Turns any agent into a full agentic application — branded, interactive screens generated at runtime.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Ar9av/termmirror'

If you have feedback or need assistance with the MCP directory API, please join our Discord server