Labsco
bjeans logo

Homelab MCP

β˜… 35

from bjeans

MCP servers for managing homelab infrastructure through Claude Desktop. Monitor Docker/Podman containers, Ollama AI models, Pi-hole DNS, Unifi networks, and Ansible inventory.

πŸ”₯πŸ”₯πŸ”₯βœ“ VerifiedFreeAdvanced setup

Homelab MCP Servers

<p align="center"> <img src="assets/Homelab-mcp-logo-transparent.png" alt="Homelab MCP Logo" width="400"> </p>

GitHub release Security Check Docker Build Docker Image Version Docker Pulls License: MIT Python

Model Context Protocol (MCP) servers for managing homelab infrastructure through Claude Desktop.

A collection of Model Context Protocol (MCP) servers for managing and monitoring your homelab infrastructure through Claude Desktop.

πŸ”’ Security Notice

⚠️ IMPORTANT: Please read SECURITY.md before deploying this project.

This project interacts with critical infrastructure (Docker APIs, DNS, network devices). Improper configuration can expose your homelab to security risks.

Key Security Requirements:

  • NEVER expose Docker/Podman APIs to the internet - Use firewall rules to restrict access
  • Keep .env file secure - Contains API keys and should never be committed
  • Use unique API keys - Generate separate keys for each service
  • Review network security - Ensure proper VLAN segmentation and firewall rules

See SECURITY.md for comprehensive security guidance.

οΏ½ Documentation Overview

This project includes several documentation files for different audiences:

πŸ‘₯ For End Users: Follow this README + copy PROJECT_INSTRUCTIONS.md to Claude πŸ”„ Migrating from v1.x? See MIGRATION_V3.md for unified server migration πŸ€– For AI Assistants: Read CLAUDE.md for complete development context πŸ”§ For Contributors: Start with CONTRIBUTING.md and CLAUDE.md

οΏ½πŸ“– Important: Configure Claude Project Instructions

After setting up the MCP servers, create your personalized project instructions:

  1. Copy the example template:

    Copy & paste β€” that's it
    # Windows
    copy PROJECT_INSTRUCTIONS.example.md PROJECT_INSTRUCTIONS.md
    
    # Linux/Mac
    cp PROJECT_INSTRUCTIONS.example.md PROJECT_INSTRUCTIONS.md
  2. Edit the file with your actual infrastructure details:

    PROJECT_INSTRUCTIONS.md (for Claude Desktop project instructions):

    • Replace example IP addresses with your real network addresses
    • Add your actual server hostnames
    • Customize with your specific services and configurations
    • Keep this file private - it contains your network topology

    CLAUDE_CUSTOM.md (for AI development work - contributors only):

    • Update repository URLs with your actual GitHub repository
    • Add your Notion workspace URLs if using task management
    • Customize infrastructure references
    • Keep this file private - contains your specific URLs and setup
  3. Add to Claude Desktop:

    • Open Claude Desktop
    • Go to your project settings
    • Copy the contents of your customized PROJECT_INSTRUCTIONS.md
    • Paste into the "Project instructions" field

What's included:

  • Detailed MCP server capabilities and usage patterns
  • Infrastructure overview and monitoring capabilities
  • Specific commands and tools available for each service
  • Troubleshooting and development guidance

This README covers installation and basic setup. The project instructions provide Claude with comprehensive usage context.

⚑ FastMCP Framework (v3.0.0)

Version 3.0.0 uses FastMCP: A modern MCP framework that simplifies server architecture while adding support for multiple transport mechanisms and tool annotations.

What is FastMCP?

FastMCP is a lightweight framework that:

  • βœ… Reduces server code by 38% (1,754 lines eliminated)
  • βœ… Uses simple decorator pattern (@mcp.tool()) for tool definitions
  • βœ… Includes comprehensive tool annotations for behavioral hints
  • βœ… Adds support for HTTP and SSE transports (in addition to stdio)
  • βœ… Auto-generates schemas from Python type hints
  • βœ… Improves code maintainability and makes adding new servers easier

All 39 tools now include MCP annotations (readOnlyHint, idempotentHint, etc.) to help Claude make informed decisions about tool usage.

Transport Options

FastMCP servers can operate using different transport mechanisms:

1. Standard Input/Output (stdio) - Default

