Skip to main content
Glama
Homelab MCP Server

Homelab MCP Server

by bshandley

Homelab MCP Server

A remote MCP (Model Context Protocol) server for managing homelab infrastructure. Provides Claude with tools to monitor and manage Docker containers, OPNsense firewall, TrueNAS storage, Proxmox virtualization, and Home Assistant service status.

Features

  • 4 Capability Levels: From read-only monitoring to full management control

  • Docker Management: List, monitor, control containers and Dockge stacks

  • OPNsense Integration: Monitor firewall status and restart services

  • TrueNAS Integration: Check pool health, manage datasets, create snapshots

  • Proxmox Integration: Monitor and manage VMs/containers, create snapshots

  • Home Assistant Integration: Monitor service health, entity states, configuration, and error logs

  • System Monitoring: CPU, memory, disk usage on the host

Related MCP server: mcp-it-ops

⚠️ DANGER - READ THIS FIRST

This software grants AI models direct control over your network infrastructure. Use with extreme caution.

Critical Risks

  • AI Can Make Mistakes: Language models can misinterpret instructions, hallucinate requirements, or execute unintended actions. A simple request like "clean up unused containers" could result in critical services being stopped.

  • Destructive Actions Are Possible: At higher capability levels (3-4), the AI can:

    • Delete virtual machines and containers

    • Modify network configurations

    • Remove critical datasets or snapshots

    • Execute arbitrary commands in production systems

    • Overwrite docker-compose files, potentially causing data loss

  • No Undo Button: Once the AI executes a destructive action (deletes a VM, removes a dataset, stops a critical service), the damage is immediate and may be irreversible.

  • Network Security Implications: This server provides API access to your firewall, storage system, and virtualization platform. A compromised API key or misconfigured capability level could allow unauthorized control over your entire homelab.

  • Misunderstandings Happen: AI models may not fully understand your infrastructure's dependencies. Restarting one service could cascade into network-wide outages.

Recommendations

  1. Start with Level 1 (Read-Only): Always begin with monitoring-only access and only increase capability levels when absolutely necessary.

  2. Test in Development: If possible, test with non-production infrastructure first to understand how the AI interprets your requests.

  3. Review Before Executing: At Level 2+, carefully review what actions the AI plans to take before confirming execution.

  4. Keep Backups: Ensure you have recent backups of all critical systems before granting Level 3+ access.

  5. Rotate Credentials: Regularly rotate API keys and OAuth credentials. Treat them as highly sensitive.

  6. Monitor Logs: Watch the container logs to see what actions are being executed in real-time.

  7. Use Network Segmentation: Consider running this server in a restricted network segment with limited access to critical infrastructure.

BY USING THIS SOFTWARE, YOU ACKNOWLEDGE THAT YOU UNDERSTAND THESE RISKS AND ACCEPT FULL RESPONSIBILITY FOR ANY ACTIONS TAKEN BY THE AI, INCLUDING DATA LOSS, SERVICE DISRUPTION, OR SECURITY INCIDENTS.

Quick Start

1. Prerequisites

  • Docker and Docker Compose installed on target host (Wharf)

  • OPNsense API credentials (optional)

  • TrueNAS API key (optional)

  • Node.js 20+ (for local development)

2. Setup

# Clone or copy the project to your host
cd homelab-mcp

# Copy example environment file
cp .env.example .env

# Generate a secure API key
openssl rand -hex 32

# Edit .env and add your credentials
nano .env

3. Configuration

Edit .env with your settings:

CAPABILITY_LEVEL=1        # Start with level 1 (read-only)
API_KEY=your-api-key-here # Use the generated key
PORT=3005

# OPNsense (optional)
OPNSENSE_HOST=10.0.0.1
OPNSENSE_API_KEY=your-key
OPNSENSE_API_SECRET=your-secret

# TrueNAS (optional)
TRUENAS_HOST=10.0.0.105
TRUENAS_API_KEY=your-key

# Proxmox (optional)
PROXMOX_HOST=10.0.0.2
PROXMOX_TOKEN_ID=root@pam!mytoken
PROXMOX_TOKEN_SECRET=your-secret

# Home Assistant (optional)
HOME_ASSISTANT_HOST=10.0.0.103
HOME_ASSISTANT_PORT=8123
HOME_ASSISTANT_TOKEN=your-long-lived-token
HOME_ASSISTANT_USE_HTTPS=false

4. Build and Deploy

# Build TypeScript
npm install
npm run build

# Build Docker image
docker compose build

# Start the server
docker compose up -d

# Check logs
docker compose logs -f

5. Configure Claude Desktop

Add to your Claude Desktop MCP settings:

