# Remote Terminal
**AI-Powered Remote Linux Server Management via MCP**
Remote Terminal lets Claude (the AI assistant) execute commands on your remote Linux servers through a natural chat interface. Watch full output in your browser in real-time while Claude receives smart-filtered summaries optimized for token efficiency.
---
## šÆ What Is This?
Imagine telling Claude:
```
"Install nginx on my server and configure it with SSL"
"Run complete system diagnostics and tell me if anything looks wrong"
"Find all log errors from the last hour and summarize them"
"Save this batch script and run it again next week"
```
And Claude does it - executing commands, analyzing output, saving useful scripts, and taking action on your behalf.
**That's Remote Terminal.**
---
## ⨠Key Features
### Core Capabilities
- **š„ļø Remote Command Execution** - Run any bash command on Linux servers
- **š Multi-Server Management** - Switch between multiple servers easily
- **š File Transfer (SFTP)** - Upload/download files and directories with compression
- **š Batch Script Execution** - Run multi-command scripts 10-50x faster
- **š Batch Script Library** - Save, browse, and reuse batch scripts (NEW in 3.1)
- **š¬ Conversation Tracking** - Group commands by goal with rollback support
- **šÆ Recipe System** - Save successful workflows for reuse
- **šļø Database Integration** - Full audit trail with SQLite
- **š Interactive Web Terminal** - Full-featured terminal in browser (type, paste, scroll history)
- **š Multi-Terminal Sync** - Open multiple terminals, all perfectly synchronized
- **⨠Bash Syntax Highlighting** - VS Code-style colors in standalone UI (NEW in 3.1)
### The Interactive Web Terminal
Remote Terminal provides a **fully interactive terminal window** in your browser at `http://localhost:8080` - it looks and feels just like WSL, PuTTY, or any standard terminal:
**You can:**
- Type commands directly (just like any terminal)
- Copy/paste text (Ctrl+C, Ctrl+V)
- Scroll through command history
- Use arrow keys for history navigation
- View real-time command output with colors preserved
**Claude can:**
- Execute commands that appear in your terminal
- See command results instantly
- Continue working while you watch
**The key advantage:** You maintain complete visibility and control. Every command Claude runs appears in your terminal window in real-time. You're never in the dark about what's happening on your server - it's like sitting side-by-side with an assistant who types commands for you while you watch the screen.
**Multi-Terminal Support:** Open multiple browser windows at `http://localhost:8080` - they all stay perfectly synchronized via WebSocket broadcast. Type in one terminal, see it in all terminals instantly. Perfect for multi-monitor setups or sharing your view with others.
ā ļø **Best Practice:** Close unused terminal tabs when done. While the system handles multiple connections efficiently, keeping many old tabs open can consume unnecessary resources and may cause connection issues.
#### š¬ See It In Action
<video width="800" controls>
<source src="https://raw.githubusercontent.com/TiM00R/remote-terminal/master/docs/demo.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>
https://github.com/user-attachments/assets/98a6fa41-ec4f-410b-8d4a-a2422d8ac7c9
*Watch the interactive web terminal in action - see Claude execute commands while you maintain full visibility and control*
### The Dual-Stream Architecture
Behind the scenes, Remote Terminal uses a smart two-stream approach:
```
SSH Output from Remote Server
ā
[Raw Output]
ā
āāāāāā“āāāāā
ā ā
ā ā
[FULL] [FILTERED]
ā ā
ā ā
Web Terminal Claude
(You see all) (Smart summary)
```
**Result:**
- **You:** Full visibility and control in interactive terminal
- **Claude:** Efficient work with 95% token savings
- **Both:** Shared SSH session, synchronized state
- **Best of both worlds!**
## š Quick Start
### Installation
**Step 1: Create Installation Directory**
```powershell
# Choose a location for your installation (example: C:\RemoteTerminal)
mkdir C:\RemoteTerminal
cd C:\RemoteTerminal
```
**Step 2: Install Package**
```powershell
# Create dedicated virtual environment
python -m venv remote-terminal-env
remote-terminal-env\Scripts\activate
pip install remote-terminal-mcp
```
**Step 3: Configure Claude Desktop**
Edit `%APPDATA%\Claude\claude_desktop_config.json`:
```json
{
"mcpServers": {
"remote-terminal": {
"command": "C:\\RemoteTerminal\\remote-terminal-env\\Scripts\\remote-terminal-mcp.exe",
"env": {
"REMOTE_TERMINAL_ROOT": "C:\\RemoteTerminal"
}
}
}
}
```
**Important:** Replace `C:\RemoteTerminal` with your actual installation path from Step 1.
**Step 4: First Run - Auto Setup**
Restart Claude Desktop. On first use, configuration files will automatically copy to `C:\RemoteTerminal`:
- `config.yaml` - Default settings (auto-created from package defaults)
- `hosts.yaml` - Server list (auto-created from template)
**Step 5: Configure Your Servers**
You have two options to configure your servers:
**Option A: Manual Configuration (Recommended for first server)**
Edit `C:\RemoteTerminal\hosts.yaml`:
```yaml
servers:
- name: My Server
host: 192.168.1.100
user: username
password: your_password
port: 22
description: My development server
tags:
- development
# Optional: Set default server for auto-connect
# Use list_servers to see which server is marked as [DEFAULT]
default_server: My Server
```
**Option B: AI-Assisted Configuration**
Ask Claude to help you add a new server:
```
Claude, add a new server to my configuration:
- Name: Production Server
- Host: 192.168.1.100
- User: admin
- Password: mypassword
- Port: 22
```
Claude will use the `add_server` tool to update your `hosts.yaml` file automatically.
Restart Claude Desktop and test:
```
List my configured servers
```
**Step 6: (Optional) Run Standalone Web Interface**
```powershell
cd C:\RemoteTerminal
remote-terminal-env\Scripts\activate
remote-terminal-standalone
```
Access at:
- Control Panel: http://localhost:8081
- Terminal: http://localhost:8082
---
## š Documentation
Complete guides for every use case:
- **[Quick Start](https://github.com/TiM00R/remote-terminal/blob/master/docs/QUICK_START.md)** ā Get running in 5 minutes
- **[Installation](https://github.com/TiM00R/remote-terminal/blob/master/docs/INSTALLATION.md)** ā Detailed setup instructions
- **[User Guide](https://github.com/TiM00R/remote-terminal/blob/master/docs/USER_GUIDE.md)** ā Complete feature walkthrough
- **[Feature Reference](https://github.com/TiM00R/remote-terminal/blob/master/docs/FEATURE_REFERENCE.md)** ā All MCP tools reference
- **[Troubleshooting](https://github.com/TiM00R/remote-terminal/blob/master/docs/TROUBLESHOOTING.md)** ā Common problems and solutions
- **[WebSocket Broadcast](https://github.com/TiM00R/remote-terminal/blob/master/docs/WEBSOCKET_BROADCAST.md)** ā Multi-terminal synchronization details
- **[Release Notes v3.1](https://github.com/TiM00R/remote-terminal/blob/master/docs/RELEASE_NOTES_v3.1.md)** ā Release notes for version 3.1
---
## š” Usage Examples
### System Administration
```
"Check disk space and memory usage"
"What processes are using the most CPU?"
"Is nginx running? If not, start it"
"Show me the last 50 lines of the system log"
```
### Software Management
```
"Install htop and verify it works"
"Update all packages"
"Check if docker is installed and what version"
```
### Troubleshooting
```
"Run complete network diagnostics"
"Find all errors in the last hour of logs"
"Check why nginx won't start"
"Analyze disk usage by directory"
```
### File Operations
```
"Upload my local config.json to /etc/app/"
"Download all log files from /var/log/myapp/"
"List files in /var/log modified today"
"Find all files larger than 100MB"
```
### Automation & Script Management
```
"Create a recipe from our successful nginx installation"
"Execute the network diagnostics recipe"
"Start a conversation to configure WiFi"
"List my saved batch scripts"
"Execute script 5"
"Load script 3 for editing"
```
---
## šØ Example Session
**You:**
> Install nginx on my production server
**Claude:**
> I'll install nginx. This will create a package installation...
*Interactive terminal opens automatically at http://localhost:8080*
**Web Terminal shows (real-time):**
```
$ sudo apt install nginx
Reading package lists... Done
Building dependency tree... Done
[... 500+ lines of installation output ...]
Setting up nginx (1.18.0-0ubuntu1) ...
Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service
Processing triggers for systemd (245.4-4ubuntu3.23) ...
```
**Claude receives (filtered summary):**
```
nginx installed successfully in 45s
12 packages installed
Service: nginx.service is active
```
**Claude responds:**
> nginx has been successfully installed and is now running. The service is active. Would you like me to configure it or show you the default page?
**Token savings: 96% (15,000 tokens ā 600 tokens)**
---
## šļø Architecture
### Project Structure
```
remote_terminal/
āāā config/ # Default configuration templates
ā āāā config.yaml # Default settings (packaged)
ā āāā hosts.yaml.example # Server template (packaged)
āāā data/ # SQLite database (user directory)
ā āāā remote_terminal.db # Command history, conversations, recipes, scripts
āāā docs/ # Documentation
ā āāā DATABASE_SCHEMA.md
ā āāā FEATURE_REFERENCE.md
ā āāā INDEX.md
ā āāā INSTALLATION.md
ā āāā QUICK_START.md
ā āāā RELEASE_NOTES_v3.1.md
ā āāā TROUBLESHOOTING.md
ā āāā USER_GUIDE.md
ā āāā WEBSOCKET_BROADCAST.md
āāā recipes/ # Example automation recipes
āāā src/ # Source code (modular architecture)
ā āāā batch/ # Batch execution system
ā ā āāā batch_executor.py
ā ā āāā batch_helpers.py
ā ā āāā batch_parser.py
ā āāā config/ # Configuration management
ā ā āāā config.py
ā ā āāā config_dataclasses.py
ā ā āāā config_init.py
ā ā āāā config_loader.py
ā āāā database/ # Database operations (SQLite)
ā ā āāā database_manager.py # Core database manager
ā ā āāā database_batch.py # Batch script storage
ā ā āāā database_batch_execution.py
ā ā āāā database_batch_queries.py
ā ā āāā database_batch_scripts.py
ā ā āāā database_commands.py # Command history
ā ā āāā database_conversations.py
ā ā āāā database_recipes.py # Recipe storage
ā ā āāā database_servers.py # Machine identity tracking
ā āāā output/ # Output filtering & formatting
ā ā āāā output_buffer.py
ā ā āāā output_buffer_base.py
ā ā āāā output_buffer_filtered.py
ā ā āāā output_filter.py # Smart filtering (95% token savings)
ā ā āāā output_filter_commands.py
ā ā āāā output_filter_decision.py
ā ā āāā output_formatter.py
ā āāā prompt/ # Command completion detection
ā ā āāā prompt_detector.py
ā ā āāā prompt_detector_checks.py
ā ā āāā prompt_detector_pager.py
ā ā āāā prompt_detector_patterns.py
ā āāā ssh/ # SSH/SFTP operations
ā ā āāā ssh_manager.py # High-level SSH manager
ā ā āāā ssh_connection.py # Connection lifecycle
ā ā āāā ssh_commands.py # Command execution
ā ā āāā ssh_io.py # Input/output streaming
ā āāā state/ # Shared state management
ā ā āāā shared_state_conversation.py
ā ā āāā shared_state_monitor.py
ā ā āāā shared_state_transfer.py
ā āāā static/ # Web terminal static assets
ā ā āāā fragments/ # HTML fragments
ā ā āāā vendor/ # xterm.js library
ā ā āāā terminal.css
ā ā āāā terminal.js
ā ā āāā transfer-panel.js
ā āāā tools/ # MCP tool modules (modular)
ā ā āāā decorators.py # Tool decorators
ā ā āāā tools_hosts.py # Server management (main)
ā ā āāā tools_hosts_crud.py # Add/remove/update servers
ā ā āāā tools_hosts_select.py # Server selection & connection
ā ā āāā tools_commands.py # Command execution (main)
ā ā āāā tools_commands_database.py
ā ā āāā tools_commands_execution.py
ā ā āāā tools_commands_status.py
ā ā āāā tools_commands_system.py
ā ā āāā tools_conversations.py # Conversation tracking (main)
ā ā āāā tools_conversations_lifecycle.py
ā ā āāā tools_conversations_query.py
ā ā āāā tools_batch.py # Batch script execution (main)
ā ā āāā tools_batch_execution.py
ā ā āāā tools_batch_helpers.py
ā ā āāā tools_batch_management.py
ā ā āāā tools_recipes.py # Recipe automation (main)
ā ā āāā tools_recipes_create.py
ā ā āāā tools_recipes_crud.py
ā ā āāā tools_recipes_execution.py
ā ā āāā tools_recipes_helpers.py
ā ā āāā tools_recipes_modify.py
ā ā āāā tools_recipes_query.py
ā ā āāā tools_sftp.py # File transfer (main)
ā ā āāā tools_sftp_single.py # Single file transfer
ā ā āāā tools_sftp_directory.py # Directory transfer
ā ā āāā tools_sftp_directory_download.py
ā ā āāā tools_sftp_directory_upload.py
ā ā āāā tools_sftp_exceptions.py
ā ā āāā tools_sftp_utils.py
ā ā āāā sftp_compression.py # Compression logic
ā ā āāā sftp_compression_download.py
ā ā āāā sftp_compression_tar.py
ā ā āāā sftp_compression_upload.py
ā ā āāā sftp_decisions.py # Auto/manual compression decisions
ā ā āāā sftp_progress.py # Progress tracking
ā ā āāā sftp_transfer_compressed.py
ā ā āāā sftp_transfer_download.py
ā ā āāā sftp_transfer_scan.py
ā ā āāā sftp_transfer_standard.py
ā ā āāā sftp_transfer_upload.py
ā ā āāā tools_info.py # System information
ā āāā utils/ # Utility functions
ā ā āāā utils.py
ā ā āāā utils_format.py
ā ā āāā utils_machine_id.py # Hardware/OS fingerprinting
ā ā āāā utils_output.py
ā ā āāā utils_text.py
ā āāā web/ # Web terminal (WebSocket-enabled)
ā ā āāā web_terminal.py # Main web server
ā ā āāā web_terminal_ui.py # UI components
ā ā āāā web_terminal_websocket.py # Multi-terminal sync
ā āāā mcp_server.py # MCP server entry point
ā āāā shared_state.py # Global shared state
ā āāā command_state.py # Command registry & tracking
ā āāā hosts_manager.py # Multi-server configuration
ā āāā error_check_helper.py # Error detection
āāā standalone/ # Standalone web UI (no Claude)
āāā static/
ā āāā css/ # Standalone UI styles
ā ā āāā control-forms.css
ā ā āāā control-layout.css
ā ā āāā control-response.css
ā ā āāā control-styles.css # Bash syntax highlighting
ā āāā js/ # Standalone UI scripts
ā ā āāā control-forms.js
ā ā āāā control-forms-fields.js
ā ā āāā control-forms-generation.js
ā ā āāā control-forms-utils.js
ā ā āāā control-main.js
ā ā āāā control-response.js
ā āāā tool-schemas/ # MCP tool schemas
ā āāā batch.json
ā āāā commands.json
ā āāā file-transfer.json
ā āāā servers.json
ā āāā workflows.json
āāā mcp_control.html # Control panel HTML
āāā standalone_mcp.py # Standalone server entry point
āāā standalone_mcp_endpoints.py # API endpoints
āāā standalone_mcp_startup.py # Initialization & connection
```
### Technology Stack
- **Python 3.9+** - Core language
- **MCP Protocol** - Claude integration
- **Paramiko** - SSH/SFTP library
- **NiceGUI + WebSockets** - Web terminal with multi-terminal sync
- **SQLite** - Database for history/recipes/scripts
- **FastAPI** - Web framework
---
## š§ Configuration
### Configuration Files Location
Configuration files are automatically copied to your working directory on first run:
**For PyPI users:**
- Set `REMOTE_TERMINAL_ROOT` in Claude Desktop config
- Files auto-copy to that directory on first run
- Location: `%REMOTE_TERMINAL_ROOT%\config.yaml` and `hosts.yaml`
- User data preserved when reinstalling/upgrading
**Default template files packaged with installation:**
- `config/config.yaml` - Default settings template
- `config/hosts.yaml.example` - Server configuration template
### hosts.yaml
Define your servers:
```yaml
servers:
- name: production
host: 192.168.1.100
user: admin
password: secure_pass
port: 22
description: Production server
tags: production, critical
- name: development
host: 192.168.1.101
user: dev
password: dev_pass
tags: development
default_server: production
```
---
## š”ļø Security Considerations
### Current Status
- Passwords stored in plain text in `hosts.yaml`
- Web terminal bound to localhost only (not network-exposed)
- Full command audit trail in database
- SSH uses standard security (password authentication)
- User config files stored outside package (preserved on reinstall)
---
## š Performance
### Token Efficiency
Average token savings on verbose commands:
| Command Type | Full Output | Filtered | Savings |
|--------------|-------------|----------|---------|
| apt install | ~15,000 | ~600 | **96%** |
| ls -la /var | ~8,000 | ~400 | **95%** |
| Log search | ~12,000 | ~500 | **96%** |
| find / | ~30,000 | ~800 | **97%** |
**Average: 95-98% token reduction on verbose commands**
### Speed Improvements
Batch execution vs sequential:
- **10 commands sequential:** 5 minutes (10 round-trips)
- **10 commands batch:** 30 seconds (1 round-trip)
- **Speed improvement: 10x faster!**
---
## š Advanced Features
### Batch Script Library
Save batch scripts for reuse:
```
1. Run diagnostics ā Script auto-saved with deduplication
2. Browse library ā "List my batch scripts"
3. Execute saved script ā "Execute script 5"
4. Edit existing ā "Load script 3 for editing"
5. Track usage ā times_used, last_used_at
```
Features:
- **Automatic deduplication** via SHA256 hash
- **Usage statistics** tracking
- **Edit mode** for modifications
- **Search and sort** capabilities
- **Two-step deletion** with confirmation
### Conversation Tracking
Group related commands by goal:
```
Start conversation: "Configure nginx with SSL"
ā [Execute multiple commands]
ā End conversation: success
ā Create recipe from conversation
```
Benefits:
- Organized command history
- Rollback capability
- Context for AI
- Recipe generation
### Recipe System
Save successful workflows:
```python
# Recipe: wifi_diagnostics
1. lspci | grep -i network
2. iwconfig
3. ip link show
4. dmesg | grep -i wifi
5. systemctl status NetworkManager
```
Reuse on any compatible server:
```
Execute wifi_diagnostics recipe on my new server
```
### Machine Identity
Each server tracked by unique machine_id (hardware + OS fingerprint):
- Commands tracked per physical machine
- Recipes execute on compatible systems
- Audit trail maintains integrity
- Handles server IP changes
---
## š Known Issues & Limitations
### Current Limitations
1. **Designed for Windows local machine**
- Currently optimized for Windows 10/11
- Linux/Mac support possible with modifications
2. **SSH Key Support not implemented**
- Password authentication only
- SSH keys work with manual SSH but not integrated with MCP tools
3. **Works with only one remote server at a time**
- Can configure multiple servers
- Can only actively work with one server per session
- Switch between servers as needed
---
## š¤ Contributing
This is Tim's personal project. If you'd like to contribute:
1. Test thoroughly on your setup
2. Document any issues found
3. Suggest improvements
4. Share recipes and scripts you create
---
## š Version History
### Version 1.3.1 (Current - February 20, 2026)
**Prompt Detection Logging Overhaul:**
- ā
Production mode: 2 log lines per command (Start + Detected) instead of hundreds
- ā
Debug mode: full verbose logging via `prompt_detection.debug_logging: true` in config.yaml
- ā
Detection summary includes: polls, lines_checked, last_non_match, matched string, total_lines
- ā
Pager/sudo/verify events still logged in production (rare, meaningful)
**Startup Config Dump:**
- ā
Full config.yaml logged at startup (passwords redacted)
- ā
Hosts summary logged (server count + default server)
- ā
Simplifies remote support and troubleshooting for distributed users
**Auto-Default Server:**
- ā
Default server automatically updated on every successful connection
- ā
Eliminates "connected to wrong server after restart" problem
- ā
Persisted to hosts.yaml immediately
**Buffer Overflow Fix:**
- ā
Commands no longer return [No output] after buffer reaches max_lines
- ā
command_start_line now tracks absolute position with offset correction
- ā
Sliding window deque buffer works correctly at any fill level
### Version 1.3.0 (January 2026)
**Virtual Environment Prompt Support:**
- ā
Added venv prefix support to all prompt patterns `(\(.+\)\s+)?`
- ā
Supports Python venv, Conda, Poetry, Pipenv and similar tools
- ā
Fixed GENERIC_PROMPT patterns in server selection and machine ID detection
- ā
Fixed pattern defaults not applied when missing from config.yaml
- ā
Fixed config file copy path for pip installations
- ā
Fixed hosts.yaml.example template (removed invalid default field)
- ā
All fixes tested and verified
### Version 1.2.1 (December 2024)
**Standalone Import Fix:**
- ā
Fixed ModuleNotFoundError in standalone modules
- ā
Added try/except fallback imports for both source and installed package usage
**Code Modularization:**
- ā
Reorganized source into modular directory structure (batch, config, database, output, prompt, ssh, state, utils, web)
- ā
Split large tool modules into smaller focused files
- ā
All 37 MCP tools tested and working after refactor
### Version 1.2.0 (December 2024)
**PyPI Package Distribution:**
- ā
Full PyPI package with modern pyproject.toml configuration
- ā
Automatic config initialization via REMOTE_TERMINAL_ROOT environment variable
- ā
Config files auto-copy to user directory on first run (survives upgrades)
- ā
Enhanced list_servers tool with [CURRENT] and [DEFAULT] markers
- ā
Fixed standalone mode crash when default server unreachable
**Standalone Web UI - Help System:**
- ā
Help button (ā) added to all MCP tools with comprehensive documentation
- ā
Help modal with full usage examples and parameter descriptions
- ā
Updated all tool schemas: workflows, commands, batch, servers, file-transfer
- ā
Enhanced CSS with consistent button colors (green Execute, blue Help)
**Recipe Management (3 new tools):**
- ā
`delete_recipe` - Permanent deletion with two-step confirmation
- ā
`create_recipe_from_commands` - Manual recipe creation without execution
- ā
`update_recipe` - In-place recipe modification (preserves ID/stats)
- ā
Recipe dropdown selectors replacing manual ID entry in standalone UI
**WebSocket Multi-Terminal Sync:**
- ā
Replaced HTTP polling with WebSocket broadcast architecture
- ā
Multiple browser terminals stay perfectly synchronized
- ā
Auto-reconnect on connection loss
### Version 1.1.0 (December 2024)
**Batch Script Management (5 new tools):**
- ā
`list_batch_scripts`, `get_batch_script`, `save_batch_script`, `execute_script_content_by_id`, `delete_batch_script`
- ā
Automatic deduplication via SHA256 content hash
- ā
Usage statistics tracking (times_used, last_used_at)
- ā
Edit mode for script modifications
- ā
Two-step deletion with confirmation
- ā
Bash syntax highlighting in standalone UI (VS Code colors)
- ā
Tool renaming: `create_diagnostic_script` ā `build_script_from_commands`, `execute_batch_script` ā `execute_script_content`
### Version 1.0.0 (Initial Release - December 2024)
**Core Features:**
- ā
Interactive web terminal (type, paste, scroll history)
- ā
Multi-server management with machine identity tracking
- ā
Smart output filtering (95-98% token reduction)
- ā
Batch script execution (10-50x faster than sequential)
- ā
Conversation tracking with rollback support
- ā
Recipe system for workflow automation
- ā
SFTP file transfer with compression
- ā
SQLite database for complete audit trail
- ā
Full MCP integration with Claude Desktop
- ā
Dual-stream architecture (full output to browser, filtered to Claude)
---
## š Support
For issues or questions:
1. **Check Documentation**
2. **Review Logs**
- Claude Desktop logs (Help ā Show Logs)
3. **Test Components**
- Use standalone mode (start_standalone.ps1)
- Test SSH manually
- Verify database (view_db.py)
---
## š License
This project is for personal use by Tim. Not currently open source.
---
## š Acknowledgments
- **Anthropic** - Claude and MCP protocol
- **Paramiko** - SSH library
- **FastAPI** - Web framework
- **NiceGUI** - UI components with WebSocket support
---
**Ready to let Claude manage your servers? Check out [QUICK_START.md](https://github.com/TiM00R/remote-terminal/blob/master/docs/QUICK_START.md) to get started in 5 minutes!**
---
**Version:** 1.3.1
**Last Updated:** February 20, 2026
**Maintainer:** Tim