A Model Context Protocol (MCP) server for XenServer/XCP-ng administration. This server enables AI assistants to interact with XenServer infrastructure through natural language.
- Multi-cluster support: Manage multiple XenServer clusters from a single server
- Comprehensive VM management: List, control, snapshot, and monitor virtual machines
- Host management: Monitor and manage XenServer hosts
- Storage operations: List and manage storage repositories and virtual disks
- Network management: View and manage network configurations
- Pool management: Get pool information and statistics
- Template management: List and work with VM templates
# Pull from GitHub Container Registry
docker pull ghcr.io/acefei/xenserver-mcp:latest
# Or build locally
docker build -t xenserver-mcp .# Install using uv
uv pip install -e .
# Or using pip
pip install -e .Create a configuration file at config/clusters.json in the project directory:
# Copy the example configuration
cp config/clusters.json.example config/clusters.json
# Edit with your credentials
nano config/clusters.jsonExample configuration:
{
"production": {
"host": "xenserver1.example.com",
"username": "root",
"password": "your-secure-password"
},
"development": {
"host": "xenserver2.example.com",
"username": "root",
"password": "another-password"
}
}Security Note: Ensure this file has restricted permissions and is not committed to version control:
chmod 600 config/clusters.json# Run the Docker container
docker run -i --rm \
-v $(pwd)/config:/app/config:ro \
ghcr.io/acefei/xenserver-mcp:latest# Run with default configuration
xenserver-mcp
# Or run directly
python -m xenserver_mcp.server
# Set default cluster via environment variable
XENSERVER_CLUSTER=production xenserver-mcpAdd to your Claude Desktop configuration (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):
Using Docker:
{
"mcpServers": {
"xenserver": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-v",
"/path/to/your/config:/app/config:ro",
"ghcr.io/acefei/xenserver-mcp:latest"
]
}
}
}Using Local Installation:
{
"mcpServers": {
"xenserver": {
"command": "xenserver-mcp",
"env": {
"XENSERVER_CLUSTER": "production"
}
}
}
}list_clusters- List all configured XenServer clustersconnect_cluster- Connect to a specific clusterget_current_cluster- Show current cluster connection
list_vms- List all VMs (with filters for templates/snapshots)get_vm_info- Get detailed VM informationvm_power_control- Control VM power state (start, shutdown, reboot, suspend, resume)create_vm_snapshot- Create VM snapshots
list_hosts- List all hosts in the poolget_host_info- Get detailed host information
list_storage_repositories- List all storage repositorieslist_virtual_disks- List virtual disk images
list_networks- List all networks in the pool
get_pool_info- Get resource pool information and statistics
list_templates- List all VM templates
User: Connect to the production cluster
Assistant: [Calls connect_cluster with cluster_id="production"]
Successfully connected to cluster: production (xenserver1.example.com)
User: Show me all running VMs
Assistant: [Calls list_vms]
Found 5 virtual machines:
- web-server-01 (UUID: xxx-xxx-xxx)
Power State: Running
vCPUs: 4, Memory: 8.00 GB
...
User: Get detailed info about web-server-01
Assistant: [Calls get_vm_info with vm_identifier="web-server-01"]
VM Information: web-server-01
UUID: xxx-xxx-xxx
Power State: Running
...
User: Create a snapshot of web-server-01 before the upgrade
Assistant: [Calls create_vm_snapshot]
Created snapshot 'pre-upgrade-snapshot' for VM 'web-server-01'
Snapshot UUID: yyy-yyy-yyy
User: Reboot the VM
Assistant: [Calls vm_power_control with action="reboot"]
Initiated clean reboot of VM: web-server-01
User: Show me the storage situation
Assistant: [Calls list_storage_repositories]
Found 2 storage repository(ies):
- Local Storage (UUID: aaa-aaa-aaa)
Type: lvm
Size: 1000.00 GB
Used: 650.00 GB (65.0%)
Free: 350.00 GB
...
User: What's the pool status?
Assistant: [Calls get_pool_info]
Pool Information: Production Pool
Total Hosts: 3
Total VMs: 25
Running VMs: 20
HA Enabled: True
The server follows best practices from production MCP implementations:
- Persistent connections with automatic reconnection
- Session validation before each operation
- Clean shutdown and resource cleanup
- Graceful degradation on connection failures
- Detailed error messages with context
- Automatic session invalidation on errors
- Comprehensive logging for debugging
- Separate info/error log levels
- Operation tracking for audit trails
- Single-purpose, focused tools
- Consistent parameter naming
- Structured output formatting
- Clear error messages
xsmcp/
├── config/
│ ├── clusters.json.example # Example cluster configuration
│ └── clusters.json # Your actual config (gitignored)
├── src/
│ ├── xenserver_mcp/
│ │ ├── __init__.py
│ │ └── server.py
│ └── xen_api/ # XenAPI object-oriented middleware
├── docs/
│ ├── configuration.md
│ └── quickstart.md
├── examples/
│ └── basic_usage.py
├── pyproject.toml
└── README.md
# Install dev dependencies
uv pip install -e ".[dev]"
# Run linting
ruff check src/
# Format code
ruff format src/If you see "Not connected to any cluster":
- Verify
config/clusters.jsonexists and is valid JSON - Check cluster credentials are correct
- Ensure XenServer host is reachable
- Verify firewall allows HTTPS (443) connections
The server automatically reconnects on session timeout. If persistent:
- Check XenServer logs for authentication issues
- Verify user account has appropriate permissions
- Check for network instability
Ensure the XenServer user has appropriate permissions:
- Pool Admin role for full management
- VM Admin role for VM operations only
- Read-only role for monitoring
-
Credential Storage: Configuration file contains plaintext passwords
- Use restricted file permissions (600)
- Never commit
config/clusters.jsonto version control - Consider using environment variables for CI/CD
- Keep config/ directory in .gitignore
-
Network Security: All communication is over HTTPS
- Verify SSL certificates in production
- Use VPN for remote access
-
Audit Logging: All operations are logged
- Review logs regularly
- Monitor for unexpected operations
Contributions are welcome! Please:
- Follow the existing code style (ruff formatting)
- Add tests for new features
- Update documentation
- Submit pull requests
[Your chosen license]
For issues and questions:
- GitHub Issues: [Your repo URL]
- Email: [email protected]
Based on best practices from:
- blender-mcp - MCP server architecture patterns
- XenAPI - XenServer API documentation
- Model Context Protocol - MCP specification