loading…
Search for a command to run...
loading…
Enables LLMs to securely manage Virtual Private Servers via SSH, with features including command execution, file operations, system monitoring, and service mana
Enables LLMs to securely manage Virtual Private Servers via SSH, with features including command execution, file operations, system monitoring, and service management.
License Python Version MCP Protocol
MCP VPS Manager is a secure, production-ready Model Context Protocol (MCP) server that enables Large Language Models to safely manage Virtual Private Servers via SSH. This tool provides comprehensive VPS management capabilities with built-in security controls, connection pooling, and comprehensive audit logging.
# 1. Clone and install
git clone https://github.com/your-org/mcp-vps-manager.git
cd mcp-vps-manager
pip install -r requirements.txt
# 2. Configure your servers
cp templates/servers.yaml config/servers.yaml
# Edit config/servers.yaml with your server details
# 3. Add to Claude Desktop config
# See Configuration section for details
# 4. Test the connection
python bin/mcp-vps-manager --config config/servers.yaml --log-level DEBUG
Ask Claude Desktop:
# Clone the repository
git clone <repository-url>
cd mcp-vps-manager
# Install dependencies
poetry install
# Activate the virtual environment
poetry shell
pip install mcp-vps-manager
Copy the example configuration file and customize it:
cp config/servers.yaml.example config/servers.yaml
Edit config/servers.yaml:
servers:
- name: production-web
host: 192.168.1.10
port: 22
username: admin
ssh_key_path: ~/.ssh/id_rsa
ssh_key_passphrase_env: SSH_KEY_PASS # Optional
allowed_paths:
- /home/admin
- /var/www
- /etc/nginx
blocked_commands: # Additional patterns beyond defaults
- shutdown
- reboot
max_file_size_mb: 50
connection_timeout: 30
command_timeout: 300
- name: staging-db
host: staging.example.com
port: 2222
username: dbadmin
ssh_key_path: ~/.ssh/staging_key
allowed_paths:
- /home/dbadmin
- /var/lib/mysql
- /etc/mysql
max_file_size_mb: 100
Create a .env file (optional):
cp .env.example .env
Configure environment variables:
# SSH Key Passphrases (if needed)
SSH_KEY_PASS=your_ssh_key_passphrase_here
# Server Configuration
SERVERS_CONFIG_PATH=./config/servers.yaml
# Logging Configuration
LOG_LEVEL=INFO
LOG_DIR=./logs
# Connection Pool Settings
MAX_CONNECTIONS_PER_SERVER=3
HEALTH_CHECK_INTERVAL=30
Add to your Claude Desktop MCP configuration:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Linux: ~/.config/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"mcp-vps-manager": {
"command": "python",
"args": ["-m", "vps_manager.server", "--config", "path/to/config/servers.yaml"],
"env": {
"SSH_KEY_PASS": "your_passphrase_if_needed"
}
}
}
}
# Using Poetry
poetry run mcp-vps-manager --config config/servers.yaml
# Using Python module
python -m vps_manager.server --config config/servers.yaml --log-level DEBUG
Execute shell commands on VPS servers with streaming and queuing support.
{
"command": "ls -la /var/www",
"server": "production-web",
"timeout": 30,
"background": false,
"stream_output": false,
"priority": "normal",
"use_queue": true
}
New Parameters:
stream_output (boolean): Enable real-time output streaming for long commandspriority (string): Queue priority - "low", "normal", "high", or "critical"use_queue (boolean): Force use or bypass of the command queue systemRead file contents from VPS servers.
{
"path": "/var/www/index.html",
"server": "production-web",
"encoding": "utf-8"
}
Write content to files on VPS servers.
{
"path": "/var/www/new-page.html",
"content": "<html><body>Hello World</body></html>",
"server": "production-web",
"create_dirs": true,
"backup": true
}
Upload files from local system to VPS.
{
"local_path": "/local/file.txt",
"remote_path": "/var/www/file.txt",
"server": "production-web",
"create_dirs": false
}
Download files from VPS to local system.
{
"remote_path": "/var/log/app.log",
"local_path": "/local/downloads/app.log",
"server": "production-web"
}
Get comprehensive system metrics.
{
"server": "production-web",
"detailed": true
}
Control system services.
{
"service_name": "nginx",
"action": "restart",
"server": "production-web",
"force": false
}
List system services.
{
"server": "production-web",
"running_only": false,
"pattern": "nginx.*"
}
Retrieve service logs.
{
"service_name": "nginx",
"server": "production-web",
"lines": 100
}
Monitor command queue status and metrics.
{
"server": "production-web"
}
Response includes:
Clean up old command queue results to free memory.
{
"max_age_hours": 24
}
"Check the system status of my web server"
Using get_system_status tool on production-web server...
System Status:
- CPU Usage: 15.3% (4 cores)
- Memory: 3.2GB used / 8GB total (40%)
- Disk: 45GB used / 100GB total (45%)
- Load Average: 0.8, 0.6, 0.5
- Uptime: 15 days, 6 hours
"Restart nginx and check if it's running"
1. Using service_control to restart nginx...
✓ Nginx restarted successfully
2. Using service_control to check status...
✓ Nginx is active and running
3. Using exec_command to verify web server response...
✓ Web server responding on port 80
"Run a system update with real-time output"
Using exec_command with stream_output=true and high priority...
Starting system package update:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
[Real-time streaming output continues...]
Fetching http://security.ubuntu.com/ubuntu jammy-security InRelease
Get:1 http://archive.ubuntu.com/ubuntu jammy InRelease [270 kB]
...
✓ Update completed successfully with streaming output
"Check command queue status across all servers"
Using get_queue_status tool...
Queue Status Summary:
- production-web: 2 commands queued, 1 executing, rate limit: 5/sec
- staging-db: 0 commands queued, 0 executing, rate limit: 3/sec
- monitoring: 1 command queued, 0 executing, rate limit: 10/sec
Total metrics: 15 commands executed, 2 failed, avg execution time: 1.2s
allowed_paths to only necessary directories/etc, /boot, /sys)blocked_commands for each serverError: Failed to connect test-server-1: [Errno 111] Connection refused
Solutions:
systemctl status sshdufw status or iptables -Lssh -i ~/.ssh/key user@hostError: Command matches dangerous pattern: sudo\s+passwd
Solutions:
force=true for administrative tasks (carefully)Error: Path not in allowed directories: /etc/passwd
Solutions:
allowed_paths in server configurationError: File size 104857600 exceeds limit of 50MB
Solutions:
max_file_size_mb in server configurationRun with debug logging to troubleshoot issues:
python -m vps_manager.server --config config/servers.yaml --log-level DEBUG
Check logs in the configured log directory:
debug.log: Detailed operation logserror.log: Error messages and stack tracesaudit.log: Command execution audit trailMonitor connection pool health:
# The server exposes connection status via MCP resources
# Access vps://server-name resource in Claude to see connection status
# Clone repository
git clone <repository-url>
cd mcp-vps-manager
# Install development dependencies
poetry install --with dev
# Run tests
poetry run pytest
# Run type checking
poetry run mypy src/
# Format code
poetry run black src/ tests/
poetry run isort src/ tests/
# Lint code
poetry run flake8 src/ tests/
# Run all tests
poetry run pytest
# Run with coverage
poetry run pytest --cov=src/vps_manager
# Run specific test file
poetry run pytest tests/unit/test_security.py
# Run integration tests (requires test environment)
poetry run pytest tests/integration/
For development and testing, you can use virtual machines or cloud instances with test configurations:
# Set up a test server with SSH access
# Create dedicated test user and SSH keys
ssh-keygen -t rsa -b 4096 -f ~/.ssh/test_key -C "[email protected]"
# Configure test server in servers.yaml
# Use appropriate port and credentials for your test environment
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ Claude/LLM │───▶│ MCP VPS Server │───▶│ VPS Servers │
└─────────────────┘ └──────────────────┘ └─────────────────┘
│
▼
┌──────────────────┐
│ Security Layer │
│ Connection Pool │
│ Audit Logging │
└──────────────────┘
server.py): Main MCP protocol handlerconnection_pool.py): SSH connection management with health checksqueue.py): Priority-based command queuing and rate limitingsecurity.py): Command and path validationtools/command.py)tools/file_ops.py)tools/monitoring.py)tools/services.py)utils/distro.py)utils/secure_sudo.py)utils/error_handling.py, utils/mcp_responses.py)MIT License - see LICENSE file for details.
Made with love for the MCP community
Securely manage your VPS infrastructure with AI assistance
Выполни в терминале:
claude mcp add mcp-vps-manager -- npx Безопасность
Низкий рискАвтоматическая эвристика по публичным данным — не гарантия безопасности.