Skip to main content
Glama
claude-sessions-mcp

claude-sessions-mcp

by LukeLamb

Claude tmux 会话

让 Linux 上的 Claude Desktop 能够启动、监控和控制 tmux 会话中长时间运行的任务。专为机器学习训练、数据流水线以及任何你希望在单次对话结束后依然保持运行的任务而设计。

Claude 可以启动一个后台训练任务,一小时后通过捕获其窗格的最后 N 行来检查进度,发送按键(包括 Ctrl+C),并在完成后终止会话。你可以从任何真实终端执行 tmux attach -t <name> 来实时观看同一个会话——Claude 和人类可以同时观察。

要求

  • Linux 且已安装 tmux:

    sudo apt install tmux
  • 适用于默认的每用户 tmux 服务器(无需共享服务器设置)。

Related MCP server: Tmux MCP Server

安装 (Claude Desktop)

  1. 从 Releases 页面下载最新的 Sessions.mcpb。

  2. 在 Claude Desktop 中:Settings → Extensions → Extension Developer → Install Extension → 选择 .mcpb 文件。

  3. 启用该扩展。

工具

工具

注解

功能

list_sessions

只读

列出所有 tmux 会话,包含名称、窗口、创建/活动时间戳、附加标志

has_session

只读

精确匹配检查会话名称

list_windows

只读

会话内的窗口(索引、名称、活动状态、窗格数量)

capture_pane

只读

会话活动窗格的最后 N 行(默认 100,最大 10000)

new_session

破坏性

启动一个后台会话;可选择运行初始 shell 命令

send_keys

破坏性

向活动窗格发送按键组合或文本(默认自动追加 Enter)

kill_session

破坏性

终止会话(向内部所有进程发送 SIGHUP)

示例工作流

启动训练任务:

“启动训练任务 b8-c1:激活我的 rdna4-train 虚拟环境并运行 train.py。”

new_session name=b8-c1 command="source ~/.venvs/rdna4-train/bin/activate && python /media/luke/Storage\ Device\ 1/NeuroForge/train.py b8-c1"

稍后检查:

“训练 b8-c1 还在运行吗?给我看最后 50 行。”

capture_pane name=b8-c1 lines=50

中断卡死的任务:

“训练卡住了——发送 Ctrl+C。”

send_keys name=b8-c1 keys="C-c" enter=false

结束任务:

“终止会话。”

kill_session name=b8-c1

按键符号

send_keys 接受字面文本(作为按键发送)或 tmux 按键名称。常见按键:

按键

效果

C-c

Ctrl+C (中断)

C-d

Ctrl+D (EOF / 登出)

Escape

Escape 键

Up, Down, Left, Right

方向键

Enter

回车键(当 enter 为 true 时也会自动追加)

Space

空格键

发送原始组合键时请使用 enter: false,以免额外触发回车。

隐私政策

此扩展完全在你的本地机器上运行,仅调用 tmux 二进制文件。没有任何数据离开你的机器。没有网络 I/O。没有套接字。除了 tmux 自身的每用户服务器套接字(默认 /tmp/tmux-$UID/default)外,不会写入任何文件。

Claude 可见的信息包括会话名称、窗格内容(你或你的程序打印的文本)以及会话元数据(创建/活动时间戳、窗口/窗格数量)。send_keys 和 kill_session 可能会影响在受管会话中运行的任何进程,因此请给予它与你信任用户在终端输入时相同的信任级别。

故障排除

“tmux is not installed” — 运行 sudo apt install tmux。

“can't find pane” 错误 — 通常意味着命名会话在操作过程中被终止了。请先调用 has_session,或使用 list_sessions 查看当前实际运行的内容。

会话名称限制 — 名称不能包含 .、:、| 或空格。. 和 : 是 tmux 目标分隔符;| 是此服务器的字段分隔符;空格原则上被拒绝。

会话在初始命令后无法存活 — 根据设计,new_session 总是启动一个 shell;command 参数作为按键发送到该 shell 中。这就是为什么命令结束后会话依然保持存活的原因。如果你直接将 command 传递给 tmux new-session,它会在命令结束时退出。

开发

单个约 300 行的 Node.js 脚本,零 npm 依赖。重新构建 .mcpb:

cd bundle-source
zip -j ../Sessions.mcpb manifest.json package.json server.js README.md LICENSE icon.png glama.json

许可证

MIT。参见 LICENSE。

相关项目

  • claude-terminal-mcp — shell、文件系统和后台任务(适用于 tmux 显得过于笨重的短时命令)。

  • claude-linux-mcp — X11 桌面控制。

  • claude-rocm-mcp — AMD GPU 监控;与此工具配合使用可在训练期间检查 GPU 健康状况。

Available Tools

7 tools
capture_paneA
Read-only

Capture the last N lines visible in the session's active pane (default 100, max 10000). Returns the joined text. The primary primitive for "is my training still running? show me the latest output".

Inputs: name (required), lines.

has_sessionA
Read-only

Check whether a named tmux session exists. Cheap precondition for capture_pane, send_keys, or kill_session.

Inputs: name (required).

kill_sessionA
Destructive

Terminate a named tmux session. Any processes running inside are sent SIGHUP by tmux. Errors if the session does not exist.

Inputs: name (required).

list_sessionsA
Read-only

List all tmux sessions on the current user's tmux server. Returns name, window count, created/activity timestamps (ISO 8601), and attached status. Returns an empty list when no tmux server is running.

Inputs: no named parameters.

list_windowsA
Read-only

List windows within a named session (index, name, active flag, pane count).

Inputs: name (required).

new_sessionA
Destructive

Start a new detached tmux session. Always starts a shell (so the session survives after the initial command finishes). If command is given, it is sent to the shell as keystrokes + Enter, so aliases, venvs, and functions work as expected. Errors if the session name already exists.

Inputs: name (required), command, cwd.

send_keysA
Destructive

Send key combos or text to the session's active pane. Use for interrupts (C-c), end-of-input (C-d), or typing a command. Text is sent literally. Enter is appended by default; set enter=false for raw key combos.

Inputs: name (required), keys (required), enter.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.3/5.0

    Scored across 7 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose: creation, output capture, listing sessions/windows, existence check, input sending, and termination. No two tools overlap in functionality, making misselection unlikely.

    Naming Consistency5/5

    All tools follow a consistent verb_noun pattern in lowercase snake_case (e.g., new_session, capture_pane, list_sessions). The naming is uniform and predictable, with no stylistic deviations.

    Tool Count5/5

    7 tools is a well-scoped set for tmux session management, covering the essential lifecycle operations without redundancy or bloat. Each tool serves a clear purpose.

    Completeness4/5

    The surface covers the core lifecycle (create, read, check, update via send_keys, delete) adequately. Minor gaps exist, such as no rename or attach/detach operations, but these are not critical for typical usage and can be worked around.

    Maintenance

    ActivityStale
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables comprehensive tmux session management through MCP, allowing users to list sessions, send commands, set up automated messaging timers, and control tmux processes directly from Claude Desktop. Provides both real-time session monitoring and automated workflow features like exit/continue cycles.
      2
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      Enables AI assistants to manage local tmux sessions, including creating and controlling sessions, windows, and panes, sending commands, and capturing terminal output.
      16
      10 npm
      Do What The F*ck You Want To Public
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables Claude to execute commands and manage directory-aware panes within tmux sessions for a shared terminal experience. It features smart output capture, interactive prompt detection, and background task management.
      2
      MIT