tmux-shell

tmux-shell

Enables AI agents to read tmux pane content on-demand, providing context-aware assistance during interactive terminal sessions.

Category
访问服务器

README

Tmux MCP Shell Tool

An MCP (Model Context Protocol) server that enables AI agents to read tmux pane content on-demand, providing context-aware assistance during interactive terminal sessions.

Problem

AI agents can't see what's happening in your terminal during interactive commands like git rebase -i, vim, or when resolving merge conflicts. This forces you to manually describe your terminal state, breaking your workflow.

Solution

This MCP server lets AI agents read your tmux pane content when you ask for help, enabling them to see exactly what you're seeing and provide context-aware guidance.

Key Constraint: LLM input cannot be streamed, so this tool uses a reactive reading approach rather than passive real-time monitoring. The agent only reads your terminal when you explicitly request assistance.

Features

  • On-demand pane reading: AI reads tmux pane content only when you ask
  • Scrollback support: Access terminal history, not just visible content
  • Multi-pane/session support: Target specific tmux sessions, windows, and panes
  • Privacy-focused: No background monitoring, explicit user control
  • Rich metadata: Cursor position, pane dimensions, active command

Installation

npm install -g tmux-mcp-shell-tool

Or use directly with npx:

npx tmux-mcp-shell-tool

Requirements

  • tmux version 2.0 or later
  • Node.js version 18 or later
  • Active tmux session

Quick Start

1. Configure MCP Client

Add to your MCP settings (e.g., Claude Desktop):

{
  "mcpServers": {
    "tmux-shell": {
      "command": "npx",
      "args": ["tmux-mcp-shell-tool"]
    }
  }
}

2. Start Tmux

tmux new-session -s work

3. Use with AI Agent

You: *runs git rebase -i and encounters conflict*
You: "I'm stuck in a rebase with conflicts. Can you help?"
Agent: *uses read_tmux_pane tool*
Agent: "I can see you have a conflict in src/main.rs between lines 45-67.
       The conflict shows your changes vs. the upstream changes..."

MCP Tools

read_tmux_pane

Reads content from a tmux pane.

Parameters:

  • target (string, optional): Tmux target in format session:window.pane (default: current pane)
  • start_line (number, optional): Start line (negative for scrollback, default: visible area)
  • end_line (number, optional): End line (default: end of visible area)
  • include_trailing_spaces (boolean, optional): Preserve trailing spaces (default: false)

Example:

// Read visible area of current pane
{
  "target": null
}

// Read last 100 lines of scrollback
{
  "target": "mysession:1.0",
  "start_line": -100,
  "end_line": -1
}

list_tmux_sessions

Lists all tmux sessions, windows, and panes.

Parameters: None

Returns:

{
  "sessions": [
    {
      "name": "work",
      "windows": [
        {
          "index": 1,
          "name": "editor",
          "panes": [
            {
              "index": 0,
              "command": "vim"
            }
          ]
        }
      ]
    }
  ]
}

Use Cases

Git Rebase Conflicts

User: "I'm in the middle of a rebase and git is showing conflicts"
Agent: *reads pane* "You have conflicts in 2 files: src/app.js and
       config.yaml. Let's resolve them one at a time..."

Vim Navigation

User: "I'm stuck in vim and can't exit"
Agent: *reads pane* "You're in NORMAL mode. Type :q and press Enter to quit,
       or :wq to save and quit"

Debugging Session

User: "The debugger is showing something weird"
Agent: *reads pane* "Looking at your debugger output, the variable 'user'
       is undefined at line 42. This suggests..."

Privacy & Security

What This Tool Does

  • Reads tmux pane content ONLY when AI agent invokes the tool
  • Requires user to actively request help (agent can't read unprompted)
  • Only accesses tmux panes you specify

What This Tool Does NOT Do

  • ❌ Monitor keystrokes in real-time
  • ❌ Run background processes watching your terminal
  • ❌ Automatically filter sensitive data (passwords, API keys)
  • ❌ Store or log terminal content

Best Practices

  1. Be mindful of sensitive data: Avoid asking for help when passwords/keys are visible
  2. Use specific pane targets: Specify exact panes rather than reading all sessions
  3. Review tool invocations: Check what your AI agent is reading in the MCP logs
  4. Clear sensitive content: Clear your terminal or switch panes before requesting help

Architecture

┌─────────────────┐
│   AI Agent      │  User: "I'm stuck in vim"
│  (Claude, etc)  │  Agent: *invokes read_tmux_pane*
└────────┬────────┘
         │ MCP Protocol
         │
┌────────▼────────┐
│  MCP Server     │  Executes: tmux capture-pane -p
│  (This Tool)    │  Returns: Terminal content
└────────┬────────┘
         │
┌────────▼────────┐
│   Tmux Pane     │  Current content: "-- INSERT --"
│  (User Shell)   │
└─────────────────┘

Concept Document

For detailed architectural decisions and technical rationale, see CONCEPT.md.

Development

# Clone repository
git clone https://github.com/ketema/tmux-mcp-shell-tool.git
cd tmux-mcp-shell-tool

# Install dependencies
npm install

# Build
npm run build

# Run in development
npm run dev

# Test
npm test

Contributing

Contributions welcome! Please read CONCEPT.md to understand the design constraints.

License

MIT

Related

FAQ

Q: Can the AI see my keystrokes in real-time? A: No. The agent only reads pane content when you explicitly ask for help. There's no real-time monitoring.

Q: What if I have sensitive data on screen? A: Clear your screen or switch panes before asking for help. This tool does not filter sensitive data automatically.

Q: Does this work without tmux? A: No. This tool specifically uses tmux's capture capabilities. You must be running tmux.

Q: Can I use this with any AI agent? A: Yes, any agent that supports the Model Context Protocol (MCP) can use this tool.

Q: Why not just use terminal sharing/recording? A: This provides programmatic access for AI agents to read terminal state, enabling context-aware assistance during your workflow without manual copy-paste.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选