docker-vm-mcp
An MCP server that provides full lifecycle management of lightweight VMs backed by Docker containers, enabling creation, SSH access, command execution, and resource monitoring through natural language.
README
docker-vm-mcp
Built by sundar.
An MCP server that gives an AI agent full VM lifecycle control — create, SSH
login, exec commands, stop/start/restart, delete, logs, and resource stats —
over lightweight "VMs" backed by Docker containers. Each VM is a real Ubuntu
system running an actual sshd, with sudo and a persistent disk, so it
behaves like a normal box you can log into — no cloud account and no nested
virtualization required. The server itself is containerized and published as
a Docker image, and is driven entirely through the Model Context Protocol.
Once this is set up you can just ask Claude things like:
- "Create a VM called dev-box with 2 CPUs and 2GB RAM"
- "SSH me into dev-box" / "What's the SSH login for dev-box?"
- "Install nginx on dev-box and start it"
- "Stop dev-box" / "Delete dev-box"
- "List all my VMs"
and Claude will drive the whole lifecycle through the tools below.
How it works
Each "VM" is a Docker container built from a small Ubuntu 22.04 image
(vm-image/Dockerfile) that runs a real sshd, has sudo, and gets a named
Docker volume mounted as its home directory (so files survive stop/restart,
similar to an EBS volume attached to an EC2 instance). The MCP server itself
talks to your local Docker daemon over /var/run/docker.sock — it does not
run VMs itself, it drives your existing Docker Desktop installation.
Claude <--MCP/stdio--> docker-vm-mcp container <--docker.sock--> Docker Desktop
|
vm-dev-box (Ubuntu + sshd)
vm-staging (Ubuntu + sshd)
...
Prerequisites
- Docker Desktop installed and running on your Mac
- Node.js 20+ only if you want to run the server outside Docker (not required)
1. Build
From this folder:
docker build -t docker-vm-mcp:latest .
This builds only the MCP server image. The VM base image
(docker-vm-mcp/vm-base:latest) is built automatically the first time you
call vm_create — the server bundles vm-image/Dockerfile and builds it
against your Docker daemon on first use. You can also pre-build it yourself:
docker build -t docker-vm-mcp/vm-base:latest ./vm-image
2. Run / register with Claude Desktop
MCP servers over stdio are launched by the client (Claude Desktop), not run
standalone. Add this to your Claude Desktop config
(~/Library/Application Support/Claude/claude_desktop_config.json):
{
"mcpServers": {
"docker-vm-mcp": {
"command": "docker",
"args": [
"run", "-i", "--rm",
"-v", "/var/run/docker.sock:/var/run/docker.sock",
"-v", "docker-vm-mcp-state:/data",
"docker-vm-mcp:latest"
]
}
}
}
Then restart Claude Desktop. The two mounts are both required:
/var/run/docker.sock— lets the server create/start/stop/exec into VM containers on your machine.docker-vm-mcp-state(a named volume) — where the server remembers each VM's generated SSH password across restarts. Without it,vm_ssh_infoloses saved passwords whenever the MCP server container restarts (the VM containers themselves are unaffected — they keep running).
You can sanity-check the image runs and can reach Docker before wiring it into Claude Desktop:
docker run -i --rm \
-v /var/run/docker.sock:/var/run/docker.sock \
-v docker-vm-mcp-state:/data \
docker-vm-mcp:latest
# should print nothing and just wait on stdin (that's correct — it's
# speaking MCP, not a REPL). Ctrl+C to exit.
Tools this server exposes
| Tool | What it does |
|---|---|
vm_create |
Create + start a new VM. Params: name, cpus, memoryMb, sshPort, sshUser, sshPublicKey. Returns the SSH command and generated password. |
vm_list |
List all managed VMs with status and SSH port. |
vm_start |
Start a stopped VM. |
vm_stop |
Stop a running VM (disk is preserved). |
vm_restart |
Reboot a VM. |
vm_delete |
Permanently delete a VM (and its disk volume, unless removeVolume=false). |
vm_exec |
Run a shell command inside a VM directly via Docker (no SSH needed). |
vm_ssh_info |
Get the SSH command, host, port, user, and password for a VM. |
vm_set_password |
Set or regenerate a VM's SSH password (also resyncs vm_ssh_info after a manual password change). |
vm_logs |
Tail a VM's console/system log output. |
vm_stats |
Live CPU % / memory usage for a running VM. |
Logging in yourself
Every VM binds its SSH port to your Mac, so once Claude creates one you can also just SSH in directly from a terminal:
ssh vmuser@localhost -p <port> # port and password from vm_create / vm_ssh_info
Pass sshPublicKey to vm_create (your ~/.ssh/id_ed25519.pub contents) to
skip the password and log in with your key instead.
Publishing this image
To share it (e.g. so a teammate or another machine can just docker pull
instead of building from source):
docker tag docker-vm-mcp:latest <your-dockerhub-username>/docker-vm-mcp:latest
docker push <your-dockerhub-username>/docker-vm-mcp:latest
Nothing secret is baked into the image — credentials are generated per-VM at
runtime and stored only in the local docker-vm-mcp-state volume on
whichever machine runs the container. It's safe to publish.
Security notes (read before exposing this beyond your own machine)
- The Docker socket mount is root-equivalent. Anything with access to
/var/run/docker.sockcan control every container on your machine, not just the VMs this tool creates. Only run this image with that mount on a machine you trust, and never expose the MCP server itself (or a port to it) to untrusted callers. - SSH passwords are stored in plaintext in the
docker-vm-mcp-statevolume (/data/credentials.json) sovm_ssh_infocan hand them back to you later. That's fine for a personal local dev tool; don't repurpose this for multi-tenant or production use without hardening it (e.g. switch to key-only auth and stop persisting passwords). - VM containers publish their SSH port on
0.0.0.0by default (Docker's default), meaning other devices on your local network could reach it if your firewall allows it. Pass an explicitsshPortand firewall it, or bind to127.0.0.1only, if that matters to you (edit thePortBindingshost IP insrc/tools/createVm.tsto127.0.0.1and rebuild).
Real-world validation: ServiceNow Discovery
This project has been used as a live Discovery target for a real ServiceNow instance, via a locally-run MID Server (also Dockerized) — proof it behaves like a genuine SSH-reachable Linux host, not just a toy:
- Standard Discovery, MID Server → VM over the Mac's LAN IP and the VM's
published SSH port (e.g.
192.168.x.x:<port>) — successfully created acmdb_ci_linux_serverCI with hostname, OS, RAM, and CPU details pulled live over SSH. - Quick Discovery also works the same way.
- Since the MID Server container and the VM container both sit on Docker's
default
bridgenetwork, they can alternatively reach each other directly by internal container IP on the standard SSH port (22) — no published port needed, and no dependency on the Mac's LAN IP (which changes across networks). - One quirk worth knowing if you try this yourself: discovered CPU
manufacturer shows as "Apple". That's correct, not a bug — Docker
Desktop for Mac runs containers inside a
linuxkitVM booted directly on the host's own Apple Silicon chip, so SSH probes reading/proc/cpuinfosee the real hardware underneath, the same as they would on any other host.
Project structure
docker-vm-mcp/
├── Dockerfile # MCP server image
├── package.json
├── tsconfig.json
├── vm-image/
│ └── Dockerfile # base "VM" image (Ubuntu + sshd), built on first vm_create
└── src/
├── index.ts # MCP server entrypoint (stdio transport)
├── docker.ts # Docker client, image-build, container lookup helpers
├── state.ts # local credential store (/data/credentials.json)
├── util.ts # exec/log demuxing helpers
└── tools/
├── createVm.ts
├── listVms.ts
├── startVm.ts
├── stopVm.ts
├── restartVm.ts
├── deleteVm.ts
├── execVm.ts
├── sshInfo.ts
├── setPassword.ts
├── logsVm.ts
└── statsVm.ts
A note on how this was verified
This was built and type-checked in a sandboxed environment without access to
the npm registry, so npm install / npm run build could not be run
end-to-end here. The TypeScript was checked against Node's own type
definitions with no errors; the only remaining checks are against
@modelcontextprotocol/sdk, dockerode, and zod's own types, which
weren't installable in that sandbox. Run this once after copying the project
to your Mac, before your first docker build:
npm install
npm run build
If tsc reports anything beyond what's already handled above, it's most
likely a version-specific API shift in @modelcontextprotocol/sdk (it's a
fast-moving package) — the fix is almost always a small adjustment to the
import paths in src/index.ts (@modelcontextprotocol/sdk/server/mcp.js /
.../server/stdio.js) to match whatever version npm install resolved.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。
mcp-server-qdrant
这个仓库展示了如何为向量搜索引擎 Qdrant 创建一个 MCP (Managed Control Plane) 服务器的示例。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。