pi-controller-mcp
MCP server for managing Raspberry Pi K3s clusters via AI assistants like Claude Code.
README
pi-controller-mcp
MCP (Model Context Protocol) server for managing Raspberry Pi K3s clusters via AI assistants like Claude Code.
Features
- 🎯 26 AI Tools for complete cluster lifecycle management
- 📊 7 Resources providing real-time cluster context
- 🔐 Secure Authentication with JWT and API keys
- 🛡️ RBAC Integration respecting viewer/operator/admin roles
- 🔌 GPIO Control for hardware management
- 📦 Zero Configuration works out of the box with npx
Quick Start
1. Configure Claude Code
Add to your ~/.config/claude-code/mcp.json (or project .mcp.json):
{
"mcpServers": {
"pi-controller": {
"command": "npx",
"args": ["-y", "pi-controller-mcp"],
"env": {
"PI_CONTROLLER_URL": "https://pi-controller.local:8080",
"PI_CONTROLLER_USERNAME": "admin",
"PI_CONTROLLER_PASSWORD": "your-password"
}
}
}
}
2. Start Using with AI
User: "Create a 3-node K3s cluster called 'homelab'"
Claude: I'll help you create a cluster...
[Uses create_cluster tool]
[Uses discover_nodes tool]
[Uses provision_cluster tool]
Available Tools
Cluster Management
create_cluster- Create cluster definitionlist_clusters- List all clustersget_cluster_status- Get detailed cluster statusprovision_cluster- Provision K3s on nodesscale_cluster- Scale cluster nodesdelete_cluster- Delete cluster
Node Management
discover_nodes- List discovered Raspberry Pi nodesget_node_info- Get node details and hardware inforegister_node- Manually register a nodeprovision_node- Provision K3s on single nodedeprovision_node- Remove K3s from node
GPIO Control
list_gpio_devices- List all GPIO devicescreate_gpio_device- Register GPIO deviceread_gpio_pin- Read pin valuewrite_gpio_pin- Write to pin (HIGH/LOW)reserve_gpio_pin- Reserve pin for exclusive userelease_gpio_pin- Release reservationget_gpio_readings- Get historical readingsdelete_gpio_device- Remove GPIO device
Deployment
deploy_pod- Deploy Kubernetes podget_pod- Get pod informationdelete_pod- Delete pod
Certificate Authority
initialize_ca- Initialize CAissue_certificate- Issue new certificatelist_certificates- List all certificatesrevoke_certificate- Revoke certificate
Available Resources
Resources provide AI with real-time context about your clusters:
cluster://{cluster_id}/status- Cluster health and metricscluster://{cluster_id}/nodes- Node list with statusnode://{node_id}/info- Hardware specs and capabilitiesnode://{node_id}/metrics- CPU, memory, temperaturenode://{node_id}/gpio- GPIO devices on nodegpio://{gpio_id}/state- Current pin statesystem://health- Overall system health
Configuration
Environment Variables
| Variable | Required | Description | Default |
|---|---|---|---|
PI_CONTROLLER_URL |
✅ | Pi-controller API URL | - |
PI_CONTROLLER_API_KEY |
⚠️* | API key for auth | - |
PI_CONTROLLER_USERNAME |
⚠️* | Username for auth | - |
PI_CONTROLLER_PASSWORD |
⚠️* | Password for auth | - |
PI_CONTROLLER_TLS_VERIFY |
❌ | Verify TLS certs | true |
PI_CONTROLLER_TLS_CA_CERT |
❌ | Path to CA cert | - |
PI_CONTROLLER_TIMEOUT |
❌ | Request timeout (ms) | 30000 |
LOG_LEVEL |
❌ | Logging level | info |
*Either API key or username/password required
Authentication Methods
Method 1: API Key (Recommended)
{
"env": {
"PI_CONTROLLER_URL": "https://pi-controller.local:8080",
"PI_CONTROLLER_API_KEY": "your-api-key"
}
}
Method 2: Username/Password
{
"env": {
"PI_CONTROLLER_URL": "https://pi-controller.local:8080",
"PI_CONTROLLER_USERNAME": "admin",
"PI_CONTROLLER_PASSWORD": "secure-password"
}
}
Examples
Create and Provision Cluster
User: "Create a K3s cluster with 1 master and 2 workers"
AI uses:
1. create_cluster → Creates cluster definition
2. discover_nodes → Finds available Pi nodes
3. provision_cluster → Installs K3s on selected nodes
4. cluster://{id}/status → Monitors provisioning progress
Control GPIO Hardware
User: "Turn on the LED on GPIO pin 18"
AI uses:
1. discover_nodes → Finds the right node
2. list_gpio_devices → Locates GPIO device on pin 18
3. write_gpio_pin → Sets pin value to HIGH (1)
4. gpio://{id}/state → Confirms new state
Deploy Application
User: "Deploy nginx on the homelab cluster"
AI uses:
1. list_clusters → Finds homelab cluster
2. deploy_pod → Creates nginx pod
3. get_pod → Verifies deployment
Development
Setup
git clone https://github.com/dsyorkd/pi-controller-mcp.git
cd pi-controller-mcp
npm install
Run in Development
# Copy environment template
cp .env.example .env
# Edit .env with your pi-controller URL and credentials
nano .env
# Start in watch mode
npm run dev
Build
npm run build
Test
# Run all tests
npm test
# Run unit tests only
npm run test:unit
# Run integration tests (requires running pi-controller)
npm run test:integration
Architecture
pi-controller-mcp/
├── src/
│ ├── index.ts # MCP server entry point
│ ├── config.ts # Configuration loader
│ ├── client/
│ │ ├── pi-controller-client.ts # REST API client
│ │ └── auth.ts # Authentication
│ ├── tools/
│ │ ├── cluster.ts # Cluster tools
│ │ ├── node.ts # Node tools
│ │ ├── gpio.ts # GPIO tools
│ │ ├── deployment.ts # Deployment tools
│ │ └── ca.ts # CA tools
│ ├── resources/
│ │ ├── cluster-status.ts # Cluster resources
│ │ ├── node-info.ts # Node resources
│ │ ├── gpio-state.ts # GPIO resources
│ │ └── metrics.ts # Metrics resources
│ └── types/
│ └── pi-controller.ts # Type definitions
Troubleshooting
Connection Issues
Error: Cannot connect to pi-controller
Solutions:
- Verify
PI_CONTROLLER_URLis correct - Check pi-controller is running:
curl ${PI_CONTROLLER_URL}/health - Verify network connectivity
- Check TLS certificate if using HTTPS
Authentication Issues
Error: Authentication failed
Solutions:
- Verify credentials in
.mcp.jsonor.env - Check user has required RBAC role
- For API key: Ensure key is valid and not expired
- For username/password: Verify credentials are correct
Permission Issues
Error: Forbidden: insufficient permissions
Solutions:
- Tools require different RBAC roles:
- Read operations:
viewerrole - Write operations:
operatorrole - Lifecycle operations:
adminrole
- Read operations:
- Check user role: See pi-controller documentation
Contributing
- Fork the repository
- Create feature branch:
git checkout -b feature/amazing-feature - Commit changes:
git commit -m 'Add amazing feature' - Push to branch:
git push origin feature/amazing-feature - Open Pull Request
See CONTRIBUTING.md for development guidelines.
Related Projects
- pi-controller - Main control plane
- kubes-aura - Web UI
- pi-agent - Node agent (part of pi-controller)
License
MIT License - see LICENSE file for details
Support
Built with ❤️ for the Raspberry Pi and AI 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 模型以安全和受控的方式获取实时的网络信息。