VPS Docker MCP (Advanced)
VPS Docker MCP — 高度な
Claude Code用のMCPサーバーで、SSH経由で安全なVPS診断とDocker/Docker Compose管理を提供します。
アーキテクチャ
Claude Code
|
| MCP / stdio
v
Local Python MCP server
|
| SSH / AsyncSSH
v
VPS
|
+-- systemd
+-- Docker
+-- Docker ComposeMCPサーバーはローカルで実行されます。VPS上で待ち受ける必要はありません。
モジュール構成
src/vps_docker_mcp/
├── server.py # MCP instance, wires modules together
├── ssh.py # SSH config, run_ssh/run_many helpers
├── docker.py # Docker and Docker Compose tools
└── infrastructure.py # VPS diagnostics toolsRelated MCP server: dokku-mcp
セキュリティモデル
このプロジェクトは意図的に任意のシェル実行を公開しません。
以下はありません:
ssh(command)
execute(command)
bash(command)代わりに、すべての操作は事前定義されたMCPツールです。
コンテナ名やサービス名などの引数は、制限的な許可リストパターンで検証され、コマンドに挿入される前にシェルクォートされます。
SSHホストキーの確認はVPS_KNOWN_HOSTSを通じて有効になります。
Dockerアクセス権を持つ専用の非root SSHアカウント(例:deploy)を使用してください。
必要条件
Python 3.11+
uvSSHアクセス
VPS上のDocker
Composeツールを使用する場合はDocker Compose v2
Dockerを実行する権限を持つ
deployユーザー
インストール
uv sync設定:
cp .env.example .env例:
VPS_HOST=YOUR_VPS_IP
VPS_PORT=22
VPS_USER=deploy
VPS_SSH_KEY=~/.ssh/vps_mcp
VPS_KNOWN_HOSTS=~/.ssh/known_hosts
DOCKER_COMPOSE_DIR=/opt/news-bot
MAX_OUTPUT_CHARS=20000SSHを個別にテスト:
ssh -i ~/.ssh/vps_mcp deploy@YOUR_VPS_IP docker psMCPをテスト:
uv run vps-docker-mcpMCPのstdio入力を待機します。これは想定された動作です。
Claude Codeの設定
.mcp.json.exampleをClaude Codeが使用するプロジェクトレベルの.mcp.jsonにコピーし、絶対パスを置き換えてください。
例:
{
"mcpServers": {
"vps-docker": {
"type": "stdio",
"command": "uv",
"args": [
"--directory",
"/home/me/projects/vps-docker-mcp-advanced",
"run",
"vps-docker-mcp"
]
}
}
}その後、Claude Codeを起動/再起動し、次のコマンドでMCPステータスを確認します:
/mcpClaude Codeのバージョンによっては、MCPサーバーはClaude Code CLIでも管理できます。
ツールグループ
VPS診断
system_infodisk_usagetop_processesnetwork_infosystemd_failedjournal_errorsdiagnose_vps
Docker読み取り専用
docker_psdocker_logsdocker_inspectdocker_statsdocker_healthdocker_imagesdocker_volumesdocker_networksdocker_disk_usage
Docker変更操作
docker_restartdocker_startdocker_stop
Docker Compose
読み取り専用:
docker_compose_psdocker_compose_configdocker_compose_logs
変更操作:
docker_compose_restartdocker_compose_pulldocker_compose_up
制限付き診断
diagnostic_commandは固定リストのみ許可します:
pwd
whoami
date
df
free
uptime
docker_version
docker_info
任意のシェル構文は受け付けません。
Claude Codeリクエストの例
Check the VPS health.Claudeは以下を使用できます:
diagnose_vps壊れたコンテナの場合:
Find out why news-bot is unhealthy.有用な診断シーケンスは次のとおりです:
docker_health
docker_ps
docker_logs
docker_stats
docker_inspect一般的なリソース問題の場合:
Check whether the VPS is running out of RAM or disk space.Claudeは以下を検査できます:
system_info
disk_usage
top_processes
docker_stats
docker_disk_usage次に:
Restart news-bot if the diagnosis indicates that a restart is appropriate.再起動操作は別の変更ツールです。
本番環境での重要な推奨事項
変更操作については、Claude Code自身の許可/承認メカニズムを有効にしておいてください。
MCPサーバーは変更ツールの説明に意図的にラベルを付けていますが、MCP自体を認証境界として扱うべきではありません。
本番VPSでは、意図的にリスクを受け入れない限り、任意のシェル実行を追加しないでください。
今後の改善点
次に追加すると良いもの:
アプリケーション固有のヘルスチェック
Dockerコンテナの再起動ループ検出
OOM検出
ディスク増加検出
systemdサービス再起動ツール
Composeプロジェクトの設定可能な許可リスト
監査ログ
ツールごとのコマンド実行タイムアウト
読み取り専用と書き込み用のSSH認証情報の分離
Available Tools
26 toolsdiagnose_vpsA
Run a compact VPS health check covering resources, disk, systemd and Docker.
Inputs: no named parameters. Returns: result
diagnostic_commandB
Run one of a small predefined set of read-only diagnostic commands.
Inputs: command (required). Returns: result
disk_usageB
Show filesystem space and inode usage.
Inputs: no named parameters. Returns: result
docker_compose_configB
Render and validate the Docker Compose configuration.
Inputs: no named parameters. Returns: result
docker_compose_logsB
Show Docker Compose logs, optionally for one service.
Inputs: tail, service. Returns: result
docker_compose_psC
Show Docker Compose services.
Inputs: no named parameters. Returns: result
docker_compose_pullB
Pull Docker Compose images. This changes local Docker image state.
Inputs: no named parameters. Returns: result
docker_compose_restartB
Restart Docker Compose services. This changes server state.
Inputs: service. Returns: result
docker_compose_upA
Start/update the Docker Compose stack with detached mode. This changes server state.
Inputs: no named parameters. Returns: result
docker_disk_usageB
Show Docker disk usage.
Inputs: no named parameters. Returns: result
docker_healthB
Show container state, restart count and health status.
Inputs: container (required). Returns: result
docker_imagesB
List Docker images.
Inputs: no named parameters. Returns: result
docker_inspectC
Inspect a Docker container.
Inputs: container (required). Returns: result
docker_logsC
Show recent logs from a Docker container.
Inputs: container (required), tail. Returns: result
docker_networksB
List Docker networks.
Inputs: no named parameters. Returns: result
docker_psA
List Docker containers. Set all_containers=true to include stopped containers.
Inputs: all_containers. Returns: result
docker_restartB
Restart a Docker container. This changes server state.
Inputs: container (required). Returns: result
docker_startB
Start a Docker container. This changes server state.
Inputs: container (required). Returns: result
docker_statsA
Show current CPU, memory, network and block I/O usage of containers.
Inputs: no named parameters. Returns: result
docker_stopC
Stop a Docker container. This changes server state.
Inputs: container (required). Returns: result
docker_volumesB
List Docker volumes.
Inputs: no named parameters. Returns: result
journal_errorsC
Show recent system journal errors.
Inputs: hours, lines. Returns: result
network_infoB
Show network interfaces, routes and listening TCP/UDP ports.
Inputs: no named parameters. Returns: result
systemd_failedA
Show failed systemd services.
Inputs: no named parameters. Returns: result
system_infoA
Show VPS uptime, OS, CPU, memory, swap, load and kernel information.
Inputs: no named parameters. Returns: result
top_processesC
Show processes consuming the most CPU and memory.
Inputs: limit. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 26 tools
Most tools have clearly distinct purposes (e.g., docker_ps vs docker_inspect, system_info vs disk_usage). However, diagnose_vps overlaps with several individual system tools, and diagnostic_command is vague, creating some ambiguity.
Tools follow snake_case with clear prefixes (docker_, docker_compose_, system_, etc.). Docker tools use verb_noun pattern, but system tools are mostly noun_noun (e.g., system_info, disk_usage). This mix is not fully consistent but still readable.
26 tools is on the higher side but appropriate for the 'Advanced' scope covering Docker, Docker Compose, and VPS diagnostics. The set is well-scoped, though a few tools could be merged (e.g., diagnose_vps and individual checks).
The tool surface covers monitoring and basic state changes for Docker and VPS, but lacks container creation/removal, Docker Compose down, and deeper system management. The diagnostic_command is undefined. Notable gaps exist for a truly 'Advanced' server.
Related MCP Connectors
Linux server administration over OAuth MCP: shell, Docker, systemd, files and monitoring.
- browser-sshDeprecatedcom.browserssh
Scoped, audited SSH exec, sessions, and SFTP on your saved servers without exposing credentials
Manage remote servers, SSH terminals, files, databases and proxies with scoped access and approvals.
Let AI operate servers without SSH. Choose actions, approve risky changes, and audit every step.
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables secure, read-only inspection of a VPS over SSH through approved operations such as system health, disk usage, container logs, and service status, without giving the AI unrestricted shell access.81MIT
- AlicenseAqualityCmaintenanceEnables MCP clients to inspect and manage a Dokku host over SSH with structured tools, read-only defaults, and explicit guardrails for safe operations.10MIT
- 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.-
- AlicenseNot gradedqualityBmaintenanceEnables read-only inspection and confirmed mutation operations on a single VPS over SSH, including host health, Docker, Compose, Swarm, firewall, and system debugging tools.36 npm1MIT