Skip to main content

MCP server for interactive tmux terminal sessions with Claude Code

Project description

MCP tmux Terminal Server

An MCP server that provides interactive tmux terminal sessions for Claude Code. Run background tasks in tmux sessions that you can attach to and interact with directly.

Features

  • Project-based Sessions: One tmux session per project (folder), multiple tasks as panes
  • Interactive Background Tasks: Commands run in tmux panes you can attach to
  • Full Terminal Access: Attach with tmux attach -t claude-<project> for full control
  • Output Monitoring: Claude Code can capture and monitor terminal output
  • Send Input: Send commands or special keys (Ctrl+C, etc.) to specific tasks
  • Task Management: List, monitor, and kill individual tasks or entire project sessions

Architecture

Project: myapp/
├── Session: claude-myapp
│   ├── Pane 1: backend (python manage.py runserver)
│   ├── Pane 2: frontend (npm run dev)
│   └── Pane 3: tests (pytest --watch)

All tasks for a project share one tmux session with multiple panes.

Prerequisites

  • Python >= 3.10
  • tmux installed on your system:
    • macOS: brew install tmux
    • Linux: apt install tmux or yum install tmux

Installation

From PyPI (recommended)

pip install mcp-tmux-server

Or with pipx for isolated installation:

pipx install mcp-tmux-server

From source

git clone https://github.com/GrigoriLab/mcp-tmux-server.git
cd mcp-tmux-server
poetry install

Register with Claude Code

If installed via pip/pipx:

claude mcp add --transport stdio --scope user tmux-terminal -- mcp-tmux

If installed from source:

claude mcp add --transport stdio --scope user tmux-terminal -- \
  poetry --directory /path/to/mcp-tmux-server run mcp-tmux

Verify Registration

claude mcp list

Available Tools

run_in_terminal

Start a command in a new pane within the project's session.

Parameters:

Name Type Required Description
command string Yes Shell command to execute
project string No Project name for grouping tasks (overrides auto-detection from working_directory)
task_name string No Descriptive name for the task (pane)
working_directory string No Directory to run in (used for project name if project not specified)

Example:

{
  "command": "npm run dev",
  "project": "myapp",
  "task_name": "frontend",
  "working_directory": "/path/to/myapp/frontend"
}

Note: If project is not specified, the project name is extracted from the last folder component of working_directory. Use project explicitly when tasks in subdirectories should share a session.

Returns:

{
  "success": true,
  "session_name": "claude-myapp",
  "project": "myapp",
  "task_name": "frontend",
  "attach_command": "tmux attach -t claude-myapp"
}

get_terminal_output

Capture output from a project session or specific task.

Parameters:

Name Type Required Description
project string Yes Project name (folder name)
task_name string No Specific task to capture from
lines int No Number of lines (default: 100, max: 10000)
include_history bool No Include scrollback history

send_input

Send text or special keys to a project session or specific task.

Parameters:

Name Type Required Description
project string Yes Project name (folder name)
text string Yes Text to send, or special key
task_name string No Specific task to send to
press_enter bool No Press Enter after text (default: true)

Special keys: C-c (Ctrl+C), C-d (Ctrl+D), C-z (Ctrl+Z), C-l (Ctrl+L), Escape

list_sessions

List all active project sessions with their tasks.

Returns:

{
  "success": true,
  "count": 1,
  "sessions": [
    {
      "name": "claude-myapp",
      "project": "myapp",
      "attach_command": "tmux attach -t claude-myapp",
      "panes": [
        {"task_name": "frontend", "command": "npm run dev"},
        {"task_name": "backend", "command": "python manage.py runserver"}
      ]
    }
  ]
}

kill_session

Terminate all tasks for a project.

Parameters:

Name Type Required Description
project string Yes Project name to terminate

kill_task

Terminate a specific task within a project.

Parameters:

Name Type Required Description
project string Yes Project name
task_name string Yes Task to terminate

Usage Examples

Start Multiple Tasks for a Project

Ask Claude Code:

"Start the backend and frontend for my project"

Claude runs two run_in_terminal calls with the same working_directory:

Task 'backend' started in project session 'claude-myapp'.
Task 'frontend' started in project session 'claude-myapp'.
Attach with: tmux attach -t claude-myapp

Both tasks appear as panes in the same tmux session.

View All Tasks

tmux attach -t claude-myapp

Use Ctrl+B, arrow keys to switch between panes.

Stop a Specific Task

Ask Claude Code:

"Stop the frontend task in myapp"

Claude uses kill_task with project: "myapp", task_name: "frontend".

Stop All Tasks

Ask Claude Code:

"Kill all tasks for myapp"

Claude uses kill_session with project: "myapp".

tmux Quick Reference

Action Command
List sessions tmux list-sessions
Attach to project tmux attach -t claude-<project>
Switch panes Ctrl+B, then arrow keys
Detach (keep running) Ctrl+B, then D
Kill session tmux kill-session -t claude-<project>
Scroll in tmux Ctrl+B, then [, then arrow keys
Exit scroll mode Q

Debugging

Claude Code MCP Debug Mode

claude --mcp-debug

Test Server Manually

mcp-tmux

Or from source:

poetry run mcp-tmux

Check Server Health

claude mcp list

Troubleshooting

"tmux is not installed"

Install tmux:

  • macOS: brew install tmux
  • Ubuntu/Debian: sudo apt install tmux
  • RHEL/CentOS: sudo yum install tmux

"Session not found"

The session may have been killed. Check active sessions:

tmux list-sessions

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcp_tmux_server-0.1.1.tar.gz (10.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcp_tmux_server-0.1.1-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file mcp_tmux_server-0.1.1.tar.gz.

File metadata

  • Download URL: mcp_tmux_server-0.1.1.tar.gz
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mcp_tmux_server-0.1.1.tar.gz
Algorithm Hash digest
SHA256 8c38fd3d155c06088f9cf5d62142b730c6dbc629d183581e639c5ed18d226578
MD5 b62e2da236633d3dba667b97bf4fbeb8
BLAKE2b-256 30a27577d2e802c1c741b7144ed4691ec1ed340cc37e2390f53e83a2e973b912

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcp_tmux_server-0.1.1.tar.gz:

Publisher: publish.yml on GrigoriLab/mcp-tmux-server

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mcp_tmux_server-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for mcp_tmux_server-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6c63ebc3fcb2a8a2ae9a783f09a1a69d097e8973dd47d6d8e60ef497c5a1120d
MD5 3db97c855e48adbc7890066455756779
BLAKE2b-256 cda2601cab4286f83581a3bc4af697fecbebadd85551ff8a16f34dff83105a3a

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcp_tmux_server-0.1.1-py3-none-any.whl:

Publisher: publish.yml on GrigoriLab/mcp-tmux-server

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page