mcp-xcpng
README.md
# mcp-xcpng
A [Model Context Protocol (MCP)](https://modelcontextprotocol.io) server for **XCP-ng / Xen Orchestra**, providing AI assistants with full access to VM, host, storage, and snapshot management through the Xen Orchestra REST API.
## Features
**17 tools** across four categories:
### Virtual Machine Management
| Tool | Description |
|------|-------------|
| `list_vms` | List all VMs with name, power state, memory, CPU count, and host placement |
| `get_vm` | Get detailed VM information by UUID or XO object ID |
| `start_vm` | Start a halted or suspended VM |
| `stop_vm` | Clean or forced shutdown of a running VM |
| `suspend_vm` | Suspend a VM (saves memory state to disk) |
| `resume_vm` | Resume a suspended VM |
| `reboot_vm` | Clean or forced reboot of a running VM |
### Host Management
| Tool | Description |
|------|-------------|
| `list_hosts` | List all XCP-ng hypervisor hosts with CPU, memory, and version info |
| `get_host` | Get detailed host information by UUID or XO object ID |
| `get_host_stats` | Get CPU and memory usage statistics with configurable time granularity |
### Storage Management
| Tool | Description |
|------|-------------|
| `list_srs` | List all Storage Repositories with type, total, used, and free space |
| `get_sr` | Get detailed SR info including free/total space and utilization percentage |
| `list_vdis` | List Virtual Disk Images in a Storage Repository |
### Snapshot Management
| Tool | Description |
|------|-------------|
| `list_snapshots` | List VM snapshots, optionally filtered by VM |
| `create_snapshot` | Create a VM snapshot |
| `delete_snapshot` | Delete a snapshot (irreversible) |
| `revert_vm_to_snapshot` | Revert a VM to a previous snapshot state |
## Installation
```bash
git clone git@github.com:fredriksknese/mcp-xcpng.git
cd mcp-xcpng
npm install
npm run build
```
## Configuration
The server is configured via environment variables:
| Variable | Required | Default | Description |
|----------|----------|---------|-------------|
| `XO_HOST` | Yes | — | Xen Orchestra server hostname or IP |
| `XO_USERNAME` | Yes | — | Xen Orchestra username |
| `XO_PASSWORD` | Yes | — | Xen Orchestra password |
| `XO_ALLOW_SELF_SIGNED` | No | `true` | Accept self-signed SSL certificates |
## Usage with Claude Desktop
Add to your `claude_desktop_config.json`:
```json
{
"mcpServers": {
"xcpng": {
"command": "node",
"args": ["/absolute/path/to/mcp-xcpng/dist/index.js"],
"env": {
"XO_HOST": "your-xen-orchestra.example.com",
"XO_USERNAME": "admin@admin.net",
"XO_PASSWORD": "your-password"
}
}
}
}
```
## Usage with Claude Code
```bash
claude mcp add xcpng -- node /absolute/path/to/mcp-xcpng/dist/index.js
```
Set the required environment variables before running, or configure them in your MCP settings.
## Example Prompts
Once connected, you can ask your AI assistant things like:
- *"Show me all running VMs on the cluster"*
- *"What is the memory usage on host xcp-01?"*
- *"Create a snapshot of vm-web-01 called 'pre-upgrade'"*
- *"List all storage repositories and their free space"*
- *"Stop the VM named 'test-server' cleanly"*
- *"Show me all snapshots for VM abc-1234"*
- *"What are the CPU stats for host xcp-node-02 over the last week?"*
- *"Delete the snapshot named 'old-backup' from VM prod-db"*
- *"List all VMs that are currently halted"*
- *"How much free space is left on the NFS storage repository?"*
## API
This server targets the **Xen Orchestra REST API** (`/rest/v0/`), which is available in Xen Orchestra Community Edition (XO-CE) and the commercial Xen Orchestra appliance (XOA).
Authentication uses the session cookie mechanism: a `POST /rest/v0/session` with credentials returns a cookie that is used for all subsequent requests.
> **Note:** The Xen API (XAPI) XML-RPC interface is available directly on XCP-ng hosts at `https://{host}/RPC2` and uses `Session.login_with_password` for authentication. This server targets XO as the management layer instead, which provides a unified API across all hosts in a pool.
## Development
```bash
npm run dev # Run with tsx (auto-reloads)
npm run build # Compile TypeScript to dist/
npm start # Run compiled output
```
## Architecture
```
src/
├── index.ts # Entry point — creates MCP server + STDIO transport
├── xcpng-client.ts # HTTP client wrapping the Xen Orchestra REST API
└── tools/
├── vms.ts # VM lifecycle management (7 tools)
├── hosts.ts # Host info and statistics (3 tools)
├── storage.ts # Storage repositories and VDIs (3 tools)
└── snapshots.ts # Snapshot CRUD and revert (4 tools)
```
## Requirements
- Node.js 18+
- Xen Orchestra (XOA or XO-CE) with REST API enabled
- XCP-ng hypervisor hosts managed by Xen Orchestra
## License
SEE LICENSE IN LICENSE
This server cannot be deployed
Maintenance
ActivityInactive
ResponsivenessNo recent community issues