LXD MCP Server
Enables AI assistants to manage LXD containers and virtual machines through a standardized MCP interface for lifecycle management, image operations, and server monitoring.
README
LXD MCP Server
A Model Context Protocol (MCP) server for managing LXD containers and virtual machines. Enable AI assistants to interact with LXD through a standardized interface for container lifecycle management, image operations, and server monitoring.
Prerequisites
- LXD: Daemon must be installed and running on the host
- Node.js: Version 20 or higher
- Socket Access: Server must run on the LXD host with access to the LXD Unix socket
Installation
Choose one of the following methods to install and run the LXD MCP Server.
Run as systemd service (recommended)
This is the recommended method for production use. The service runs automatically on boot and handles logging and auto-restart.
# Install the server globally
npm install -g lxd-mcp
# Copy the service file to systemd directory
sudo cp lxd-mcp.service /etc/systemd/system/
# Reload systemd to pick up the new service
sudo systemctl daemon-reload
# Start the service
sudo systemctl start lxd-mcp
# Enable auto-start on boot
sudo systemctl enable lxd-mcp
Run manually
If you prefer to run the server manually (for development or testing):
# Install globally
npm install -g lxd-mcp
# Run with default settings
lxd-mcp --port 3000
# Or run directly without installing
npx lxd-mcp --port 3000
⚠️ Important: LXD Group Membership Required
When running manually (not as a systemd service), your user must be a member of the
lxdgroup to access the LXD Unix socket. Without this, you'll get a "LXD socket not found" error.To add your user to the LXD group:
sudo usermod -a -G lxd $USERImportant: You must log out and log back in (or run
newgrp lxd) for group changes to take effect.
Agent Configuration
The LXD MCP Server exposes an HTTP endpoint at /mcp. Configure your AI agent to connect to it as a remote MCP server.
OpenCode
{
"mcp": {
"servers": {
"lxd": {
"type": "remote",
"url": "http://localhost:3000/mcp",
"enabled": true,
"headers": {
"Authorization": "Bearer {env:ACCESS_TOKEN}"
}
}
}
}
}
Claude Desktop and Claude Code
Claude supports remote MCP servers via the Connectors UI. Go to Settings > Connectors in claude.ai to add your server:
- Enter your MCP server URL:
http://localhost:3000/mcp - For authentication, configure OAuth or API key in the advanced settings
Alternatively, use the CLI command (Claude Code only):
claude mcp add --transport http lxd http://localhost:3000/mcp --env ACCESS_TOKEN="your-token"
Cursor
Add to your ~/.cursor/mcp.json:
{
"mcpServers": {
"lxd": {
"url": "http://localhost:3000/mcp",
"headers": {
"Authorization": "Bearer your-access-token"
}
}
}
}
Note: Replace http://localhost:3000/mcp with your server's actual URL if running remotely.
Example Prompts
Once configured, try asking your agent:
- "List all running LXD containers"
- "Create a new Ubuntu 22.04 container called web-server"
- "Start the test-container and run apt-get update inside it"
- "Show me the server resources (CPU, memory, disk)"
- "Create a profile for web server with 2 CPU cores and 4GB memory"
Environment Variables
| Variable | Default | Description |
|---|---|---|
LXD_SOCKET_PATH |
/var/snap/lxd/common/lxd/unix.socket |
Path to LXD Unix socket |
ACCESS_TOKEN |
(none) | Bearer token for API authentication |
LXD_PROJECTS |
(all) | Comma-separated list of allowed projects |
LOG_LEVEL |
info |
Logging level: debug, info, error |
PORT |
3000 |
Server HTTP port |
Security
Important: The server must run on the LXD host due to socket access requirements.
- Set
ACCESS_TOKENto enable bearer token authentication (recommended for network exposure) - Use
LXD_PROJECTSto restrict access to specific projects - See docs/security.md for detailed security guidance
Documentation
- Tools Reference - All MCP tool definitions and parameters
- Configuration - Environment variables, CLI flags, socket paths
- Security - Token setup, project restriction, best practices
- Troubleshooting - Common issues and solutions
- API Reference - LXD API endpoints used by this server
License
MIT License - see the LICENSE file for details.
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。