The traditional MCP transport used by Claude Desktop. This is the default and recommended option for most users.

Copy & paste β€” that's it
# Run with stdio (default)
python homelab_unified_mcp.py

# Or explicitly specify stdio transport
python homelab_unified_mcp.py --transport stdio

When to use:

  • Claude Desktop integration (default mode)
  • Most common use case
  • No additional configuration needed

2. HTTP Transport

Run MCP servers as HTTP services for remote or flexible deployment scenarios.

Copy & paste β€” that's it
# Start server with HTTP transport
python homelab_unified_mcp.py --transport http --host 0.0.0.0 --port 8000

# Test the HTTP endpoint
curl http://localhost:8000/tools

When to use:

  • Deploying servers remotely
  • Web-based integrations
  • Multi-client scenarios
  • Load balancing requirements

3. Server-Sent Events (SSE) Transport

Stream-based protocol for real-time bidirectional communication.

Copy & paste β€” that's it
# Start server with SSE transport
python homelab_unified_mcp.py --transport sse --host 0.0.0.0 --port 8000

# Connect via SSE client
curl http://localhost:8000/sse

When to use:

  • Real-time monitoring applications
  • Browser-based integrations
  • Event-driven architectures
  • Streaming responses

Configuring Claude Desktop with FastMCP

Claude Desktop continues to use stdio transport by default. No configuration changes are required:

Copy & paste β€” that's it
{
  "mcpServers": {
    "homelab-unified": {
      "command": "python",
      "args": ["C:\\Path\\To\\Homelab-MCP\\homelab_unified_mcp.py"]
    }
  }
}

Migration from v2.2.0

If you're upgrading from v2.2.0:

  • βœ… No breaking changes - Your existing configuration continues to work unchanged
  • βœ… Same functionality - All 7 servers and all tools remain identical
  • βœ… Cleaner code - Internal refactoring produces the same results
  • βœ… New options - Optional HTTP/SSE transports available if needed

No action required - just update and restart Claude Desktop.


πŸ“¦ Available MCP Servers

✨ Dynamic Tool Parameter Enums (New in v2.1.0)

When you configure Ansible inventory, Claude Desktop will automatically show your infrastructure options in dropdown menus. No more guessing hostnames or group names!

What gets auto-populated:

  • Ping tools - Your Ansible groups appear in dropdown menus
  • Docker tools - Your Docker/Podman hosts shown in dropdowns
  • Ollama tools - Your Ollama server hostnames available for selection
  • UPS tools - Your NUT server hostnames shown in dropdowns

How it works:

  1. Set ANSIBLE_INVENTORY_PATH in your .env file
  2. Restart Claude Desktop (required - enums load at startup)
  3. When using tools, Claude shows your actual infrastructure in dropdown menus instead of requiring manual entry

Important Notes:

  • Restart Required: Changes to Ansible inventory require restarting Claude Desktop to update dropdown options
  • Performance: Enums generate once at startup - minimal impact even with large inventories (100+ hosts)
  • Graceful Degradation: If no Ansible inventory is configured, tools still work - you just won't see dropdown suggestions

Example before/after:

Before: "Which group should I ping?" β†’ User manually types "webservers" (or guesses) After: "Which group should I ping?" β†’ User selects from dropdown: all, docker_hosts, webservers, databases, etc.

Troubleshooting:

  • Dropdowns not showing? Verify ANSIBLE_INVENTORY_PATH is set and restart Claude Desktop
  • Wrong options showing? Check that your Ansible inventory is up-to-date and restart Claude Desktop
  • Performance issues? Enum generation happens once at startup - if slow, check inventory file size and Ansible installation

MCP Registry Inspector (⚠️ DEPRECATED)

Deprecation Notice (v2.3.0): This tool is deprecated. Claude Desktop now has native file system access, making this MCP server unnecessary. You can simply ask Claude to read your MCP server files or configuration directly.

Replacement: Use Claude's built-in file access:

  • "Read my claude_desktop_config.json file"
  • "Show me the source code for docker_mcp_podman.py"
  • "List all .py files in this directory"

For users with existing configurations: This server will continue to work but will not receive updates. It will be removed from documentation in v3.0.0. Consider removing it from your claude_desktop_config.json.