{
  "mcpServers": {
    "homelab": {
      "command": "node",
      "args": ["/path/to/homelab-mcp/dist/index.js"],
      "env": {
        "CAPABILITY_LEVEL": "1",
        "API_KEY": "your-api-key-here",
        "OPNSENSE_HOST": "10.0.0.1",
        "OPNSENSE_API_KEY": "your-key",
        "OPNSENSE_API_SECRET": "your-secret",
        "TRUENAS_HOST": "10.0.0.105",
        "TRUENAS_API_KEY": "your-key",
        "PROXMOX_HOST": "10.0.0.2",
        "PROXMOX_TOKEN_ID": "root@pam!mytoken",
        "PROXMOX_TOKEN_SECRET": "your-secret",
        "HOME_ASSISTANT_HOST": "10.0.0.103",
        "HOME_ASSISTANT_PORT": "8123",
        "HOME_ASSISTANT_TOKEN": "your-long-lived-token",
        "HOME_ASSISTANT_USE_HTTPS": "false"
      }
    }
  }
}

Remote Access (Claude Chat)

For accessing the MCP server from Claude Chat (web interface), deploy with HTTP transport:

  1. Set environment variables in .env:

    PORT=3000
    API_KEY=your-generated-key
    CAPABILITY_LEVEL=1
  2. Deploy the container:

    docker compose up -d
  3. Configure reverse proxy (e.g., Traefik, Pangolin, nginx) to route mcp.example.com to http://localhost:3000

  4. Add DNS record pointing mcp.example.com to your server

  5. In Claude Chat, add the MCP server:

    • URL: https://mcp.example.com/mcp

    • Authentication: Bearer token

    • Token: Your API_KEY value

OAuth 2.0 Authentication (for Claude Chat)

Claude Chat requires OAuth 2.0 for custom connectors. This server supports the Client Credentials flow.

  1. Generate OAuth credentials:

    # Generate client ID
    openssl rand -hex 32
    
    # Generate client secret
    openssl rand -hex 32
  2. Add to .env:

    OAUTH_CLIENT_ID=your-generated-client-id
    OAUTH_CLIENT_SECRET=your-generated-client-secret
  3. In Claude Chat, add the connector:

    • Name: Homelab

    • Remote MCP server URL: https://mcp.example.com/mcp

    • OAuth Client ID: Your generated client ID

    • OAuth Client Secret: Your generated client secret

The server will issue access tokens valid for 1 hour. Claude Chat handles token refresh automatically.

Endpoints

When running in HTTP mode:

Endpoint

Method

Auth

Description

/health

GET

No

Health check, returns status and capability level

/oauth/token

POST

No

OAuth 2.0 token endpoint

/mcp

POST

Yes

MCP protocol endpoint

/

POST

Yes

Alias for /mcp

Testing

# Test health endpoint
curl https://mcp.example.com/health

# Get an access token
curl -X POST https://mcp.example.com/oauth/token \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "grant_type=client_credentials&client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRET"

# Use the token
curl https://mcp.example.com/mcp \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'

Capability Levels

Level

Name

Capabilities

1

Monitor

Read-only: container status, logs, stats, system info, service health

2

Operate

Level 1 + start/stop/restart containers and services

3

Configure

Level 2 + read compose files, configs, volumes, networks

4

Manage

Level 3 + write configs, create/remove containers, exec commands

Recommendation: Start with Level 1 and increase as needed.

Available Tools

Level 1 - Monitor

  • docker_list_containers - List all containers

  • docker_container_logs - Get container logs

  • docker_container_stats - Get container CPU/memory stats

  • system_info - Get host system info

  • opnsense_status - Get OPNsense status

  • truenas_status - Get TrueNAS pool status

  • truenas_alerts - Get TrueNAS alerts

  • proxmox_status - Get Proxmox cluster status

  • proxmox_list_vms - List all VMs and containers

  • proxmox_vm_status - Get VM/container status

  • home_assistant_status - Get Home Assistant version and entity counts

  • home_assistant_list_entities - List all entities (lights, switches, sensors)

  • home_assistant_get_entity - Get specific entity state and attributes

Level 2 - Operate

  • docker_restart_container - Restart a container

  • docker_start_container - Start a container

  • docker_stop_container - Stop a container

  • opnsense_service_restart - Restart OPNsense service

  • proxmox_start_vm - Start a VM/container

  • proxmox_stop_vm - Stop a VM/container

  • proxmox_shutdown_vm - Gracefully shutdown a VM/container

  • proxmox_reboot_vm - Reboot a VM/container

Level 3 - Configure

  • docker_read_compose - Read docker-compose.yml

  • docker_list_volumes - List Docker volumes

  • docker_list_networks - List Docker networks

  • docker_inspect_container - Inspect container details

  • truenas_list_datasets - List ZFS datasets

  • truenas_dataset_info - Get dataset details

  • proxmox_vm_config - Get VM/container configuration

  • proxmox_list_storage - List Proxmox storage

  • proxmox_list_nodes - List cluster nodes

  • home_assistant_get_config - Get Home Assistant configuration

  • home_assistant_error_log - Get error log

