remote-shell-mcp
Supports persistent interactive sessions to Docker containers, allowing AI assistants to run commands, transfer files, and manage containers via SSH-like access.
Supports persistent interactive sessions to Kubernetes pods via kubectl exec, enabling AI assistants to run commands, view logs, and manage containerized applications in a cluster.
Supports persistent interactive sessions to Vagrant-managed virtual machines, providing SSH-like access for AI assistants to manage and interact with the VM environment.
Click on "Install 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., "@remote-shell-mcpSSH into my server and tail the logs"
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.
Remote Shell MCP Server
Persistent SSH sessions for AI assistants. Give Claude, GPT, or any MCP-compatible AI the ability to maintain long-running remote shell connections—just like Warp does for developers.
What's New in v5.0
Feature | Description |
TTY Input | Respond to interactive prompts (passwords, confirmations) directly |
Swarm Mode | Launch parallel SSH sessions to multiple machines simultaneously |
Broadcast Commands | Execute the same command across all machines in a swarm |
Real-time Streaming | Monitor output in real-time with error pattern detection |
Auto-Interrupt | Automatically send Ctrl+C when errors are detected |
Related MCP server: MCP SSH Session
What's New in v4.0
Feature | Description |
Block-Based Output | Warp-style command blocks with search, tagging, and copy |
Pane Management | tmux-style split panes for multi-view sessions |
Session Sharing | Real-time collaboration with shareable URLs |
Enhanced Persistence | Session state persistence and faster reconnection |
Heartbeat Monitoring | Faster disconnect detection |
The Problem
AI assistants can't maintain persistent connections to remote servers. Every command runs in isolation:
AI: Let me SSH into your server and check the logs.
AI: [runs: ssh user@server "cat /var/log/app.log"] # Opens connection, runs, closes
AI: Now let me check disk space.
AI: [runs: ssh user@server "df -h"] # Opens ANOTHER connection, runs, closesThis means:
No session state — environment variables, working directory, and context are lost
Repeated authentication — every command requires a new SSH handshake
No file transfers — can't easily upload configs or download logs
Broken workflows — can't
cdto a directory and then run commands there
The Solution
Remote Shell MCP provides Warp-like persistent shell sessions for AI assistants:
AI: [starts session → ssh user@server]
AI: [runs: cd /var/log] # Working directory persists
AI: [runs: tail -f app.log] # Can run interactive commands
AI: [sends: Ctrl+C] # Can send signals
AI: [downloads: error.log] # Can transfer files
AI: [forwards: 5432 → postgres] # Can forward ports
AI: [shares session] # Collaborate in real-time
AI: [ends session] # Explicit close when doneFeatures
Core Features
Feature | Description |
Auto-Detection | Recognizes SSH commands and starts sessions automatically |
Persistent Sessions | Connections stay open until explicitly closed |
Multi-Cloud Support | GCP, AWS, Azure, plain SSH, kubectl, docker, vagrant |
Multiple Sessions | Run concurrent connections with easy switching |
Signal Support | Send Ctrl+C (SIGINT), SIGTERM, SIGKILL |
Auto-Cleanup | Stale sessions cleaned up after 1 hour |
v4.0 Features
Feature | Description |
Blocks | Every command creates a searchable, taggable block |
Panes | Split view with broadcast commands |
Sharing | Real-time session collaboration |
Persistence | State saved to disk for recovery |
Heartbeat | Fast disconnect detection |
v3.0 Features
Feature | Description |
File Transfer |
|
Port Forwarding |
|
Smart Wait | Auto-adjusts timeout: 500ms for |
Directory Tracking | Tracks |
Auto-Reconnect | Configurable reconnection with backoff |
Output Search |
|
Installation
Prerequisites
Node.js 18+
npm or yarn
An MCP-compatible AI client (Claude Code, Claude Desktop, etc.)
Setup
# Clone the repository
git clone https://github.com/raghavharness/remote-shell-mcp
cd mcp-remote-shell
# Install dependencies
npm install
# Build
npm run buildConfigure Claude Code
Add to ~/.claude/settings.json:
{
"mcpServers": {
"remote-shell": {
"command": "node",
"args": ["/path/to/mcp-remote-shell/dist/index.js"]
}
}
}Usage
The shell Tool
The primary interface. Auto-detects remote commands and manages sessions:
# Start a session (auto-detected):
shell(command="ssh user@hostname")
shell(command="gcloud compute ssh my-vm --zone us-central1-a")
# Run commands in session:
shell(command="ls -la")
shell(command="cd /var/log")
# Smart wait auto-adjusts for slow commands:
shell(command="npm install") # Waits 20s automatically
# Interrupt (Ctrl+C):
shell(command="//stop")
# End session:
shell(command="//end")Block-Based Output (NEW in v4.0)
Every command creates a block that can be referenced later:
# List recent blocks
remote_blocks_list(limit=10)
# Get a specific block
remote_block_get(blockId="block-5")
# Search through blocks
remote_blocks_search(query="error")
# Copy just the output (no command)
remote_block_copy(blockId="block-5")
# Tag blocks for organization
remote_block_tag(blockId="block-5", tags=["important", "debug"])
# Find error blocks
remote_blocks_errors()Pane Management (NEW in v4.0)
tmux-style panes within a session:
# Split the current pane
remote_pane_split(direction="horizontal")
remote_pane_split(direction="vertical")
# List panes
remote_pane_list()
# Switch to a pane
remote_pane_focus(paneId="pane-1")
# Run command in specific pane (without switching)
remote_pane_exec(paneId="pane-1", command="tail -f /var/log/app.log")
# Broadcast command to ALL panes
remote_pane_broadcast(command="uptime")
# Close a pane
remote_pane_close(paneId="pane-1")TTY Input (NEW in v5.0)
Respond to interactive prompts directly:
# Check if session is waiting for input
remote_session_check_prompt()
# Send text input
remote_session_input(input="my-response")
# Send password (hidden in output)
remote_session_password(password="secret123")
# Send Y/N confirmation
remote_session_confirm(confirm=true)Swarm Mode (NEW in v5.0)
Launch parallel SSH sessions to multiple machines:
# Create a swarm of SSH connections
remote_swarm_create(
name="web-servers",
method="ssh",
targets=[
{ "id": "web1", "host": "10.0.0.1", "username": "admin" },
{ "id": "web2", "host": "10.0.0.2", "username": "admin" },
{ "id": "web3", "host": "10.0.0.3", "username": "admin" }
]
)
# Create a GCloud swarm
remote_swarm_create(
name="gcp-cluster",
method="gcloud",
targets=[
{ "id": "node1", "instance": "gke-node-1", "zone": "us-central1-a" },
{ "id": "node2", "instance": "gke-node-2", "zone": "us-central1-a" }
]
)
# Broadcast command to all targets
remote_swarm_exec(swarmId="swarm-1", command="uptime")
remote_swarm_exec(swarmId="swarm-1", command="df -h")
# Send input to all sessions (e.g., for sudo password)
remote_swarm_input(swarmId="swarm-1", input="mypassword")
# Interrupt all sessions
remote_swarm_interrupt(swarmId="swarm-1")
# List swarms
remote_swarm_list()
# Get detailed swarm status
remote_swarm_status(swarmId="swarm-1")
# End a swarm
remote_swarm_end(swarmId="swarm-1")
remote_swarm_end(swarmId="all") # End all swarmsReal-time Streaming (NEW in v5.0)
Enable real-time output streaming with error detection:
# Enable streaming with auto-interrupt on errors
remote_stream_enable(autoInterrupt=true)
# Add custom error patterns
remote_stream_enable(
autoInterrupt=true,
errorPatterns=["CRITICAL", "OutOfMemory", "Segfault"]
)
# Check streaming status
remote_stream_status()
# Disable streaming
remote_stream_disable()When streaming is enabled:
Output is monitored in real-time
Error patterns are detected immediately
Interactive prompts are detected
Auto-interrupt sends Ctrl+C when errors are found
Session Sharing (NEW in v4.0)
Share sessions for real-time collaboration:
# Share the current session
remote_session_share(permissions="view")
# Returns: http://localhost:3847/share/abc123
# Share with control access and password
remote_session_share(permissions="control", password="secret123")
# List active shares
remote_shares_list()
# Update share settings
remote_share_update(shareId="abc123", permissions="control")
# Stop sharing
remote_session_unshare()File Transfer
# Upload a local file to remote:
remote_file_upload(localPath="./config.yml", remotePath="/etc/myapp/config.yml")
# Download a remote file:
remote_file_download(remotePath="/var/log/app.log", localPath="./app.log")
# List remote directory:
remote_file_list(path="/var/log")Port Forwarding
# Local forward: access remote PostgreSQL on localhost:5433
remote_port_forward_local(localPort=5433, remoteHost="localhost", remotePort=5432)
# Remote forward: expose local dev server to remote
remote_port_forward_remote(remotePort=8080, localPort=3000)
# List active forwards:
remote_port_list()
# Stop a forward:
remote_port_stop(forwardId="fwd-1")Supported Connection Types
Type | Pattern | Example |
SSH |
|
|
GCP |
|
|
AWS |
|
|
Azure |
|
|
Kubernetes |
|
|
Docker |
|
|
Control Sequences & MCP Prompts
Every control sequence has a corresponding MCP prompt:
Exit Session
Sequence | MCP Prompt | Aliases |
|
|
|
|
|
Interrupt Command
Sequence | MCP Prompt | Aliases |
|
|
|
Blocks
MCP Prompt | Description |
| List recent command blocks |
| Get a specific block |
| Search through blocks |
| Find error blocks |
| Tag a block |
Panes
MCP Prompt | Description |
| Split current pane |
| List panes |
| Switch to pane |
| Close a pane |
| Broadcast command to all panes |
Sharing
MCP Prompt | Description |
| Share current session |
| Stop sharing |
| List active shares |
All Tools (50)
Tool | Purpose |
Core | |
| Primary tool - execute commands, auto-detect sessions |
| Start session with explicit parameters |
| List all sessions with details |
| Switch between sessions |
| End session(s) |
| View command history |
| Get raw output buffer |
| Send signals |
| Search history/output |
| Find error messages |
Files | |
| Upload file to remote |
| Download file from remote |
| List remote directory |
Ports | |
| Start local port forward |
| Start remote port forward |
| List port forwards |
| Stop port forward |
| Stop all port forwards |
Blocks (v4.0) | |
| List command blocks |
| Get specific block |
| Search blocks |
| Copy block output |
| Tag a block |
| Remove block tags |
| Toggle block collapsed |
| Find error blocks |
Panes (v4.0) | |
| Split pane |
| Focus pane |
| Close pane |
| List panes |
| Execute in specific pane |
| Broadcast to all panes |
| Rename pane |
| Focus next pane |
Sharing (v4.0) | |
| Share session |
| Stop sharing |
| List shares |
| Update share settings |
| Start share server |
| Stop share server |
Swarm (v5.0) | |
| Create parallel session swarm |
| List active swarms |
| Get swarm details |
| Broadcast command to swarm |
| Send input to all swarm sessions |
| Interrupt all swarm sessions |
| End swarm |
| Add target to swarm |
| Remove target from swarm |
Input/Streaming (v5.0) | |
| Send input to session |
| Check for pending prompts |
| Send Y/N confirmation |
| Send password (hidden) |
| Enable real-time streaming |
| Disable streaming |
| Get streaming status |
Smart Wait Time
Commands automatically get appropriate timeouts:
Command Type | Wait Time | Example |
Quick info | 500ms |
|
File read | 1s |
|
Search | 3s |
|
Default | 2s | Most commands |
Network | 10s |
|
Package install | 15-30s |
|
Build | 20-60s |
|
Override with explicit waitTime parameter when needed.
Example Workflow
User: Connect to prod and figure out why the app is slow
Claude: [shell: gcloud compute ssh prod-server --project myapp]
Session started: gcloud:prod-server
Working directory: /home/user
Claude: [shell: top -bn1 | head -20]
CPU at 95%! Checking what's using it...
[block-1]
Claude: [shell: ps aux --sort=-%cpu | head -10]
App process using 92% CPU.
[block-2]
Claude: [remote_blocks_search: query="error"]
Found 3 matches in block history...
Claude: [remote_pane_split: direction="horizontal"]
Split into 2 panes for monitoring
Claude: [remote_pane_exec: paneId="pane-1", command="tail -f /var/log/app.log"]
Watching logs in pane-1...
Claude: [remote_session_share: permissions="view"]
Shared session: http://localhost:3847/share/xyz789
(Ops team can watch live)
Claude: [shell: sudo systemctl restart myapp]
Service restarted.
Claude: [shell: //end]
Session ended. App should be recovering.Architecture
┌─────────────────┐ ┌───────────────────────────────┐ ┌─────────────────┐
│ AI Client │────▶│ Remote Shell MCP │────▶│ Remote Server │
│ (Claude Code) │ MCP │ Server │ │ (SSH/gcloud) │
└─────────────────┘ └───────────────────────────────┘ └─────────────────┘
│
┌───────────┴───────────┐
▼ ▼
┌───────────────┐ ┌───────────────┐
│Session Manager│ │ Features │
│ - Sessions │ │ - Blocks │
│ - Panes │ │ - Persistence │
│ - History │ │ - Sharing │
└───────────────┘ │ - FileTransfer│
│ - PortForward │
│ - SmartWait │
└───────────────┘
│
┌───────┴───────┐
▼ ▼
┌───────────┐ ┌───────────┐
│ WebSocket │ │ Web Client│
│ Server │──▶│ (Browser) │
└───────────┘ └───────────┘Module Structure
src/
├── index.ts # MCP server entry point
├── session-manager.ts # Session lifecycle management
├── types.ts # TypeScript interfaces
├── features/
│ ├── blocks.ts # Block-based output (v4.0)
│ ├── panes.ts # Pane management (v4.0)
│ ├── persistence.ts # Session persistence (v4.0)
│ ├── heartbeat.ts # Connection monitoring (v4.0)
│ ├── sharing/ # Session sharing (v4.0)
│ │ ├── share-manager.ts
│ │ └── ws-server.ts
│ ├── file-transfer.ts # SFTP/SCP operations
│ ├── port-forward.ts # Port forwarding
│ ├── smart-wait.ts # Command timeout logic
│ ├── directory-tracker.ts
│ ├── reconnect.ts
│ ├── output-search.ts
│ └── streaming.ts
├── tools/
│ ├── shell.ts # Main shell tool
│ ├── session-tools.ts # Session management
│ ├── file-tools.ts # File transfer tools
│ ├── port-tools.ts # Port forward tools
│ ├── block-tools.ts # Block tools (v4.0)
│ ├── pane-tools.ts # Pane tools (v4.0)
│ └── share-tools.ts # Share tools (v4.0)
├── prompts/
│ └── index.ts # MCP prompts
└── utils/
├── ansi.ts # Terminal formatting
├── terminal-ui.ts # UI helpers
└── patterns.ts # Command detectionDevelopment
# Install dependencies
npm install
# Build
npm run build
# Watch mode
npm run dev
# Run integration tests (local only)
npm test
# Run with live SSH (requires TEST_SSH_HOST, TEST_SSH_USER)
TEST_SSH_HOST=myserver TEST_SSH_USER=myuser npm testTroubleshooting
Session won't start
Ensure CLI tools are installed and authenticated (
gcloud auth login, etc.)Check SSH keys are configured
Commands timeout
Smart wait auto-adjusts, but override with
waitTimeparameterUse
//stopto interrupt stuck commands
File transfer fails
SSH2 sessions use SFTP (most reliable)
Child process sessions use base64 encoding
Port forward not working
Ensure local port is available
Check remote service is running
Share server issues
Default port is 3847
Use
remote_share_server_start(port=XXXX)to use a different portCheck firewall allows connections
License
MIT License - see LICENSE for details.
Keywords: MCP, Model Context Protocol, SSH, remote shell, AI tools, Claude, persistent sessions, terminal, DevOps, SFTP, port forwarding, cloud computing, tmux, panes, blocks, collaboration, sharing
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/raghavharness/remote-shell-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server