<details> <summary>Legacy Configuration (for reference only)</summary>

Tools:

  • get_claude_config - View Claude Desktop MCP configuration
  • list_mcp_servers - List all registered MCP servers
  • list_mcp_directory - Browse MCP development directory
  • read_mcp_file - Read MCP server source code
  • write_mcp_file - Write/update MCP server files
  • search_mcp_files - Search for files by name

Configuration:

Copy & paste β€” that's it
MCP_DIRECTORY=/path/to/your/Homelab-MCP
CLAUDE_CONFIG_PATH=/path/to/claude_desktop_config.json  # Optional
</details>

Docker/Podman Container Manager

Manage Docker and Podman containers across multiple hosts.

πŸ”’ Security Warning: Docker/Podman APIs typically use unencrypted HTTP without authentication. See SECURITY.md for required firewall configuration.

Tools:

Individual server mode:

  • get_docker_containers - Get containers on a specific host
  • get_all_containers - Get all containers across all hosts
  • get_container_stats - Get CPU and memory stats
  • check_container - Check if a specific container is running
  • find_containers_by_label - Find containers by label
  • get_container_labels - Get all labels for a container

Unified server mode (namespaced):

  • docker_get_containers - Get containers on a specific host
  • docker_get_all_containers - Get all containers across all hosts
  • docker_get_container_stats - Get CPU and memory stats
  • docker_check_container - Check if a specific container is running
  • docker_find_containers_by_label - Find containers by label
  • docker_get_container_labels - Get all labels for a container

Configuration Options:

Option 1: Using Ansible Inventory (Recommended)

Copy & paste β€” that's it
ANSIBLE_INVENTORY_PATH=/path/to/ansible_hosts.yml

# Ansible inventory group names (default: docker_hosts, podman_hosts)
# Change these if you use different group names in your ansible_hosts.yml
DOCKER_ANSIBLE_GROUP=docker_hosts
PODMAN_ANSIBLE_GROUP=podman_hosts

Option 2: Using Environment Variables

Copy & paste β€” that's it
DOCKER_SERVER1_ENDPOINT=192.168.1.100:2375
DOCKER_SERVER2_ENDPOINT=192.168.1.101:2375
PODMAN_SERVER1_ENDPOINT=192.168.1.102:8080

Ollama AI Model Manager

Monitor and manage Ollama AI model instances across your homelab, plus check your LiteLLM proxy for unified API access.

What's Included

Ollama Monitoring:

  • Track multiple Ollama instances across different hosts
  • View available models and their sizes
  • Check instance health and availability

LiteLLM Proxy Integration:

  • LiteLLM provides a unified OpenAI-compatible API across all your Ollama instances
  • Enables load balancing and failover between multiple Ollama servers
  • Allows you to use OpenAI client libraries with your local models
  • The MCP server can verify your LiteLLM proxy is online and responding

