通过模型上下文协议(MCP)管理 Proxmox 虚拟环境(VE)基础设施的 115 种专用工具
Proxmox MCP 增强版提供了一个完整的模型上下文协议(MCP)服务器实现,用于管理 Proxmox 虚拟环境(VE)基础设施。通过涵盖 Proxmox 管理各个方面的一百一十五种专用工具,该服务器使 AI 助手和自动化系统能够无缝执行复杂的虚拟化任务。
Dict[str, Any]pip install proxmox-mcp-enhanced
git clone https://github.com/yourusername/proxmox-mcp-enhanced.git
cd proxmox-mcenhanced
pip install -e .
创建一个 .env 文件或设置以下环境变量:
# 必需 - 主机配置
PROXMOX_HOST=your-proxmox-host.example.com
PROXMOX_USER=root@pam
# 认证(选择一种方法)
# 方法 1:API 令牌(推荐)
PROXMOX_TOKEN_NAME=your-token-name
PROXMOX_TOKEN_VALUE=your-token-value
# 方法 2:密码
PROXMOX_PASSWORD=your-password
# 可选设置
PROXMOX_PORT=8006 # 默认值:8006
PROXMOX_VERIFY_SSL=true # 默认值:true
添加到您的 MCP 客户端配置中:
{
"mcpServers": {
"proxmox": {
"command": "proxmox-mcp",
"env": {
"PROXMOX_HOST": "your-host",
"PROXMOX_USER": "root@pam",
"PROXMOX_TOKEN_NAME": "token-name",
"PROXMOX_TOKEN_VALUE": "token-value"
}
}
}
}
# 创建新的虚拟机
{
"tool": "vm_create",
"arguments": {
"vmid": 100,
"node": "pve-node1",
"name": "test-vm",
"memory": 2048,
"cores": 2,
"storage": "local-lvm",
"disk_size": "10G"
}
}
# 启动虚拟机
{
"tool": "vm_start",
"arguments": {
"vmid": 100,
"node": "pve-node1"
}
}
# 创建 LXC 容器
{
"tool": "container_create",
"arguments": {
"vmid": 200,
"node": "pve-node1",
"ostemplate": "local:vztmpl/ubuntu-22.04-standard.tar.gz",
"hostname": "test-container",
"memory": 1024,
"cores": 1,
"rootfs": "local-lvm:8"
}
}
# 创建 Ceph 池
{
"tool": "ceph_pool_create",
"arguments": {
"name": "rbd-pool",
"size": 3,
"min_size": 2,
"pg_num": 128
}
}
# 创建 ZFS 数据集
{
"tool": "zfs_dataset_create",
"arguments": {
"name": "tank/datasets/test",
"pool": "tank",
"compression": "lz4",
"dedup": "off"
}
}
# 创建 VXLAN 区域
{
"tool": "sdn_zone_create",
"arguments": {
"zone": "vxlan-zone",
"type": "vxlan",
"peers": ["10.0.0.1", "10.0.0.2"],
"mtu": 1450
}
}
# 动态搜索操作系统 ISO
{
"tool": "iso_search",
"arguments": {
"os_name": "ubuntu",
"version": "22.04",
"variant": "server",
"architecture": "amd64"
}
}
# 直接下载 ISO 到 Proxmox 节点
{
"tool": "iso_download_direct",
"arguments": {
"url": "https://releases.ubuntu.com/22.04/ubuntu-22.04.5-live-server-amd64.iso",
"filename": "ubuntu-22.04-server.iso",
"node": "pve-node1",
"checksum_url": "https://releases.ubuntu.com/22.04/SHA256SUMS"
}
}
# 列出可用的 ISO
{
"tool": "iso_list_available",
"arguments": {
"storage": "local"
}
}
有关完整的 ISO 下载文档,请参阅 ISO_DOWNLOAD_GUIDE.md。
# 调度自动备份
{
"tool": "schedule_create",
"arguments": {
"name": "daily-backup",
"schedule": "0 2 * * *",
"command": "backup:all",
"node": "pve-node1"
}
}
# 生成性能报告
{
"tool": "performance_report",
"arguments": {
"analysis_type": "bottleneck",
"metrics": ["cpu", "memory", "disk", "network"],
"recommendations": true
}
}
proxmox-mcp-enhanced/
├── src/
│ └── proxmox_mcp/
│ ├── __init__.py # 工具注册(115 种工具)
│ ├── base.py # 基础 ToolHandler 类
│ ├── types.py # TypedDict 定义
│ ├── server.py # MCP 服务器实现
│ ├── api/
│ │ ├── __init__.py
│ │ └── client.py # Proxmox API 客户端
│ └── tools/
│ ├── vm_tools.py # 虚拟机管理
│ ├── container_tools_complete.py
│ ├── storage_tools_complete.py
│ ├── ceph_tools.py
│ ├── zfs_tools.py
│ └── ... (15 更多工具模块)
├── tests/
├── pyproject.toml
└── README.md
所有工具都使用严格的 TypedDict 定义:
class VMCreateArgs(TypedDict):
vmid: int
node: str
name: str
memory: Optional[int]
cores: Optional[int]
# ... 无 Dict[str, Any]!
pytest tests/
pytest --cov=proxmox_mcp tests/
# 格式化代码
black src/
# 类型检查
mypy src/
# 代码检查
ruff src/
git checkout -b feature/new-tool)Dict[str, Any])feat: 添加新工具)MIT 许可证 - 详情见 LICENSE 文件。
为 Proxmox 社区打造,充满爱心