Level 4 - Manage

  • docker_write_compose - Write docker-compose.yml

  • docker_compose_up - Deploy a stack

  • docker_compose_down - Remove a stack

  • docker_exec - Execute command in container

  • truenas_create_snapshot - Create ZFS snapshot

  • proxmox_create_snapshot - Create VM/container snapshot

  • proxmox_delete_vm - Delete a VM/container

Development

# Install dependencies
npm install

# Run in development mode
npm run dev

# Build
npm run build

# Type check
npx tsc --noEmit

Security Notes

  • The API key should be kept secret and rotated periodically

  • Start with the lowest capability level you need

  • For Level 4, the /opt/stacks mount must be :rw instead of :ro

  • The container requires access to the Docker socket for container management

  • OPNsense and TrueNAS APIs use self-signed certificates by default

Troubleshooting

Container won't start

# Check logs
docker compose logs homelab-mcp

# Common issues:
# - Missing API_KEY in .env
# - Invalid CAPABILITY_LEVEL (must be 1-4)
# - Docker socket not accessible

Tools failing

# Test OPNsense API
curl -k -u "key:secret" https://10.0.0.1/api/core/system/status

# Test TrueNAS API
curl -k -H "Authorization: Bearer YOUR_KEY" https://10.0.0.105/api/v2.0/system/info

# Test Home Assistant API
curl -H "Authorization: Bearer YOUR_TOKEN" http://10.0.0.103:8123/api/

# Check network connectivity from container
docker exec homelab-mcp ping 10.0.0.1

Permission issues

If you need Level 4 (write access to stacks), update the volume mount:

volumes:
  - /opt/stacks:/opt/stacks:rw  # Change from :ro to :rw

License

MIT

Contributing

Issues and pull requests welcome!

Available Tools

13 tools
docker_container_logsC

Get recent logs from a container

Inputs: container (required), lines, since, filter.

docker_container_statsC

Get CPU/memory/network stats for a container

Inputs: container (required).

docker_list_containersC

List all Docker containers with their status

Inputs: all.

home_assistant_get_entityB

Get detailed state and attributes of a specific Home Assistant entity

Inputs: entity_id (required).

home_assistant_list_entitiesB

List all Home Assistant entities (lights, switches, sensors, etc.)

Inputs: domain.

home_assistant_statusB

Get Home Assistant version, entity count, and available domains

opnsense_statusB

Get OPNsense firewall/gateway status

proxmox_list_vmsB

List all Proxmox VMs and containers across all nodes

proxmox_statusB

Get Proxmox cluster status and node information

proxmox_vm_statusC

Get detailed status of a specific Proxmox VM or container

Inputs: node (required), vmid (required), type (required).

system_infoB

Get host system information (disk, memory, CPU usage)

truenas_alertsB

Get active TrueNAS alerts

truenas_statusB

Get TrueNAS pool health and system status

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.5/5.0

    Scored across 13 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose targeting specific resources and actions, such as docker_container_logs vs. docker_container_stats, home_assistant_get_entity vs. home_assistant_list_entities, and proxmox_list_vms vs. proxmox_vm_status. There is no ambiguity or overlap in functionality, making it easy for an agent to select the correct tool.

    Naming Consistency5/5

    All tool names follow a consistent verb_noun pattern with clear prefixes for each domain (e.g., docker_, home_assistant_, proxmox_, system_, truenas_). The naming is uniform across the set, using snake_case throughout without any deviations or mixed conventions.

    Tool Count5/5

    With 13 tools, the server is well-scoped for monitoring a homelab environment, covering key areas like Docker, Home Assistant, Proxmox, TrueNAS, OPNsense, and system info. Each tool serves a distinct monitoring purpose, and the count is appropriate without being excessive or insufficient.

    Completeness4/5

    The tool set provides comprehensive read-only monitoring coverage for homelab components, including status, lists, and detailed views. Minor gaps exist, such as no control actions (e.g., starting/stopping containers or VMs) or deeper diagnostic tools, but agents can effectively monitor the environment with the available tools.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      Enables Claude to monitor CPU, memory, disk, processes, network connections, Docker containers, and system logs for system diagnostics and troubleshooting.
      5
      MIT
    • F
      license
      A
      quality
      D
      maintenance
      Exposes homelab and IT-ops tools to Claude, including system health monitoring, Grafana alert states, Docker container status, Loki logs, SMART disk health, and more.
      8
      1
      -
    • A
      license
      Not graded
      quality
      Not graded
      maintenance
      Enables Claude to manage a Proxmox cluster through chat: inventory, power control, configuration changes, VM/container creation and cloning, snapshots, network/firewall/cluster visibility, guest command execution, and file writes via the QEMU Guest Agent.
      26 npm
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables control of a home lab through a single MCP server, exposing tools for Home Assistant, Portainer, Sonarr, Radarr, SABnzbd, and Jellyfin so Claude can query states, manage containers and stacks, handle media libraries and download queues, and run automations. Each service is optional and can be configured via environment variables, with a read-only mode and bearer-token-protected HTTP transport for always-on deployments.
      1
      MIT