Skip to main content
Glama

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)

Related MCP server: Ryan's Tmux MCP Server

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 rm aimed at / or top-level system roots (/usr, /etc, …), including sudo-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.04 with tmux installed (the server runs inside WSL; clients launch it via wsl.exe)

  • Linux/macOS host: just tmux on PATH — drop the wsl.exe wrapper and run uv run python server.py directly

  • 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:

  1. 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"
  2. Global MCP server — merge mcp-config.copilot.json into ~/.copilot/mcp-config.json to 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

Available Tools

3 tools
execute_commandA

Dispatch a raw shell command string into the persistent background workspace pane (FR-02). The text is sent literally, then a carriage return (C-m) is appended to ensure statement completion.

By default output is NOT returned — poll read_terminal_buffer to observe
results. Pass wait_s > 0 to sleep that many seconds (capped at 30.0)
after dispatch and get the trailing buffer back in the same call —
ideal for quick commands. Long jobs should still dispatch, then poll.

Inputs: command (required), wait_s. Returns: result

read_terminal_bufferA

Capture trailing scrollback from the active tmux pane (FR-03).

Hard-wrapped rows are joined and trailing blank viewport padding is
trimmed before the payload is returned.

Args:
    lines: Number of trailing scrollback lines to capture (default 100,
        max 20000).

Inputs: lines. Returns: result

send_control_signalA

Issue a control signal keystroke to the persistent pane (FR-04), e.g. SIGINT (Ctrl+C) to break out of a blocking process without killing the harness. Supported: SIGINT, SIGTSTP, SIGQUIT, EOF.

Inputs: signal. Returns: result

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A4.4/5.0

    Scored across 3 tools

    Disambiguation5/5

    Each tool addresses a distinct action: sending commands, reading output, and sending control signals. There is no overlap in functionality.

    Naming Consistency5/5

    All tool names follow a consistent verb_noun pattern in snake_case (execute_command, read_terminal_buffer, send_control_signal), with no deviations.

    Tool Count5/5

    Three tools cover the essential interactions with a tmux pane (write, read, signal). This is well-scoped for a minimal but functional MCP server.

    Completeness4/5

    The tools cover the core workflow of dispatching commands and retrieving output. Missing operations like pane management or clearing the buffer are minor gaps given the focused scope.

    Maintenance

    ActivityInactive
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      C
      maintenance
      MCP server for SSH and local terminal access. Supports interactive commands, long-running processes, and TUI apps like tmux/zellij
      6
      4
      MIT
    • A
      license
      B
      quality
      B
      maintenance
      A comprehensive MCP server for driving tmux sessions, windows, panes, sending keystrokes, and reading pane output locally or over SSH, enabling real-time collaborative pairing with AI.
      71
      6
      MIT