boxes-mcp
Enables management of GNOME Boxes virtual machines through libvirt/virsh with lifecycle and snapshot operations.
README
boxes-mcp
A lightweight Model Context Protocol (MCP) server that enables Claude Code to manage GNOME Boxes virtual machines through libvirt/virsh. Provides safe, reversible VM operations with comprehensive snapshot management.
Features
- 🖥️ VM Lifecycle Management - Start, stop, reboot, suspend, and resume VMs
- 📸 Snapshot Operations - Create, list, revert, and delete VM snapshots
- 🔍 VM Discovery - List and inspect all VMs with detailed information
- 🔒 Safe Operations - Storage preservation by default, no destructive actions
- 🎯 GNOME Boxes Compatible - Works seamlessly with GNOME Boxes VMs
- ⚡ Fast & Lightweight - Minimal overhead, direct virsh integration
Quick Start
Prerequisites
- Ubuntu 22.04/24.04 (or compatible Linux distribution)
- libvirt-daemon-system, qemu-kvm installed
- Node.js 18+ and npm
- User in
libvirtandkvmgroups
# Install dependencies
sudo apt install -y libvirt-daemon-system qemu-kvm virt-manager
# Add your user to required groups
sudo usermod -aG libvirt,kvm "$USER"
newgrp libvirt
Installation
# Clone the repository
git clone https://github.com/your-org/boxes-mcp.git
cd boxes-mcp
# Install dependencies
npm install
# Build the project
npm run build
# Run tests
npm test
Configuration
Add to your Claude Code config (~/.claude/config.json):
{
"mcpServers": {
"boxes": {
"command": "node",
"args": ["/absolute/path/to/boxes-mcp/dist/src/index.js"],
"env": {
"LIBVIRT_URI": "qemu:///system"
}
}
}
}
Available Tools
VM Management
| Tool | Description | Parameters |
|---|---|---|
boxes.list |
List all VMs | - |
boxes.info |
Get VM details | nameOrUuid: string |
boxes.start |
Start a VM | nameOrUuid: string |
boxes.shutdown |
Shutdown VM (graceful) | nameOrUuid: string, force?: boolean |
boxes.reboot |
Reboot a VM | nameOrUuid: string |
boxes.suspend |
Suspend a VM | nameOrUuid: string |
boxes.resume |
Resume suspended VM | nameOrUuid: string |
boxes.undefine |
Remove VM (keeps storage) | nameOrUuid: string, keepStorage?: boolean |
boxes.display |
Get SPICE/VNC address | nameOrUuid: string |
Snapshot Management
| Tool | Description | Parameters |
|---|---|---|
boxes.snapshots.list |
List VM snapshots | nameOrUuid: string |
boxes.snapshots.create |
Create snapshot | nameOrUuid: string, snapshot: string, description?: string |
boxes.snapshots.revert |
Revert to snapshot | nameOrUuid: string, snapshot: string |
boxes.snapshots.delete |
Delete snapshot | nameOrUuid: string, snapshot: string |
Usage Examples
With Claude Code
User: "List all my VMs"
Claude: [Uses boxes.list tool]
User: "Start ubuntu-24.04"
Claude: [Uses boxes.start with nameOrUuid="ubuntu-24.04"]
User: "Create a snapshot called 'before-update' for my fedora VM"
Claude: [Uses boxes.snapshots.create]
Direct Usage
# Run the MCP server
LIBVIRT_URI=qemu:///system node dist/src/index.js
Development
Project Structure
boxes-mcp/
├── src/
│ ├── index.ts # MCP server entry point
│ ├── libvirt.ts # virsh operations & parsers
│ ├── exec.ts # Safe command execution
│ ├── *.test.ts # Unit tests
├── systemd/
│ └── boxes-mcp.service # Systemd user service
├── dist/ # Compiled JavaScript
├── coverage/ # Test coverage reports
├── package.json
├── tsconfig.json
└── vitest.config.ts
Testing
# Run all tests
npm test
# Run tests in watch mode
npm run test:watch
# Generate coverage report
npm run test:coverage
Test Coverage: 33 tests, 100% passing
exec.ts: 100% statementslibvirt.ts: 81.3% statements, 92.85% branches- Comprehensive unit and integration tests
Building
# Build TypeScript
npm run build
# Watch mode for development
npm run dev
Systemd Service
Install as a user service for automatic startup:
mkdir -p ~/.config/systemd/user
cp systemd/boxes-mcp.service ~/.config/systemd/user/
sed -i "s|%h/projects/virtmcp|$HOME/boxes-mcp|g" ~/.config/systemd/user/boxes-mcp.service
systemctl --user daemon-reload
systemctl --user enable --now boxes-mcp
journalctl --user -fu boxes-mcp
Security Considerations
- ✅ Sandboxed Execution: Uses Node.js
execFilewith timeout and buffer limits - ✅ No Arbitrary Commands: Only predefined virsh operations allowed
- ✅ Storage Preservation: VM storage not deleted by default
- ✅ LIBVIRT_URI Isolation: Respects environment-specified libvirt connection
- ⚠️ Permissions Required: User must have libvirt group membership
- ⚠️ Network Exposure: Not designed for remote access without additional security
Troubleshooting
No VMs Listed
# Check libvirt URI
virsh -c qemu:///system list --all
virsh -c qemu:///session list --all
# Verify permissions
groups # Should include 'libvirt' and 'kvm'
Permission Denied
# Re-add to groups and re-login
sudo usermod -aG libvirt,kvm "$USER"
# Then logout/login or:
newgrp libvirt
VMs Not Showing in Boxes
Open virt-manager and check which connection your VMs use:
- System connection:
qemu:///system - User session:
qemu:///session
Set LIBVIRT_URI environment variable accordingly.
Roadmap
- [ ] VM creation via
virt-installintegration - [ ] Network management (
virsh net-list, port forwarding) - [ ] Storage pool information (
virsh vol-list) - [ ] VM import from OVA/QCOW2
- [ ] Remote libvirt connection support
- [ ] Performance metrics and monitoring
Contributing
Contributions welcome! Please read CONTRIBUTING.md for guidelines.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Run tests (
npm test) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- Built for Claude Code
- Uses Model Context Protocol SDK
- Integrates with libvirt virtualization API
Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: Project Wiki
Made with ❤️ for the Claude Code community
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。