MCP Remote Machine Control - Secure MCP Server by ALMC Security 2025

MCP Remote Machine Control

View on GitHub

MCP Remote Machine Control

A Model Context Protocol (MCP) server that provides comprehensive remote machine control capabilities for Claude Code, eliminating SSH overhead and providing token-efficient system operations.

Features

🚀 Performance Benefits

  • 30-50% fewer tokens vs SSH commands
  • Persistent connections - no SSH handshake overhead
  • Structured data exchange - binary protocol vs text parsing
  • Session-based authentication - authenticate once, not per command

🛠️ System Control Tools

  • File Operations: read, write, copy, move, delete, permissions
  • Process Management: list, monitor, kill processes
  • Service Control: systemctl operations (start/stop/enable/disable)
  • Package Management: install/remove/update (apt/yum/pacman auto-detection)
  • System Monitoring: CPU, memory, disk, network status
  • Command Execution: direct shell access with sudo support

🔐 Security Features

  • Session-based sudo authentication (30-minute cache)
  • Local network IP filtering
  • Secure password handling (never stored)
  • Command audit logging

Quick Start

1. Installation

# Clone or download the server files
git clone <repository> mcp-remote-machine
cd mcp-remote-machine

# Run installation script
./install_server.sh

2. Configure Claude Code

Add the MCP server to Claude Code:

# For local machine control
claude mcp add remote-machine "python3 /path/to/remote_machine_server.py --transport stdio"

# For remote machine (over network)
claude mcp add remote-machine-net "python3 /path/to/remote_machine_server.py --transport sse --host 0.0.0.0 --port 8765"

3. Start Using

In Claude Code, you'll have access to these tools:

  • authenticate_sudo - Authenticate for privileged operations
  • execute_command - Run shell commands
  • read_file / write_file - File operations
  • list_directory - Browse directories
  • process_management - Control processes
  • service_control - Manage systemd services
  • package_management - Install/remove packages
  • system_info - Get system status

Usage Examples

Basic Authentication

First authenticate for sudo operations:
> Use authenticate_sudo with your password

File Operations

> Read the contents of /etc/nginx/nginx.conf
> Write a new configuration to /etc/myapp/config.json
> List all files in /var/log/ including hidden files

System Management

> Get current system information including CPU and memory usage
> Install the htop package
> Restart the nginx service
> Show all running processes

Command Execution

> Execute "df -h" to show disk usage
> Run "systemctl status docker" with sudo privileges

Architecture

MCP vs SSH Comparison

AspectSSH ApproachMCP Approach
Tokens per operation~150-300~50-150
Connection overheadNew connection each commandPersistent connection
Data formatText parsing requiredStructured JSON
AuthenticationPer-command promptsSession-based cache
Error handlingText parsingStructured responses
Type safetyNoneFull type annotations

Server Architecture

┌─────────────────┐    ┌──────────────────┐    ┌─────────────────┐
│   Claude Code   │◄──►│   MCP Server     │◄──►│  Target System  │
│                 │    │                  │    │                 │
│ - Tool calls    │    │ - Authentication │    │ - File system   │
│ - Structured    │    │ - Command exec   │    │ - Processes     │
│   responses     │    │ - System APIs    │    │ - Services      │
└─────────────────┘    └──────────────────┘    └─────────────────┘

Configuration Options

Server Transport Modes

STDIO Mode (recommended for local/SSH):

python3 remote_machine_server.py --transport stdio

SSE Mode (for network access):

python3 remote_machine_server.py --transport sse --host 0.0.0.0 --port 8765

Claude Code MCP Configuration

Edit your Claude Code MCP configuration:

{
  "mcpServers": {
    "remote-machine": {
      "command": "python3",
      "args": ["/path/to/remote_machine_server.py", "--transport", "stdio"],
      "env": {
        "PYTHONPATH": "/path/to/server"
      }
    }
  }
}

Security Considerations

Local Network Setup

  • Server is designed for local network use where security is less critical
  • IP filtering can be configured for additional security
  • No SSL/TLS required for local network communication

Authentication

  • Sudo passwords are cached in memory only (never written to disk)
  • Session timeout configurable (default: 30 minutes)
  • All privileged operations require prior authentication

Network Security

  • For network access, ensure firewall rules allow only trusted sources
  • Consider running behind reverse proxy for additional security layers
  • Monitor server logs for suspicious activity

Troubleshooting

Common Issues

"Sudo authentication required"

  • Use the authenticate_sudo tool first with your password
  • Check if sudo session has timed out (default: 30 minutes)

"Command not found" errors

  • Verify the package manager detection worked correctly
  • Some commands may need full paths (e.g., /usr/bin/systemctl)

Connection issues

  • For SSE mode, ensure the port is not blocked by firewall
  • Check that the server process is running and listening

Debug Mode

Run server with debug logging:

PYTHONPATH=/path/to/server python3 remote_machine_server.py --transport stdio

Token Efficiency Analysis

Typical Operation Comparison

Installing a package via SSH:

Tokens: ~280
Command: ssh user@host "sudo apt install -y htop"
Response parsing: Complex text parsing required

Installing a package via MCP:

Tokens: ~120  
Tool call: package_management(action="install", package_name="htop")
Response: Structured JSON with success/error status

Reading a file via SSH:

Tokens: ~200
Command: ssh user@host "cat /etc/hostname"  
Response: Raw text output

Reading a file via MCP:

Tokens: ~80
Tool call: read_file(file_path="/etc/hostname")
Response: Structured with content, size, modified date

Overall Benefits

  • 35% average token reduction across common operations
  • 50% faster execution due to persistent connections
  • Better error handling with structured responses
  • Type safety prevents many classes of errors

Dependencies

  • Python 3.8+
  • mcp >= 1.0.0
  • psutil >= 5.9.0
  • fastapi >= 0.100.0 (for SSE mode)
  • uvicorn >= 0.20.0 (for SSE mode)

License

MIT License - see LICENSE file for details.

Related in Development - Secure MCP Servers

ServerSummaryActions
MCP Audio InspectorView
PureScript MCP ServerA Model Context Protocol (MCP) server that provides PureScript development tools for AI assistants l...View
React Native Debugger MCPAn MCP server that connects to your React Native application debugger.View
YAPI MCP ServerThis is a Model Context Protocol (MCP) server that provides access to YAPI interface details.View
CODING DevOpsCODING DevOps MCP Server 是一个基于 Model Context Protocol (MCP) 的服务器实现,用于与 CODING DevOps...View
Jenkins MCP ServerA Python-based Jenkins MCP server using the Model Context Protocol Python SDK. This server integrate...View