@yuki-yano/tmux-mcp
v0.0.8
Published
Development environment for the tmux MCP server
Downloads
41
Readme
Tmux MCP Server
A Bun/Node-compatible TypeScript toolkit that exposes tmux pane context and logs through the Model Context Protocol (MCP). It lets MCP-compatible assistants inspect and troubleshoot your live tmux session.
Requirements
- Node.js 20+
- Bun 1.2+
- tmux installed on the host machine
Configure MCP Agents
MCP-capable tools should launch the server themselves. Configure each agent to run bunx @yuki-yano/tmux-mcp@latest (or npx @yuki-yano/tmux-mcp@latest) as a command provider; there is no need to start the server manually.
MCP Tool Reference
All tools live under the tmux namespace. Validation is handled with Zod; requests outside these shapes are rejected and surface as tool call failed errors.
tmux.describe-context
- Purpose: identify the most relevant tmux pane and provide ranked alternatives.
- Request fields (optional):
paneHint: string matched against pane id/title/session/window/command.tags: string[] placeholder for future tagged panes (accepted but unused).
- Response:
{ primaryPane, candidates }where each pane includes{ id, title, session, window, command? }.
tmux.fetch-log
- Purpose: take a one-off log snapshot from a tmux pane or file.
- Required field:
modemust be"capture"or"file". - When to use: choose
mode: "capture"for panes,mode: "file"for local log files. Usetmux.stream-logfor anything that needs to keep streaming.
Capture mode (pane snapshot)
paneId— tmux pane id (for example"%305").lines— positive integer ≤ 10_000; defaults toTMUX_CONTEXT_CAPTURE_LINES(2000 if unset).filters— optionaltimeRange,keywords,levelsfilters.maskPatterns— strings or regex fragments replaced with***.summary— include{ totalLines, errorCount, firstErrorLine? }.
{ "mode": "capture", "paneId": "%305", "lines": 400 }File mode (log tail)
filePath— absolute path to the log file; response exposes a readable stream.
{ "mode": "file", "filePath": "/var/log/app.log" }Info: Passing
mode: "tail"ormode: "stream"triggers a validation error. For live streaming calltmux.stream-log.
tmux.stream-log
- Purpose: manage a live
pipe-panestream. - Start:
{ "mode": "stream", "paneId": "%1" }(the optionalaction: "start"is ignored). - Stop:
{ "mode": "stream", "action": "stop", "streamId": "...", "stopToken": "..." }using theidandstopTokenreturned when you started the stream. - Responses:
{ id, stopToken }for both start and stop. - Errors:
paneId is required,Stream not found: ...,Invalid stop token.
Typical Failure Scenarios
- Missing required fields (
paneId is required,filePath is required). - Unsupported
modestrings supplied tofetch-log(the error message includes the valid options). - Using a stale or incorrect
stopTokenwhen stopping a stream.
Example Calls
tmux.describe-context { "paneHint": "%3" }
// Start then stop a live stream (generic MCP JSON-RPC)
{
"name": "tmux.stream-log",
"arguments": { "mode": "stream", "paneId": "%1" }
}
{
"name": "tmux.stream-log",
"arguments": { "mode": "stream", "action": "stop", "streamId": "…", "stopToken": "…" }
}Optional Local Installation
If you need to bundle the server with other tooling:
npm install @yuki-yano/tmux-mcp
# or
bun add @yuki-yano/tmux-mcpOnce installed locally, the executable name is tmux-mcp, so npx tmux-mcp or bunx tmux-mcp will resolve to the same CLI.
Configuration
Environment variables tweak runtime behaviour:
| Variable | Description |
| --- | --- |
| TMUX_CONTEXT_TMUX_PATH | Absolute path to the tmux binary (falls back to $TMUX or tmux). |
| TMUX_CONTEXT_CAPTURE_LINES | Default capture-pane line count (defaults to 2000). |
| TMUX_CONTEXT_AUDIT_PATH | File destination for JSON Lines audit logs (defaults to STDOUT). |
| NODE_ENV | When test, suppresses info logs for cleaner test output. |
Developer Notes (for contributors)
- Source lives in
src/and follows a functional style (no classes or interfaces). src/index.tswires dependencies;src/sdk-server.tsregisters MCP tools via@modelcontextprotocol/sdk.- Supporting modules handle tmux integration, log formatting, file tailing, configuration, and auditing.
- Tests in
tests/mock external processes/files so they run without tmux. bun run ciexecutes formatting, type checks, lint, and tests before publishing.
