Secure VPS Operations MCP Server
Enables inspection of Docker containers, including listing containers and reading their logs.
Provides visibility into Grafana container health and logs through the container inspection tools.
Allows users to check the syntax and validity of Nginx configuration files on the VPS.
Provides visibility into OpenSearch container health and logs through the container inspection tools.
Provides visibility into Prometheus container health and logs through the container inspection tools.
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., "@Secure VPS Operations MCP Server Check the system health and disk usage on my VPS"
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.
Secure VPS Operations MCP Server
A secure, read-only Model Context Protocol (MCP) server for inspecting a VPS over SSH without giving an AI assistant unrestricted shell access.
The core idea is simple: the AI selects approved operations; it never constructs or executes arbitrary shell commands.
What This Project Does
This project exposes a small set of MCP tools for safe VPS inspection:
get_system_healthget_disk_usagelist_containersget_container_logsget_service_statuscheck_nginx_configurationcheck_ssl_expirycheck_database_health
Each MCP tool validates input locally, checks configured allowlists, then calls a fixed SSH gateway command on the VPS. The gateway maps operation names to root-owned scripts under /usr/local/lib/mcp/scripts.
There is intentionally no generic execute_shell tool.
Related MCP server: Kalymos Hoag
Architecture
AI Client
|
v
MCP Client
|
v
Local Python MCP Server
|
v
SSH key authentication
|
v
Dedicated VPS user
|
v
/usr/local/bin/mcp-command-gateway
|
v
Root-owned allowlisted scriptsWhy Python
This first version uses Python 3.11+ because the official MCP Python SDK, asyncssh, and Pydantic make a small control-plane server straightforward to build and audit.
Java would also be viable, especially inside an existing Spring-based internal platform, but Python keeps this MCP adapter smaller and simpler for the first release.
Security Model
The security boundary is based on constraints rather than prompting:
No unrestricted shell tool
Dedicated SSH user, not root
SSH key authentication only
Host-key verification through
known_hostsFixed gateway command on the VPS
Operation allowlist in the gateway
Resource allowlists for containers, services, domains, and databases
Root-owned scripts that the SSH user cannot edit
Narrow sudo rules only where required
Output sanitisation before returning data to the model
Append-only JSONL audit logs
Local Setup
Create a virtual environment:
python3.11 -m venv .venv
source .venv/bin/activate
pip install -e '.[test]'Create local configuration:
cp .env.example .envEdit .env:
SSH_HOST=your-vps-host-or-ip
SSH_PORT=22
SSH_USERNAME=mcp-operator
SSH_PRIVATE_KEY_FILE=/path/to/private/key
SSH_KNOWN_HOSTS_FILE=/path/to/known_hosts
ALLOWED_CONTAINERS=grafana,prometheus,opensearch
ALLOWED_SERVICES=app.service,docker.service,nginx.service
ALLOWED_DOMAINS=api-dev.example.com,api-staging.example.com
ALLOWED_DATABASES=appdbPin the VPS host key:
ssh-keyscan -H your-vps-host-or-ip >> ~/.ssh/known_hostsRun tests:
python -m pytestRun the MCP server locally:
contabo-ops-mcpFor stdio MCP usage, the server will appear to wait for input. That is expected. An MCP client starts the process and communicates with it over stdin/stdout.
VPS Setup
Create a dedicated user on the VPS:
sudo useradd --create-home --shell /bin/bash mcp-operator
sudo mkdir -p /home/mcp-operator/.ssh
sudo chmod 700 /home/mcp-operator/.ssh
sudo chown -R mcp-operator:mcp-operator /home/mcp-operatorCreate an SSH key locally:
ssh-keygen -t ed25519 -f ~/.ssh/vps_mcp -C "vps-operations-mcp"Add the public key to the VPS:
sudo tee /home/mcp-operator/.ssh/authorized_keys > /dev/null <<'EOF'
PASTE_PUBLIC_KEY_HERE
EOF
sudo chown -R mcp-operator:mcp-operator /home/mcp-operator/.ssh
sudo chmod 700 /home/mcp-operator/.ssh
sudo chmod 600 /home/mcp-operator/.ssh/authorized_keys
sudo chmod 755 /home/mcp-operatorTest SSH from your local machine:
ssh -i ~/.ssh/vps_mcp mcp-operator@your-vps-host-or-ipGateway Installation
Copy the gateway to the VPS:
scp -i ~/.ssh/vps_mcp vps/mcp-command-gateway mcp-operator@your-vps-host-or-ip:/tmp/mcp-command-gatewayInstall it on the VPS:
sudo install -o root -g root -m 755 /tmp/mcp-command-gateway /usr/local/bin/mcp-command-gateway
sudo mkdir -p /usr/local/lib/mcp/scripts
sudo chown -R root:root /usr/local/lib/mcp
sudo chmod -R 755 /usr/local/lib/mcpThe gateway accepts structured JSON like this:
{
"operation": "system.health",
"arguments": {}
}It rejects unknown operations and never accepts raw shell commands.
Example Script
Create /usr/local/lib/mcp/scripts/system-health on the VPS:
sudo tee /usr/local/lib/mcp/scripts/system-health > /dev/null <<'EOF'
#!/usr/bin/env bash
set -Eeuo pipefail
load_average="$(cut -d ' ' -f1-3 /proc/loadavg)"
uptime_seconds="$(cut -d. -f1 /proc/uptime)"
hostname="$(hostname)"
printf '{"success":true,"hostname":"%s","uptimeSeconds":%s,"loadAverage":"%s"}\n' \
"$hostname" \
"$uptime_seconds" \
"$load_average"
EOF
sudo chown root:root /usr/local/lib/mcp/scripts/system-health
sudo chmod 755 /usr/local/lib/mcp/scripts/system-healthTest directly on the VPS:
printf '{"operation":"system.health","arguments":{}}' | /usr/local/bin/mcp-command-gatewayTest from your local machine over SSH:
ssh -i ~/.ssh/vps_mcp mcp-operator@your-vps-host-or-ip \
'printf '\''{"operation":"system.health","arguments":{}}'\'' | /usr/local/bin/mcp-command-gateway'MCP Client Configuration
For an MCP client that supports local stdio servers, configure the command as:
{
"mcp": {
"vps-ops": {
"type": "local",
"command": [
"/absolute/path/to/project/.venv/bin/python",
"/absolute/path/to/project/src/contabo_mcp/main.py"
],
"enabled": true,
"env": {
"PYTHONPATH": "/absolute/path/to/project/src"
}
}
}
}Restart the MCP client after changing its config.
Example prompts:
"Check system health on the VPS."
"Show disk usage on the VPS."
"Show the last 20 logs for the Grafana container."
"Check SSL expiry for
api-dev.example.com.""Check status of
nginx.service."
Development
Run tests:
source .venv/bin/activate
python -m pytestCheck config loading:
python -c "from contabo_mcp.config import get_settings; print(get_settings().ssh_host)"Check the SSH gateway from Python:
python - <<'PY'
import asyncio
from contabo_mcp.config import get_settings
from contabo_mcp.ssh_gateway import SshGateway
async def main():
gateway = SshGateway(get_settings())
result = await gateway.execute("system.health", {})
print(result.exit_code)
print(result.stdout)
print(result.stderr)
asyncio.run(main())
PYCurrent Scope
This repository is intentionally read-only for the first release.
Write operations such as service restarts, Nginx reloads, certificate renewal, backups, deployments, and rollbacks should be added only after implementing:
Explicit approval handling
Risk classification
Narrow sudo rules
Idempotency checks
Post-action health verification
Stronger audit records
Failure and rollback behavior
License
This project is licensed under the MIT License. See LICENSE for details.
Available Tools
8 toolscheck_database_healthA
Return health information for an allowlisted PostgreSQL database.
Inputs: database (required). Returns: object
check_nginx_configurationB
Run nginx configuration validation on the VPS.
Inputs: no named parameters. Returns: object
check_ssl_expiryB
Return certificate expiry details for an allowlisted domain.
Inputs: domain (required). Returns: object
get_container_logsC
Return recent logs for an allowlisted Docker container.
Inputs: container (required), lines. Returns: object
get_disk_usageA
Return filesystem usage for the VPS.
Inputs: no named parameters. Returns: object
get_service_statusA
Return systemd status for an allowlisted service.
Inputs: service (required). Returns: object
get_system_healthA
Return CPU, memory, load, disk, and service health summary from the VPS.
Inputs: no named parameters. Returns: object
list_containersA
List allowlisted Docker containers and their status.
Inputs: no named parameters. Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 8 tools
Most tools have clearly distinct purposes (system health, disk usage, containers, logs, services, nginx, SSL, database). There's minor overlap between get_system_health and get_disk_usage/get_service_status, but descriptions clarify the scope.
All tool names follow a consistent verb_noun pattern (get_*, list_*, check_*) with snake_case throughout. The verbs are predictable and appropriate for the actions.
8 tools is well-scoped for a VPS operations/monitoring server. Each tool addresses a distinct monitoring need without redundancy or bloat.
The server covers core VPS health checks (system, disk, containers, services, nginx, SSL, database) well. Minor gaps exist (e.g., no network health or process-level details), but the surface is sufficient for typical operational monitoring.
Related MCP Connectors
Let AI operate servers without SSH. Choose actions, approve risky changes, and audit every step.
Manage Vozora VPS servers, SSH keys, firewalls, DNS and usage from an AI agent.
Read-only server insight: why a Linux server or K8s cluster is slow, failing or changed.
Run verified read-only code tools: quant diagnostics + agent-ops preflight, no source exposure.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceProvides read-only server monitoring and diagnostic tools for AI assistants to manage Linux and Unraid systems via SSH. It enables natural language interactions for container management, storage health checks, and system log analysis while keeping credentials secure.17ISC
- FlicenseNot gradedqualityCmaintenanceEnables AI agents to audit server health and operations through read-only tools, including container status, logs, alerts, and WhatsApp session status, without requiring SSH access.-
- AlicenseAqualityBmaintenanceEnables AI agents to safely monitor Linux VPS health, inspect Docker containers, retrieve service logs, and execute whitelisted recovery actions via MCP.31134 npm45 PyPIMIT
- FlicenseNot gradedqualityBmaintenanceEnables controlled diagnostics and limited actions on a VPS through safe, auditable tools instead of an unrestricted root terminal, including read-only checks, basic Docker status, allowed-path file reading/searching, and YAML/JSON validation.-