tmux-mcp
A persistent, stateful MCP server that exposes a detached tmux session to clients, enabling shell command execution, terminal buffer reading, and control signal sending via JSON-RPC over stdio.
README
Project BareMetal-Tmux
A decoupled, stateful, interactive MCP (Model Context Protocol) Tmux tool.
It exposes a persistent host tmux session to MCP clients — GitHub Copilot CLI,
ForgeCode, VS Code — over the stdio transport. No containers, no network: raw
JSON-RPC text streams straight into bare-metal shell execution.
Interactive terminal state survives agent crashes, context compaction reloads,
and framework restarts, because the shell lives in a detached tmux session
(local_agent_workspace) owned by the host — not by the agent process.
Architecture
Upstream Client (Copilot CLI / ForgeCode / VS Code)
│ spawns subprocess, speaks JSON-RPC over stdio
▼
Local MCP Server (server.py — Python 3.11+, fastmcp)
│ validates schemas, applies SR-01 safety checks, strips ANSI
▼
Host OS Shell (persistent detached tmux session, 20k-line scrollback)
MCP Tools
| Tool | Arguments | Purpose |
|---|---|---|
execute_command |
command: str, wait_s: float = 0 |
Dispatch a literal shell command into the persistent pane, followed by a carriage return (C-m). Fire-and-forget by default; pass wait_s > 0 (capped at 30) to sleep then return the trailing buffer in the same call. |
read_terminal_buffer |
lines: int = 100 (max 20000) |
Capture trailing scrollback from the pane, with ANSI/OSC/control sequences stripped so payloads always encode cleanly into JSON-RPC. |
send_control_signal |
signal: str = "SIGINT" |
Send SIGINT (Ctrl+C), SIGTSTP, SIGQUIT, or EOF to break blocking processes without killing the harness. |
The session is created lazily on first tool invocation (FR-01) with a 20,000-line history limit.
Safety Guardrails (SR-01)
Execution is un-sandboxed on the host, so the server refuses destructive commands before they reach the tmux buffer:
- Recursive
rmaimed at/or top-level system roots (/usr,/etc, …), includingsudo-wrapped and&&/;-chained variants --no-preserve-root,mkfs.*,dd of=/dev/..., redirects onto block devices, fork-bomb signatures
Workspace-scoped destruction (e.g. rm -rf ./build, /tmp/...) passes through.
Requirements
- Windows host: WSL distro
Ubuntu-24.04withtmuxinstalled (the server runs inside WSL; clients launch it viawsl.exe) - Linux/macOS host: just
tmuxonPATH— drop thewsl.exewrapper and runuv run python server.pydirectly - uv (installed user-locally, e.g.
curl -LsSf https://astral.sh/uv/install.sh | sh) - Python ≥ 3.11 (resolved by uv)
Setup
Dependencies are isolated in a uv-managed venv. On WSL, keep the venv on ext4
(not /mnt/c) for speed:
cd /mnt/c/Users/troll/Python/tmux-harness
export UV_PROJECT_ENVIRONMENT="$HOME/.venvs/tmux-harness"
uv sync
Run the smoke test (28 checks: ANSI stripping, SR-01 guardrails, live tmux round-trips against a throwaway session):
TMUX=harness_smoke_test uv run python tests/smoke_test.py
Client Integration
GitHub Copilot CLI
Two options:
-
Custom agent (recommended) — .github/agents/tmux.agent.md is a self-contained agent profile: it defines the MCP server in its frontmatter and allowlists only the three harness tools (no shell, no file edits, no web). Use it with:
/agent # pick "tmux" interactively copilot --agent=tmux -p "run the test suite and watch for failures" -
Global MCP server — merge mcp-config.copilot.json into
~/.copilot/mcp-config.jsonto expose the harness tools in every session (all built-in tools remain available).
ForgeCode
.mcp.json sits at the project root and is picked up automatically when ForgeCode runs from this directory.
VS Code
Add the same server block from .mcp.json to .vscode/mcp.json.
Configuration
| Variable | Default | Effect |
|---|---|---|
TMUX |
local_agent_workspace |
Name of the persistent tmux session |
UV_PROJECT_ENVIRONMENT |
.venv in project |
Venv location (keep on ext4 under WSL) |
Project Layout
server.py MCP server (tools, SR-01 checks, ANSI stripping)
pyproject.toml uv project: mcp[cli] + fastmcp
tests/smoke_test.py 28-check verification suite
.github/agents/tmux.agent.md Copilot CLI custom agent (harness tools only)
mcp-config.copilot.json Copilot CLI global MCP config
.mcp.json ForgeCode project-root MCP config
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。