vcenter-mcp
vcenter-mcp
一个 Model Context Protocol 服务器,用于向 Claude Code 和其他 MCP 客户端公开 VMware vCenter / ESXi 虚拟机生命周期管理工具。基于 pyVmomi 构建。
功能
列出 vCenter 数据中心(按主机分组)或独立 ESXi 主机上的虚拟机
创建虚拟机(优先网络启动;支持精简或厚置备;ESXi 目标支持嵌套虚拟化选项)
虚拟机开关机
删除虚拟机(若正在运行则先关机,然后从磁盘销毁)
查找时可接受显示名称或 moref ID(例如 vm-42)——使用 moref 路径可跳过清单扫描,在大型环境中速度更快。
Related MCP server: VMWare MCP
前置要求
Python 3.10 或更高版本
可通过网络访问的 vCenter Server 或独立 ESXi 主机
拥有执行所需操作权限的 vSphere 账户(
list_vms仅需只读权限;创建/删除操作需要相应的虚拟机和资源池权限)
安装
安装到项目本地的虚拟环境中。使用 venv 可以将 vcenter-mcp 及其依赖项(主要是 pyVmomi)与系统 Python 隔离开来。
从本仓库克隆后安装:
python3 -m venv .venv
.venv/bin/pip install --upgrade pip
.venv/bin/pip install -e .开发环境安装(同时安装 pytest):
.venv/bin/pip install -e ".[dev]"在本 README 中,命令均使用
.venv/bin/...。你也可以在每个 shell 中执行一次source .venv/bin/activate并省略前缀——效果相同。
配置目标
使用虚拟环境的 Python 运行交互式设置:
.venv/bin/python -m vcenter_mcp setup系统将提示你输入:
目标名称(例如
lab-vcenter)——用于后续引用此目标vCenter / ESXi 的主机名或 IP
用户名和密码
目标类型:
vcenter或esxi(仅 vCenter) 数据中心和集群名称
数据存储名称
一个或多个网络配置文件,每个包含一个名称以及一个或多个端口组名称
设置程序会将配置写入 ~/.config/vcenter-mcp/config.json(模式 0600)。你可以随时重新运行以添加新目标或更新现有目标。
配置文件结构
{
"default_target": "lab-vcenter",
"targets": {
"lab-vcenter": {
"host": "vcenter.lab.example.com",
"user": "admin@vsphere.local",
"password": "...",
"type": "vcenter",
"datacenter": "Lab DC",
"cluster": "Lab Cluster",
"datastore": "datastore1",
"networks": {
"standard": ["VM Network"],
"secure-boot": ["pg-secure-1", "pg-secure-2"]
},
"default_network": "standard"
}
},
"templates": {
"esxi": { "cpu": 4, "ram_mb": 16384, "disk_gb": 100, "disk_provisioning": "thin", "guest_id": "vmkernel7Guest", "vhv": true },
"ubuntu": { "cpu": 2, "ram_mb": 4096, "disk_gb": 40, "disk_provisioning": "thin", "guest_id": "ubuntu64Guest", "vhv": false },
"rhel": { "cpu": 2, "ram_mb": 4096, "disk_gb": 40, "disk_provisioning": "thin", "guest_id": "rhel9_64Guest", "vhv": false }
}
}网络配置文件是端口组的列表;第一个条目将成为启动网卡。要添加自定义虚拟机类型,请在 templates 中添加条目——传递给 create_vm 的 vm_type 字符串将与此字典进行匹配。
在 Claude Code 中注册
使用虚拟环境的 Python 通过绝对路径注册 MCP 服务器。Claude Code 会在一个全新的 shell 中启动服务器,该 shell 不会 继承你已激活的 venv,因此必须使用绝对路径——在此处指向普通的 python 将导致无法导入 vcenter_mcp。
VCENTER_MCP_DIR="$(pwd)" # run this from the repo root, after install
claude mcp add --scope user vcenter -- "$VCENTER_MCP_DIR/.venv/bin/python" -m vcenter_mcp或者直接内联你想要的绝对路径:
claude mcp add --scope user vcenter -- /absolute/path/to/vcenter-mcp/.venv/bin/python -m vcenter_mcp读取工具(list_vms)可以安全地允许而不进行提示。将其添加到 ~/.claude/settings.json 中的 permissions.allow:
{
"permissions": {
"allow": [
"mcp__vcenter__list_vms"
]
}
}破坏性工具(create_vm、power_on_vm、power_off_vm、delete_vm)默认不在允许列表中——Claude 会在每次调用时提示你。
工具
工具 | 功能 |
| 列出目标上的虚拟机。vCenter 目标按数据中心内的主机分组;ESXi 目标列出主机上的所有内容。 |
| 创建一个优先网络启动的虚拟机。选择一个 |
| 通过显示名称或 moref ID 开启虚拟机。 |
| 通过显示名称或 moref ID 强制关闭虚拟机。 |
| 永久删除虚拟机(若正在运行则先关机,然后从磁盘销毁)。 |
关于 TLS 的说明
vcenter-mcp 使用未验证的 SSL 上下文进行连接,这与 govc 和大多数 pyVmomi 示例代码使用的默认设置相同,因为实验室 vCenter 通常使用自签名证书。如果你的目标使用正确签名的证书,并且你希望进行真正的验证,请替换 src/vcenter_mcp/client.py 中的 _ssl_context()。
开发
python3 -m venv .venv
.venv/bin/pip install -e ".[dev]"
.venv/bin/pytest测试在 CI 中的 Python 3.10、3.11 和 3.12 上运行(参见 .github/workflows/test.yml)。
许可证
Available Tools
5 toolscreate_vmA
Create a VM that network boots first. vm_type: esxi, ubuntu, rhel (or any type defined in config templates). disk_provisioning: thin (default) or thick. network_profile: named profile from target config (e.g. standard, secure-boot).
Inputs: name (required), vm_type (required), target, network_profile, +4 more. Returns: result
delete_vmA
Permanently delete a VM (power off if running, then destroy from disk). Accepts display name or moref ID (e.g. 'vm-42').
Inputs: name_or_id (required), target. Returns: result
list_vmsA
List VMs on a target.
Standalone ESXi: lists all VMs on the host.
vCenter: groups VMs by host within the specified datacenter (defaults to the target's configured datacenter).
Inputs: target, datacenter. Returns: result
power_off_vmB
Hard power off a VM by display name or moref ID (e.g. 'vm-42').
Inputs: name_or_id (required), target. Returns: result
power_on_vmA
Power on a VM by display name or moref ID (e.g. 'vm-42').
Inputs: name_or_id (required), target. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 5 tools
Each tool has a clearly distinct purpose: create, delete, list, power on, power off. No overlap in functionality.
All tools follow a consistent verb_noun pattern in snake_case (create_vm, delete_vm, list_vms, power_off_vm, power_on_vm). Minor plural variation for list_vms is acceptable.
5 tools cover the essential VM lifecycle operations without being excessive or insufficient for a vCenter MCP server.
Missing common operations like get single VM details, update VM configuration, clone, or snapshot management. Basic CRUD and power actions are present but gaps exist for full lifecycle management.
Related MCP Connectors
Create, list and destroy hourly-billed servers on Vultr, DigitalOcean, Hetzner and Linode.
Provides capabilities that let LLM agents perform a range of infrastructure management tasks.
Create, power on or off and delete Kubana Cloud VPS servers, and check CPU, memory and disk.
Manage American Cloud VMs, Kubernetes, databases, storage, networks and DNS from your AI assistant.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables AI agents to manage VMware vSphere virtual infrastructure through comprehensive operations including VM power control, snapshot management, resource monitoring, performance analytics, and bulk operations with built-in safety confirmations for destructive actions.-
- FlicenseNot gradedqualityCmaintenanceEnables AI agents to manage VMware vSphere infrastructure through 55 typed tools built on the govc CLI. It supports comprehensive operations including VM lifecycle management, snapshot control, datastore navigation, and networking configuration.5-
- AlicenseAqualityAmaintenanceAI-powered VMware vCenter/ESXi monitoring and operations. 20 MCP tools for inventory queries, health monitoring, VM lifecycle management, fast provisioning (Linked Clone, OVA, template deploy), snapshot management, and datastore browsing. Supports vSphere 6.5–8.0. Works with local models via Ollama/LM Studio.44566 PyPI87MIT
- AlicenseNot gradedqualityCmaintenanceEnables natural language interaction with VMware SDDC Manager and vCenter APIs through MCP tools, allowing users to query workload domains, VMs, clusters, and more.MIT