Skip to main content
Glama
VPS Docker MCP (Advanced)

VPS Docker MCP (Advanced)

by mordanov

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 Compose

MCPサーバーはローカルで実行されます。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 tools

Related MCP server: dokku-mcp

セキュリティモデル

このプロジェクトは意図的に任意のシェル実行を公開しません。

以下はありません:

ssh(command)
execute(command)
bash(command)

代わりに、すべての操作は事前定義されたMCPツールです。

コンテナ名やサービス名などの引数は、制限的な許可リストパターンで検証され、コマンドに挿入される前にシェルクォートされます。

SSHホストキーの確認はVPS_KNOWN_HOSTSを通じて有効になります。

Dockerアクセス権を持つ専用の非root SSHアカウント(例:deploy)を使用してください。

必要条件

  • Python 3.11+

  • uv

  • SSHアクセス

  • 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=20000

SSHを個別にテスト:

ssh -i ~/.ssh/vps_mcp deploy@YOUR_VPS_IP docker ps

MCPをテスト:

uv run vps-docker-mcp

MCPの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ステータスを確認します:

/mcp

Claude Codeのバージョンによっては、MCPサーバーはClaude Code CLIでも管理できます。

ツールグループ

VPS診断

  • system_info

  • disk_usage

  • top_processes

  • network_info

  • systemd_failed

  • journal_errors

  • diagnose_vps

Docker読み取り専用

  • docker_ps

  • docker_logs

  • docker_inspect

  • docker_stats

  • docker_health

  • docker_images

  • docker_volumes

  • docker_networks

  • docker_disk_usage

Docker変更操作

  • docker_restart

  • docker_start

  • docker_stop

Docker Compose

読み取り専用:

  • docker_compose_ps

  • docker_compose_config

  • docker_compose_logs

変更操作:

  • docker_compose_restart

  • docker_compose_pull

  • docker_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 tools
diagnose_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

    B3.1/5.0

    Scored across 26 tools

    Disambiguation4/5

    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.

    Naming Consistency4/5

    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.

    Tool Count4/5

    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).

    Completeness3/5

    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

    Related MCP Servers

    • A
      license
      A
      quality
      C
      maintenance
      Enables MCP clients to inspect and manage a Dokku host over SSH with structured tools, read-only defaults, and explicit guardrails for safe operations.
      10
      MIT
    • F
      license
      Not graded
      quality
      B
      maintenance
      Enables 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.
      -