VPS Docker MCP (Advanced)
VPS Docker MCP — 高级版
为 Claude Code 提供的 MCP 服务器,支持安全的 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: Docker/Hetzner MCP Server
安全模型
本项目有意不暴露任意 shell 执行。
没有:
ssh(command)
execute(command)
bash(command)相反,每个操作都是一个预定义的 MCP 工具。
诸如容器和服务名称等参数会通过严格的允许列表模式进行验证,并在插入命令前进行 shell 引用转义。
通过 VPS_KNOWN_HOSTS 启用 SSH 主机密钥检查。
使用专用的非 root SSH 账户(例如 deploy),并赋予其 Docker 访问权限。
要求
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=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_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
它不接受任意 shell 语法。
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,除非您有意接受风险,否则不要添加任意 shell 执行功能。
未来改进
下一步好的改进包括:
特定应用的健康检查
Docker 容器重启循环检测
OOM 检测
磁盘增长检测
systemd 服务重启工具
可配置的 Compose 项目允许列表
审计日志
每个工具的命令执行超时
独立的只读和写入 SSH 凭据
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseAqualityCmaintenanceEnables AI assistants to securely execute remote SSH commands, perform file transfers, and monitor system status through a standardized interface. It features robust security controls including command whitelisting, blacklisting, and credential isolation to prevent unauthorized operations.1022MIT
- Alicense-quality-maintenanceProvides tools for managing Docker containers, Compose stacks, and system resources on Hetzner servers via SSH. It also includes capabilities for reloading Caddy configurations and managing Cloudflare DNS records.
- Alicense-qualityDmaintenanceEnables LLMs to securely manage Virtual Private Servers via SSH, with features including command execution, file operations, system monitoring, and service management.MIT
- AlicenseAqualityAmaintenanceEnables AI assistants to perform controlled Linux system administration tasks like reading logs, managing services, cron jobs, WordPress, and executing sandboxed Python code, with strict security constraints.292GPL 2.0
Related MCP Connectors
Let AI operate servers without SSH. Choose actions, approve risky changes, and audit every step.
Operate Linux, macOS and Windows from your LLM. Every action runs through an auditable allowlist.
Execute PowerShell commands securely with controlled timeouts and input validation. Retrieve syste…
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/mordanov/vps_mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server