Why use LiteLLM?

  • Load Balancing: Automatically distributes requests across multiple Ollama instances
  • Failover: If one Ollama server is down, requests route to healthy servers
  • OpenAI Compatibility: Use any OpenAI SDK/library with your local models
  • Centralized Access: Single endpoint (e.g., http://192.0.2.10:4000) for all models
  • Usage Tracking: Monitor which models are being used most

Tools:

  • get_ollama_status - Check status of all Ollama instances and model counts
  • get_ollama_models - Get detailed model list for a specific host
  • get_litellm_status - Verify LiteLLM proxy is online and responding

Configuration Options:

Option 1: Using Ansible Inventory (Recommended)

Copy & paste β€” that's it
ANSIBLE_INVENTORY_PATH=/path/to/ansible_hosts.yml
OLLAMA_PORT=11434  # Default Ollama port

# Ansible inventory group name (default: ollama_servers)
# Change this if you use a different group name in your ansible_hosts.yml
OLLAMA_INVENTORY_GROUP=ollama_servers

# LiteLLM Configuration
LITELLM_HOST=192.168.1.100  # Host running LiteLLM proxy
LITELLM_PORT=4000           # LiteLLM proxy port (default: 4000)

Option 2: Using Environment Variables

Copy & paste β€” that's it
# Ollama Instances
OLLAMA_SERVER1=192.168.1.100
OLLAMA_SERVER2=192.168.1.101
OLLAMA_WORKSTATION=192.168.1.150

# LiteLLM Proxy
LITELLM_HOST=192.168.1.100
LITELLM_PORT=4000

Setting Up LiteLLM (Optional):

If you want to use LiteLLM for unified access to your Ollama instances:

  1. Install LiteLLM on one of your servers:

    Copy & paste β€” that's it
    pip install litellm[proxy]
  2. Create configuration (litellm_config.yaml):

    Copy & paste β€” that's it
    model_list:
      - model_name: llama3.2
        litellm_params:
          model: ollama/llama3.2
          api_base: http://server1:11434
      - model_name: llama3.2
        litellm_params:
          model: ollama/llama3.2
          api_base: http://server2:11434
    
    router_settings:
      routing_strategy: usage-based-routing
  3. Start LiteLLM proxy:

    Copy & paste β€” that's it
    litellm --config litellm_config.yaml --port 4000
  4. Use the MCP tool to verify it's running:

    • In Claude: "Check my LiteLLM proxy status"

Example Usage:

  • "What Ollama instances do I have running?"
  • "Show me all models on my Dell-Server"
  • "Is my LiteLLM proxy online?"
  • "How many models are available across all servers?"

Pi-hole DNS Manager

Monitor Pi-hole DNS statistics and status.

πŸ”’ Security Note: Store Pi-hole API keys securely in .env file. Generate unique keys per instance.

Tools:

  • get_pihole_stats - Get DNS statistics from all Pi-hole instances
  • get_pihole_status - Check which Pi-hole instances are online

Configuration Options:

Option 1: Using Ansible Inventory (Recommended)

Copy & paste β€” that's it
ANSIBLE_INVENTORY_PATH=/path/to/ansible_hosts.yml

# Ansible inventory group name (default: PiHole)
# Change this if you use a different group name in your ansible_hosts.yml
PIHOLE_ANSIBLE_GROUP=PiHole

# API keys still required in .env:
PIHOLE_API_KEY_SERVER1=your-api-key-here
PIHOLE_API_KEY_SERVER2=your-api-key-here

Option 2: Using Environment Variables

Copy & paste β€” that's it
PIHOLE_API_KEY_SERVER1=your-api-key
PIHOLE_API_KEY_SERVER2=your-api-key
PIHOLE_SERVER1_HOST=pihole1.local
PIHOLE_SERVER1_PORT=80
PIHOLE_SERVER2_HOST=pihole2.local
PIHOLE_SERVER2_PORT=8053

Getting Pi-hole API Keys:

  • Web UI: Settings β†’ API β†’ Show API Token
  • Or generate new: pihole -a -p on Pi-hole server

Unifi Network Monitor

Monitor Unifi network infrastructure and clients with caching for performance.

πŸ”’ Security Note: Use a dedicated API key with minimal required permissions.

Tools:

  • get_network_devices - Get all network devices (switches, APs, gateways)
  • get_network_clients - Get all active network clients
  • get_network_summary - Get network overview
  • refresh_network_data - Force refresh from controller (bypasses cache)

Configuration:

Copy & paste β€” that's it
UNIFI_API_KEY=your-unifi-api-key
UNIFI_HOST=192.168.1.1

Note: Data is cached for 5 minutes to improve performance. Use refresh_network_data to force update.

Ansible Inventory Inspector

Query Ansible inventory information (read-only). Available in both unified and standalone modes.

Unified Mode Tools (with ansible_ prefix):

  • ansible_get_all_hosts - Get all hosts in inventory
  • ansible_get_all_groups - Get all groups
  • ansible_get_host_details - Get detailed host information
  • ansible_get_group_details - Get detailed group information
  • ansible_get_hosts_by_group - Get hosts in specific group
  • ansible_search_hosts - Search hosts by pattern or variable
  • ansible_get_inventory_summary - High-level inventory overview
  • ansible_reload_inventory - Reload inventory from disk

Standalone Mode Tools (without prefix):

  • get_all_hosts - Get all hosts in inventory
  • get_all_groups - Get all groups
  • get_host_details - Get detailed host information
  • get_group_details - Get detailed group information
  • get_hosts_by_group - Get hosts in specific group
  • search_hosts - Search hosts by pattern or variable
  • get_inventory_summary - High-level inventory overview
  • reload_inventory - Reload inventory from disk

Configuration:

Copy & paste β€” that's it
ANSIBLE_INVENTORY_PATH=/path/to/ansible_hosts.yml

Deployment:

  • βœ… Available in unified server mode
  • βœ… Available in Docker deployments
  • βœ… Available in standalone mode: python ansible_mcp_server.py

Ping Network Connectivity Monitor

Test network connectivity and host availability using ICMP ping across your infrastructure.

Why use this?

  • Quick health checks during outages or after power events
  • Verify which hosts are reachable before querying service-specific MCPs
  • Simple troubleshooting tool to identify network issues
  • Baseline connectivity testing for your infrastructure

Tools:

  • ping_host - Ping a single host by name (resolved from Ansible inventory)
  • ping_group - Ping all hosts in an Ansible group concurrently
  • ping_all - Ping all infrastructure hosts concurrently
  • list_groups - List available Ansible groups for ping operations

Features:

  • βœ… Cross-platform support - Works on Windows, Linux, and macOS
  • βœ… Ansible integration - Automatically resolves hostnames/IPs from inventory
  • βœ… Concurrent pings - Test multiple hosts simultaneously for faster results
  • βœ… Detailed statistics - RTT min/avg/max, packet loss percentage
  • βœ… Customizable - Configure timeout and packet count
  • βœ… No dependencies - Uses system ping command (no extra libraries needed)

Configuration:

Copy & paste β€” that's it
ANSIBLE_INVENTORY_PATH=/path/to/ansible_hosts.yml
# No additional API keys required!

Example Usage:

  • "Ping server1.example.local"
  • "Check connectivity to all Pi-hole servers"
  • "Ping all Ubuntu_Server hosts"
  • "Test connectivity to entire infrastructure"
  • "What groups can I ping?"

When to use:

  • After power outages - Quickly identify which hosts came back online
  • Before service checks - Verify host is reachable before checking specific services
  • Network troubleshooting - Isolate connectivity issues from service issues
  • Health monitoring - Regular checks to ensure infrastructure availability

UPS Monitoring (Network UPS Tools)

Monitor UPS (Uninterruptible Power Supply) devices across your infrastructure using Network UPS Tools (NUT) protocol.

Why use this?

  • Real-time visibility into power infrastructure status
  • Proactive alerts before battery depletion during outages
  • Monitor multiple UPS devices across different hosts
  • Track battery health and runtime estimates
  • Essential for critical infrastructure planning

Tools:

  • get_ups_status - Check status of all UPS devices across all NUT servers
  • get_ups_details - Get detailed information for a specific UPS device
  • get_battery_runtime - Get battery runtime estimates for all UPS devices
  • get_power_events - Check for recent power events (on battery, low battery)
  • list_ups_devices - List all UPS devices configured in inventory
  • reload_inventory - Reload Ansible inventory after changes

Features:

  • βœ… NUT protocol support - Uses Network UPS Tools standard protocol (port 3493)
  • βœ… Ansible integration - Automatically discovers UPS from inventory
  • βœ… Multiple UPS per host - Support for servers with multiple UPS devices
  • βœ… Battery monitoring - Track charge level, runtime remaining, load percentage
  • βœ… Power event detection - Identify when UPS switches to battery or low battery
  • βœ… Cross-platform - Works with any NUT-compatible UPS (TrippLite, APC, CyberPower, etc.)
  • βœ… Flexible auth - Optional username/password authentication

Configuration:

Option 1: Using Ansible Inventory (Recommended)

Copy & paste β€” that's it
ANSIBLE_INVENTORY_PATH=/path/to/ansible_hosts.yml

# Default NUT port (optional, defaults to 3493)
NUT_PORT=3493

# NUT authentication (optional - only if your NUT server requires it)
NUT_USERNAME=monuser
NUT_PASSWORD=secret

Ansible inventory example:

Copy & paste β€” that's it
nut_servers:
  hosts:
    dell-server.example.local:
      ansible_host: 192.168.1.100
      nut_port: 3493
      ups_devices:
        - name: tripplite
          description: "TrippLite SMART1500LCDXL"

Option 2: Using Environment Variables

Copy & paste β€” that's it
NUT_PORT=3493
NUT_USERNAME=monuser
NUT_PASSWORD=secret

Prerequisites:

  1. Install NUT on servers with UPS devices:

    Copy & paste β€” that's it
    # Debian/Ubuntu
    sudo apt install nut nut-client nut-server
    
    # RHEL/Rocky/CentOS
    sudo dnf install nut nut-client
  2. Configure NUT daemon (/etc/nut/ups.conf):

    Copy & paste β€” that's it
    [tripplite]
        driver = usbhid-ups
        port = auto
        desc = "TrippLite SMART1500LCDXL"
  3. Enable network monitoring (/etc/nut/upsd.conf):

    Copy & paste β€” that's it
    LISTEN 0.0.0.0 3493
  4. Configure access (/etc/nut/upsd.users):

    Copy & paste β€” that's it
    [monuser]
        password = secret
        upsmon master
  5. Start NUT services:

    Copy & paste β€” that's it
    sudo systemctl enable nut-server nut-client
    sudo systemctl start nut-server nut-client

Example Usage:

  • "What's the status of all my UPS devices?"
  • "Show me battery runtime for the Dell server UPS"
  • "Check for any power events"
  • "Get detailed info about the TrippLite UPS"
  • "List all configured UPS devices"

When to use:

  • After power flickers - Verify UPS devices handled the event properly
  • Before maintenance - Check battery levels and estimated runtime
  • Regular monitoring - Track UPS health and battery condition
  • Capacity planning - Understand how long systems can run on battery

Common UPS Status Codes:

  • OL - Online (normal operation, AC power present)
  • OB - On Battery (power outage, running on battery)
  • LB - Low Battery (critically low battery, shutdown imminent)
  • CHRG - Charging (battery is charging)
  • RB - Replace Battery (battery needs replacement)

πŸ”’ Security

Automated Security Checks

This project includes automated security validation to prevent accidental exposure of sensitive data:

Install the pre-push git hook (recommended):

Copy & paste β€” that's it
# From project root
python helpers/install_git_hook.py

What it does:

  • Automatically runs helpers/pre_publish_check.py before every git push
  • Blocks pushes that contain potential secrets or sensitive data
  • Protects against accidentally committing API keys, passwords, or personal information

Manual security check:

Copy & paste β€” that's it
# Run security validation manually
python helpers/pre_publish_check.py

Bypass security check (use with extreme caution):

Copy & paste β€” that's it
# Only when absolutely necessary
git push --no-verify

Critical Security Practices

Configuration Files:

  • βœ… DO use .env.example as a template
  • βœ… DO keep .env file permissions restrictive (chmod 600 on Linux/Mac)
  • ❌ NEVER commit .env to version control
  • ❌ NEVER commit ansible_hosts.yml with real infrastructure
  • ❌ NEVER commit PROJECT_INSTRUCTIONS.md with real network topology

API Security:

  • βœ… DO use unique API keys for each service
  • βœ… DO rotate API keys regularly (every 90 days recommended)
  • βœ… DO use strong, randomly-generated keys (32+ characters)
  • ❌ NEVER expose Docker/Podman APIs to the internet
  • ❌ NEVER reuse API keys between environments

Network Security:

  • βœ… DO use firewall rules to restrict API access
  • βœ… DO implement VLAN segmentation
  • βœ… DO enable TLS/HTTPS where possible
  • ❌ NEVER expose management interfaces publicly

For detailed security guidance, see SECURITY.md

πŸ’» Compatibility

Tested Platforms

Developed and tested on:

  • OS: Windows 11
  • Claude Desktop: Version 0.13.64
  • Python: Version 3.13.8

Cross-Platform Notes

Windows: Fully tested and supported βœ… macOS: Should work but untested ⚠️ Linux: Should work but untested ⚠️

Known platform differences:

  • File paths in documentation are Windows-style
  • Path separators may need adjustment for Unix systems
  • .env file permissions should be set on Unix (chmod 600 .env)

Contributions for other platforms welcome!

πŸ› οΈ Development

πŸ“– First time contributing? Read CLAUDE.md for complete development guidance including architecture patterns, security requirements, and AI assistant workflows.

Getting Started

  1. Install security git hook (required for contributors):

    Copy & paste β€” that's it
    python helpers/install_git_hook.py
  2. Set up development environment:

    Copy & paste β€” that's it
    pip install -r requirements.txt
    cp .env.example .env
    # Edit .env with your test values

Testing MCP Servers Locally

Before submitting a PR, test your MCP server changes locally using the MCP Inspector tool.

Quick start:

Copy & paste β€” that's it
# MCP Inspector is an optional Node.js tool for interactive testing
# Option 1: Use npx (no installation needed - recommended)
npx @modelcontextprotocol/inspector uv --directory . run <server>_mcp.py

# Option 2: Install globally first (one-time setup)
npm install -g @modelcontextprotocol/inspector
# Then run: mcp-inspector uv --directory . run <server>_mcp.py

This opens a web-based debugger at http://localhost:5173 where you can:

  • See all available tools for the MCP server
  • Test each tool with sample arguments
  • Verify responses are properly formatted
  • Debug issues before submitting PRs

For detailed testing instructions, see the Testing MCP Servers Locally section in CONTRIBUTING.md.

Helper Scripts

The helpers/ directory contains utility scripts for development and deployment:

  • install_git_hook.py - Installs git pre-push hook for automatic security checks
  • pre_publish_check.py - Security validation script (runs automatically via git hook)

Usage:

Copy & paste β€” that's it
# Install security git hook
python helpers/install_git_hook.py

# Run security check manually  
python helpers/pre_publish_check.py

Project Structure

Copy & paste β€” that's it
Homelab-MCP/
β”œβ”€β”€ MCP Servers (7 production servers)
β”‚   β”œβ”€β”€ ansible_mcp_server.py      # Ansible inventory queries (integration in progress)
β”‚   β”œβ”€β”€ docker_mcp_podman.py       # Docker/Podman container monitoring
β”‚   β”œβ”€β”€ ollama_mcp.py              # Ollama AI model management
β”‚   β”œβ”€β”€ pihole_mcp.py              # Pi-hole DNS monitoring
β”‚   β”œβ”€β”€ ping_mcp_server.py         # Network connectivity testing
β”‚   β”œβ”€β”€ unifi_mcp_optimized.py     # Unifi network device monitoring
β”‚   └── ups_mcp_server.py          # UPS/NUT monitoring
β”‚
β”œβ”€β”€ Unified Server & Core Modules
β”‚   β”œβ”€β”€ homelab_unified_mcp.py     # Combines all servers (Docker entrypoint)
β”‚   β”œβ”€β”€ mcp_config_loader.py       # Secure environment variable loading
β”‚   β”œβ”€β”€ mcp_error_handler.py       # Centralized error handling
β”‚   └── ansible_config_manager.py  # Ansible inventory + enum generation
β”‚
β”œβ”€β”€ Utilities & Deprecated Tools
β”‚   β”œβ”€β”€ unifi_exporter.py          # Unifi data export utility
β”‚   └── mcp_registry_inspector.py  # MCP file management (⚠️ DEPRECATED v2.3.0)
β”‚
β”œβ”€β”€ Configuration & Examples
β”‚   β”œβ”€β”€ .env.example               # Configuration template (gitignored)
β”‚   β”œβ”€β”€ ansible_hosts.example.yml  # Ansible inventory example (gitignored)
β”‚   β”œβ”€β”€ PROJECT_INSTRUCTIONS.example.md # AI assistant guide template
β”‚   └── CLAUDE_CUSTOM.example.md   # Local customization template (gitignored)
β”‚
β”œβ”€β”€ Documentation
β”‚   β”œβ”€β”€ README.md                  # This file - user documentation
β”‚   β”œβ”€β”€ CLAUDE.md                  # AI assistant development guide
β”‚   β”œβ”€β”€ SECURITY.md                # Security guidelines
β”‚   β”œβ”€β”€ CONTRIBUTING.md            # Contribution guide
β”‚   β”œβ”€β”€ CHANGELOG.md               # Version history
β”‚   β”œβ”€β”€ MIGRATION_V3.md               # Version migration guide
β”‚   β”œβ”€β”€ CONTEXT_AWARE_SECURITY.md  # Security scanning docs
β”‚   β”œβ”€β”€ CI_CD_CHECKS.md            # CI/CD automation docs
β”‚   └── LICENSE                    # MIT License
β”‚
β”œβ”€β”€ Docker Deployment
β”‚   β”œβ”€β”€ Dockerfile                 # Container build configuration
β”‚   β”œβ”€β”€ docker-compose.yml         # Container orchestration (uses bjeans/homelab-mcp:latest)
β”‚   └── docker-entrypoint.sh       # Container startup script
β”‚
β”œβ”€β”€ Development Tools
β”‚   β”œβ”€β”€ helpers/
β”‚   β”‚   β”œβ”€β”€ install_git_hook.py    # Git pre-push hook installer
β”‚   β”‚   β”œβ”€β”€ pre_publish_check.py   # Security validation
β”‚   β”‚   β”œβ”€β”€ run_checks.py          # CI/CD check runner
β”‚   β”‚   └── requirements-dev.txt   # Development dependencies
β”‚   β”œβ”€β”€ requirements.txt           # Production Python dependencies
β”‚   └── .gitignore                 # Git ignore rules

Adding a New MCP Server

  1. Create the server file

    Copy & paste β€” that's it
    #!/usr/bin/env python3
    """
    My Service MCP Server
    Description of what it does
    """
    import asyncio
    from mcp.server import Server
    # ... implement tools ...
  2. Add configuration to .env.example

    Copy & paste β€” that's it
    # My Service Configuration
    MY_SERVICE_HOST=192.168.1.100
    MY_SERVICE_API_KEY=your-api-key
  3. Update documentation

    • Add server details to this README
    • Update PROJECT_INSTRUCTIONS.example.md
    • Update CLAUDE.md if adding new patterns or capabilities
    • Add security notes if applicable
  4. Test thoroughly

    • Test with real infrastructure
    • Verify error handling
    • Check for sensitive data leaks
    • Review security implications

Environment Variables

All MCP servers support two configuration methods:

1. Environment Variables (.env file)

  • Simple key=value pairs
  • Loaded automatically by each MCP server
  • Good for simple setups or testing

2. Ansible Inventory (recommended for production)

  • Centralized infrastructure definition
  • Supports complex host groupings
  • Better for multi-host environments
  • Set ANSIBLE_INVENTORY_PATH in .env

Coding Standards

  • Python 3.10+ syntax and features
  • Async/await for all I/O operations
  • Type hints where beneficial
  • Error handling for network operations
  • Logging to stderr for debugging
  • Security: Validate inputs, sanitize outputs

Testing Checklist

Before committing changes:

  • Security git hook installed (python helpers/install_git_hook.py)
  • Manual security check passes (python helpers/pre_publish_check.py)
  • No sensitive data in code or commits
  • Environment variables for all configuration
  • Error handling for network failures
  • Logging doesn't expose secrets
  • Documentation updated
  • Security implications reviewed
  • .gitignore updated if needed

πŸ“š Additional Resources

MCP Protocol

Related Projects

πŸ“„ License

MIT License - See LICENSE file for details

Copyright (c) 2025 Barnaby Jeans

🀝 Contributing

Contributions are welcome! Please see CONTRIBUTING.md for detailed guidelines.

For AI Assistants & Developers

πŸ“– Read CLAUDE.md first - This file contains:

  • Complete project architecture and development patterns
  • Security requirements and common pitfalls to avoid
  • Specific workflows for adding features and fixing bugs
  • AI assistant-specific guidance for working with this codebase

Quick Start for Contributors

  1. Install security git hook (python helpers/install_git_hook.py)
  2. Review security guidelines in SECURITY.md
  3. No sensitive data in commits (hook will block automatically)
  4. All configuration uses environment variables or Ansible
  5. Update documentation for any changes
  6. Test thoroughly with real infrastructure

Pull Request Process

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Test with your homelab setup
  5. Update README and other docs as needed
  6. Commit with clear messages (git commit -m 'Add amazing feature')
  7. Push to your fork (git push origin feature/amazing-feature)
  8. Open a Pull Request

Code Review Criteria

  • Security best practices followed
  • No hardcoded credentials or IPs
  • Proper error handling
  • Code follows existing patterns
  • Documentation is clear and complete
  • Changes are tested

πŸ™ Acknowledgments

  • Anthropic for Claude and MCP
  • The homelab community for inspiration
  • Contributors and testers

πŸ“ž Support


Remember: This project handles critical infrastructure. Always prioritize security and test changes in a safe environment first!