Skip to main content
Glama
Menager MCP Server

Menager MCP Server

Menager MCP Server

MIT License TypeScript

Menager 终端编排

menager 是一个基于 TypeScript 的 Model Context Protocol (MCP) 服务器,专为会话间终端编排而设计。它使 AI 代理会话(或人工操作员)能够充当主控制平面,通过标准 POSIX 伪终端(pty)创建、监控、驱动并挂接子终端封装器(CLI 工具、辅助 AI 代理、交互式 Shell 或多语言运行时)。

目录

Related MCP server: pty-mcp

功能特性

  • 多语言封装器多路复用: 通过标准 POSIX 伪终端驱动以任何语言编写的交互式进程。

  • 模拟人工键入: 将文本、控制序列(SIGINT、EOF、Ctrl+C)和原始按键无缝注入子进程 stdin。

  • 可预测的事件拦截: 提供带超时保证的非阻塞正则表达式钩子,并支持可选的即时自动响应。

  • 内存受限的可观测性: 为每个会话维护专用环形缓冲区(默认 5,000 行),并实时剥离 ANSI 转义序列,使 LLM 上下文消费更省 token。

  • 严格异步与资源纪律: 事件处理保持纯事件驱动,使用 Node.js 事件发射器和 Promise,并严格执行缓冲区边界以防止内存泄漏。

安装

手动安装

# Clone the repository
git clone <your-repo-url>
cd menager

# Install dependencies (requires build-essential/g++ for node-pty native bindings)
npm install

# Build the project
npm run build

使用说明

启动服务器

服务器通过 Stdio 传输方式运行,旨在由 MCP 客户端直接执行。

# Start the server (standard mode)
npm start

# Or run the built file directly
node build/index.js

可用工具

session_spawn

创建新的子 PTY 会话。

  • command (string): 目标二进制文件或可执行程序(例如 bash、python3)。必填。

  • args (string[]): 命令行参数。

  • cwd (string): 工作目录路径。

  • env (object): 额外的环境变量。

  • maxBufferLines (number): 内存缓冲区的滚动行数上限(默认 5000)。

  • terminalType (string): 终端仿真类型("dumb" 或 "xterm-256color",默认 "xterm-256color")。

  • name (string): 会话的可选逻辑名称/标签。

  • cols (number): 终端列数(默认 80)。

  • rows (number): 终端行数(默认 24)。

session_wait

阻塞并等待会话正常退出,返回其最终退出码。

  • sessionId (string): 目标会话 ID。必填。

  • timeoutMs (number): 可选的超时时间(毫秒)。

session_write

将按键、命令或转义序列注入会话的标准输入。

  • sessionId (string): 目标会话 ID。必填。

  • payload (string): 字符串或控制字符序列。必填。

  • pressEnter (boolean): 向载荷追加 \n(默认 false - v4 中的破坏性变更)。

  • pressKey (string): 特殊按键注入(Ctrl+C、Ctrl+D、Enter、Tab、Escape、ArrowUp、ArrowDown)。

session_read

读取目标会话的缓冲输出。

  • sessionId (string): 目标会话 ID。必填。

  • tailLines (number): 要检索的末尾行数(默认 100)。

  • stripAnsi (boolean): 返回不含 ANSI 码的净化文本(默认 true)。

  • clearBuffer (boolean): 读取后刷新内部缓冲区(默认 false)。

  • offsetLines (number): 从该绝对索引偏移处开始读取行(取代 tailLines)。

  • grepPattern (string): 通过正则表达式字符串匹配预过滤缓冲区行。

session_hook

在会话流上等待特定的正则表达式模式,并支持可选的自动回复。

  • sessionId (string): 目标会话 ID。必填。

  • pattern (string): 要观察的正则表达式字符串。必填。

  • timeoutMs (number): 超时前的毫秒数(默认 30000)。

  • autoResponse (string): 匹配时立即写入的可选字符串。

  • triggerPayload (string): 在钩子注册 之后 写入载荷(防止并发死锁)。

session_resize

调整目标 PTY 终端的尺寸。

  • sessionId (string): 目标会话 ID。必填。

  • cols (number): 终端列数。必填。

  • rows (number): 终端行数。必填。

session_signal

向目标会话发送 POSIX 信号(并递归终止进程树)。

  • sessionId (string): 目标会话 ID。必填。

  • signal (string): 要发送的信号(SIGINT、SIGTERM、SIGKILL)。必填。

session_close

强制终止会话的进程树并立即删除内存缓冲区。

  • sessionId (string): 目标会话 ID。必填。

session_prune

强制删除会话以释放内存。

  • status (string): 仅删除具有该状态的会话("running" 或 "exited")。默认为 "exited"。

session_info

返回单个会话的实时元数据和指标。

  • sessionId (string): 目标会话 ID。必填。

session_list

列出服务器管理的所有活动会话和已结束会话。无需参数。

与 AI 助手集成配置

在 Roo Code 或 Cline 中配置

  1. 打开 MCP 设置文件(通常是 cline_mcp_settings.json 或 config.json)。

  2. 为标准 stdio 模式添加以下配置:

{
  "mcpServers": {
    "menager-mcp": {
      "command": "node",
      "args": ["/path/to/menager/build/index.js"],
      "env": {}
    }
  }
}

在 Claude Desktop 中配置

  1. 打开 claude_desktop_config.json。

  2. 添加以下配置:

{
  "mcpServers": {
    "menager-mcp": {
      "command": "node",
      "args": ["/path/to/menager/build/index.js"],
      "env": {}
    }
  }
}

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables AI agents to interact with terminal environments through multiple concurrent PTY sessions. Supports cross-platform terminal operations including command execution, session management, and real-time communication.
    15 npm
    3
    MIT
  • F
    license
    A
    quality
    D
    maintenance
    Enables AI agents to start and manage pseudo-terminal sessions, run shell commands and interact with REPLs programmatically.
    7
    -
  • 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 npm
    1
    MIT
  • A
    license
    Not graded
    quality
    B
    maintenance
    Enables AI agents to drive real interactive terminal sessions—PTYs, TUIs, REPLs, SSH, even another agent's CLI—with a live web view where humans can watch and type in.
    19 npm
    2
    MIT