Persistent Shell MCP
Provides tools for persistent shell execution through tmux sessions, enabling command execution, process monitoring, and workspace management with dual-window architecture for separate execution and UI display.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Persistent Shell MCP start the dev server in a persistent workspace called 'backend'"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
This is experimental software intended for testing and development purposes only. Do not use in production environments or with sensitive data.
A Model Context Protocol (MCP) server that provides persistent shell execution through tmux sessions. This server enables AI assistants to execute commands in a persistent shell.
This unlocks a lot of possiblities, such as Agent Orchestration...
Features
Dual-Window Architecture: Each workspace has two windows -
execfor command execution anduifor clean output displayPersistent Workspaces: Execute commands in tmux sessions that persist across MCP client restarts
Interactive Process Support: Handle long-running processes, REPLs, and interactive commands
Workspace Isolation: Multiple isolated workspaces for different projects or tasks
Clean UI Management: Separate windows for execution and user-facing output
Automatic Session Management: Create, destroy, and monitor workspaces seamlessly
Related MCP server: tmux-mcp
Installation
šØ SECURITY WARNING: This software allows AI assistants to execute arbitrary shell commands on your system. Only install and use in isolated testing environments. Never use on systems with sensitive data or in production environments.
Prerequisites
Node.js 18.0.0 or higher
tmux installed on your system
Ubuntu/Debian:
sudo apt install tmuxmacOS:
brew install tmuxCentOS/RHEL:
sudo yum install tmux
Install from npm
npm install -g tmux-mcp-serverInstall from source
git clone https://github.com/TNTisdial/persistent-shell-mcp.git
cd persistent-shell-mcp
npm install
npm linkUsage
MCP Client Configuration
Add to your MCP client configuration:
{
"mcpServers": {
"tmux-shell": {
"command": "tmux-mcp-server"
}
}
}Available Tools
Core Execution Tools
execute_command
Execute commands that complete quickly and return full output. Uses the exec window.
execute_command({
command: "ls -la",
workspace_id: "my-project"
})start_process
Start long-running or interactive processes. Can target either window:
execwindow (default): For background processesuiwindow: For interactive applications that need user visibility
start_process({
command: "python3",
workspace_id: "dev",
target_window: "ui" // For interactive apps like vim, python REPL
})get_output
Capture current terminal output from either window:
uiwindow (default): Clean user-facing outputexecwindow: Raw shell with all commands
get_output({
workspace_id: "dev",
window_name: "ui" // or "exec" for raw output
})send_input
Send input to running processes in either window.
send_input({
text: "print('Hello World')",
workspace_id: "dev",
target_window: "ui"
})stop_process
Stop the currently running process in the exec window (sends Ctrl+C).
stop_process({workspace_id: "dev"})Workspace Management Tools
create_workspace
Create a new isolated workspace with dual windows.
destroy_workspace
Destroy a workspace and all its processes.
list_workspaces
List all active workspaces.
Architecture
Dual-Window Design
Each workspace consists of two tmux windows:
execwindow: Raw shell for command executionHandles all command execution
Shows full shell history and prompts
Used for background processes
uiwindow: Clean output displayShows clean output for user interaction
Used for interactive applications
Provides better user experience
Workspace Isolation
Each workspace is a separate tmux session
Independent working directories and environments
Processes don't interfere between workspaces
Clean separation of different projects/tasks
Common Workflows
Quick Command Execution
// Execute and get results immediately
execute_command({command: "npm install", workspace_id: "frontend"})
execute_command({command: "git status", workspace_id: "frontend"})Interactive Development
// Start Python REPL in UI window
start_process({
command: "python3",
workspace_id: "python-dev",
target_window: "ui"
})
// Send Python commands
send_input({text: "import os", workspace_id: "python-dev", target_window: "ui"})
send_input({text: "print(os.getcwd())", workspace_id: "python-dev", target_window: "ui"})
// Check output
get_output({workspace_id: "python-dev", window_name: "ui"})Background Process Management
// Start server in background
start_process({command: "npm run dev", workspace_id: "server"})
// Check server status
get_output({workspace_id: "server", window_name: "exec"})
// Stop server when done
stop_process({workspace_id: "server"})Multi-Project Development
// Frontend workspace
create_workspace({workspace_id: "frontend"})
execute_command({command: "cd /path/to/frontend", workspace_id: "frontend"})
// Backend workspace
create_workspace({workspace_id: "backend"})
execute_command({command: "cd /path/to/backend", workspace_id: "backend"})
// Database workspace
create_workspace({workspace_id: "database"})
start_process({command: "mysql -u root -p", workspace_id: "database", target_window: "ui"})Project Structure
tmux-mcp/
āāā src/
ā āāā server.js # Main MCP server and tool definitions
ā āāā tmux-manager.js # Tmux session and window management
ā āāā index.js # Entry point
āāā bin/
ā āāā tmux-mcp-server # Executable script
āāā package.json
āāā README.mdTroubleshooting
Tmux Not Found
Error: tmux command not foundInstall tmux: sudo apt install tmux (Ubuntu/Debian) or brew install tmux (macOS)
Workspace Creation Failed
Error: Failed to create workspaceCheck if tmux server is running and you have permissions to create sessions
Commands Not Responding
Check workspace status with get_outputUse get_output with window_name: "exec" to see raw shell state
Process Stuck
Use stop_process to send Ctrl+CSend interrupt signal with stop_process to terminate hanging processes
License
MIT
Available Tools
8 toolscreate_workspaceC
Create a new isolated workspace for commands.
Inputs: workspace_id (required).
destroy_workspaceB
Destroy a workspace and all its processes.
Inputs: workspace_id (required).
execute_commandC
Execute a shell command in the background 'exec' window and return the output.
Inputs: command (required), workspace_id.
get_outputA
Get current terminal output. Defaults to the ui window (what the user sees), but can check the exec window for background process status.
Inputs: workspace_id, window_name.
list_workspacesB
List all active workspaces.
Inputs: no named parameters.
send_inputC
Send input to a running process in a specified window.
Inputs: text (required), workspace_id, target_window.
start_processB
Start a long-running or interactive process. Defaults to the background exec window, but can target the ui window for interactive applications.
Inputs: command (required), workspace_id, target_window.
stop_processB
Stop the currently running process in the exec window (sends Ctrl+C).
Inputs: workspace_id.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogā¦
TDQS
Scored across 8 tools
Each tool has a clearly distinct purpose with no ambiguity. For example, create_workspace/destroy_workspace handle workspace lifecycle, execute_command/start_process differentiate between one-off commands and long-running processes, and get_output/send_input separate output retrieval from input sending. The descriptions clearly delineate when to use each tool.
All tools follow a consistent verb_noun pattern with snake_case throughout. The naming convention is perfectly predictable: create_workspace, destroy_workspace, execute_command, get_output, list_workspaces, send_input, start_process, stop_process. This consistency makes the tool set easy to understand and navigate.
With 8 tools, this server is well-scoped for persistent shell management. Each tool earns its place by covering essential operations: workspace management (create/destroy/list), process execution (execute/start/stop), and I/O handling (get_output/send_input). The count is neither too sparse nor bloated for the domain.
The tool surface provides excellent coverage of core persistent shell operations, including workspace lifecycle, process management, and I/O. A minor gap exists in workspace modification (e.g., rename_workspace or update_workspace_settings), but agents can work around this by destroying and recreating workspaces. The tools support complete workflows without dead ends.
Maintenance
Related MCP Connectors
Persistent cloud workspaces for AI agents: run commands, edit files, use git and a browser.
Operate Linux, macOS and Windows from your LLM. Every action runs through an auditable allowlist.
Persistent Linux computers for AI agents: desktop, signed-in browser, vault, apps and shell.
Linux VMs for AI agents: create VMs, run commands, edit files and open preview URLs.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceExposes tmux features to AI agents for managing sessions, windows, and panes with built-in command execution. It includes comprehensive guardrails to prevent destructive system operations, file deletions, and unauthorized network changes.-
- AlicenseAqualityDmaintenanceAllows AI assistants to create, manage, and interact with tmux sessions, windows, and panes programmatically.1919 PyPIMIT
- AlicenseAqualityDmaintenanceEnables AI agents to spawn, interact with, and orchestrate multiple concurrent terminal sessions via tmux.9MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to execute commands in a shared tmux session that is simultaneously visible to a human via a web-based terminal UI.1MIT