A production-ready MCP (Model Context Protocol) server that provides HTTP-based tools for controlling Philips Hue smart lighting systems. Designed for local network deployment in containerized environments like Kubernetes.
- π HTTPS with self-signed certificates - Secure TLS via nginx-local ingress for local network deployment
- π‘ List and control individual lights
- π¨ Adjust brightness and color temperature
- π Set colors using CIE xy color space
- π Control groups/rooms of lights
- π¬ List and activate scenes
- β‘ Full async/await support for optimal performance
- π₯ Health check endpoint for Kubernetes probes
- π Transport security with allowed hosts/origins configuration
- π³ Production-ready Kubernetes manifests with nginx-local ingress
- π ArgoCD GitOps deployment ready
- Python 3.10 or higher
- A Philips Hue Bridge connected to your network
- API key (username) for your Hue Bridge (see setup instructions below)
- Clone or download this repository:
cd ~/development/mcphue- Create a virtual environment and install dependencies:
Option A: Using uv (Recommended - Fast)
If you have uv installed:
uv venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
uv pip install -e .Option B: Using standard pip
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -e .Or install dependencies directly:
pip install mcp aiohue aiohttp pydantic python-dotenvYou can find your bridge IP address in several ways:
- Using the Philips Hue app (Settings > Hue Bridges > i icon)
- Using the discovery service: https://discovery.meethue.com/
- Checking your router's DHCP client list
To control your Hue Bridge, you need to create an API key (called "username" in Hue terminology):
- Press the physical button on your Hue Bridge
- Within 30 seconds, run one of these commands:
Using curl:
curl -X POST http://<BRIDGE_IP>/api \
-H "Content-Type: application/json" \
-d '{"devicetype":"hue-mcp-server#user"}'Using Python:
import requests
response = requests.post(
"http://<BRIDGE_IP>/api",
json={"devicetype": "hue-mcp-server#user"}
)
print(response.json())You'll receive a response like:
[{"success":{"username":"1234567890abcdef1234567890abcdef"}}]Save the username value - this is your API key.
- Copy the example environment file:
cp .env.example .env- Edit the
.envfile with your actual values:
HUE_BRIDGE_IP=192.168.1.x
HUE_API_KEY=your-api-key-hereThe .env file is already in .gitignore so your credentials won't be committed to version control.
Alternatively, you can set environment variables manually:
Linux/macOS:
export HUE_BRIDGE_IP="192.168.1.x"
export HUE_API_KEY="your-api-key-here"Windows (Command Prompt):
set HUE_BRIDGE_IP=192.168.1.x
set HUE_API_KEY=your-api-key-hereWindows (PowerShell):
$env:HUE_BRIDGE_IP="192.168.1.x"
$env:HUE_API_KEY="your-api-key-here"You can run the MCP server in a container (Podman or Docker), which is useful for isolation and deployment:
Using Podman (Recommended for WSL2):
cd ~/development/mcphue
# Build the image
podman build -t hue-mcp-server:latest .Using Docker:
cd ~/development/mcphue
# Build the image
docker build -t hue-mcp-server:latest .The default docker-compose.yml runs the server in network mode (HTTP).
Podman Compose:
# Install podman-compose if not already installed
pip install podman-compose
# Start the container in network mode (default)
podman-compose up -d
# View logs
podman-compose logs -f
# Stop the container
podman-compose downDocker Compose:
# Start the container in network mode (default)
docker-compose up -d
# View logs
docker-compose logs -f
# Stop the container
docker-compose downOnce running, the server is accessible at http://localhost:8080/mcp (or your machine's IP for remote access).
For stdio mode, use docker-compose.stdio.yml:
podman-compose -f docker-compose.stdio.yml up -d
# or
docker-compose -f docker-compose.stdio.yml up -dThe wrapper script run-docker-mcp.sh automatically detects Podman or Docker and allows Claude Desktop to communicate with the containerized MCP server.
Step 1: Build the container image first:
cd ~/development/mcphue
# Using Podman
podman build -t hue-mcp-server:latest .
# Or using Docker
docker build -t hue-mcp-server:latest .Step 2: Configure Claude Desktop
Edit your Claude Desktop config file based on your setup:
Option A: Linux (Claude Desktop on Linux)
Location: ~/.config/Claude/claude_desktop_config.json
{
"mcpServers": {
"hue": {
"command": "/home/micro/development/mcphue/run-docker-mcp.sh"
}
}
}Option B: Windows + WSL2 (MCP in WSL, Claude Desktop on Windows)
Location: %APPDATA%\Claude\claude_desktop_config.json
Full path example: C:\Users\YourUsername\AppData\Roaming\Claude\claude_desktop_config.json
{
"mcpServers": {
"hue": {
"command": "\\\\wsl.localhost\\Ubuntu\\home\\micro\\development\\mcphue\\run-mcp-windows.bat"
}
}
}Alternative Windows path formats (try if the above doesn't work):
{
"mcpServers": {
"hue": {
"command": "\\\\wsl$\\Ubuntu\\home\\micro\\development\\mcphue\\run-mcp-windows.bat"
}
}
}Or using the PowerShell script:
{
"mcpServers": {
"hue": {
"command": "powershell.exe",
"args": ["-File", "\\\\wsl.localhost\\Ubuntu\\home\\micro\\development\\mcphue\\run-mcp-windows.ps1"]
}
}
}Option C: macOS
Location: ~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"hue": {
"command": "/path/to/mcphue/run-docker-mcp.sh"
}
}
}Step 3: Restart Claude Desktop
The wrapper script will:
- Automatically detect whether you're using Podman or Docker
- Load environment variables from your
.envfile - Run the container with
--network hostto access your Hue Bridge - Handle stdio communication with Claude Desktop
- Automatically clean up the container when done
- The container uses
--network hostmode to access your Hue Bridge on the local network - This is necessary because the Hue Bridge typically doesn't have external access
- Podman on WSL2 works great with host networking
- If your container runtime doesn't support host networking, you may need to configure bridge networking differently
The server runs in HTTP mode by default, accessible on your local network:
# Start the server
hue-mcp-server
# Or using Python directly
python -m hue_mcp_server.fastmcp_http_serverThe server will start on http://0.0.0.0:8080 with the MCP endpoint at http://0.0.0.0:8080/mcp.
Environment Variables:
# Required
export HUE_BRIDGE_IP="10.1.1.207"
export HUE_API_KEY="your-api-key-here"
# Optional (defaults shown)
export MCP_HOST="0.0.0.0"
export MCP_PORT="8080"
# Optional: Transport security for local network
export MCP_ALLOWED_HOSTS="mcphue.local.shadyknollcave.io,mcphue.local.shadyknollcave.io:*"
export MCP_ALLOWED_ORIGINS="https://mcphue.local.shadyknollcave.io"Health Check:
curl http://localhost:8080/health
# {"status":"healthy","bridge_connected":true,"service":"hue-mcp-server"}This server includes production-ready Kubernetes manifests:
# Apply base manifests (default namespace: mcp)
kubectl apply -k k8s/overlays/production
# Check pod status
kubectl get pods -n mcp
# View logs
kubectl logs -n mcp -l app=mcphue
# Check health endpoint
kubectl port-forward -n mcp svc/mcphue 8080:8080
curl http://localhost:8080/healthManifest Structure:
k8s/base/- Base deployment, service, namespacek8s/overlays/production/- Production configuration with:- Resource limits and requests
- Replicas configuration
- Transport security settings
- nginx-local ingress for HTTPS with self-signed certificates
- SealedSecrets for secure credentials
The deployment includes:
- Liveness/Readiness probes -
/healthendpoint monitoring - Resource limits - CPU: 1, Memory: 1Gi (requests: 200m CPU, 256Mi memory)
- Horizontal Pod Autoscaler ready (replica patches included)
- TLS termination via nginx-local ingress with self-signed certificates
- HTTPS endpoints for secure MCP communication
Network mode allows Claude Desktop to connect to the MCP server over HTTP, enabling remote access and multi-computer setups.
Make sure your MCP server is running in network mode:
# Start the server (runs on http://0.0.0.0:8080 by default)
hue-mcp-server
# Or start with Docker/Podman
podman-compose up -dYou should see output like:
INFO: Hue MCP HTTP Server starting on http://0.0.0.0:8080
INFO: MCP endpoint: http://0.0.0.0:8080/mcp
Option A: Same Computer (Server and Claude Desktop on same machine)
- Use:
http://localhost:8080/mcp
Option B: Different Computer (Server on another machine)
- Find your server's IP address:
# On Linux/macOS ip addr show | grep "inet " | grep -v 127.0.0.1 # On Windows (in WSL or PowerShell) ipconfig | findstr IPv4
- Use:
http://YOUR_SERVER_IP:8080/mcp(e.g.,http://192.168.1.50:8080/mcp)
Test the health endpoint from the computer where Claude Desktop is installed:
# Replace localhost with your server IP if on different computer
curl http://localhost:8080/health
# Expected response:
# {"status":"healthy","bridge_connected":true,"service":"hue-mcp-server"}If you can't reach the health endpoint, check:
- Server is running (
podman psorps aux | grep hue_mcp_server) - Firewall allows port 8080
- Both computers are on the same network
Find your Claude Desktop config file:
| Platform | Config File Location |
|---|---|
| macOS | ~/Library/Application Support/Claude/claude_desktop_config.json |
| Windows | %APPDATA%\Claude\claude_desktop_config.jsonFull path: C:\Users\YourUsername\AppData\Roaming\Claude\claude_desktop_config.json |
| Linux | ~/.config/Claude/claude_desktop_config.json |
Edit the config file and add the Hue MCP server configuration:
For Same Computer:
{
"mcpServers": {
"hue": {
"url": "http://localhost:8080/mcp"
}
}
}For Different Computer (Remote Server):
{
"mcpServers": {
"hue": {
"url": "http://192.168.1.50:8080/mcp"
}
}
}Replace 192.168.1.50 with your actual server IP address
If you have other MCP servers configured, add the hue entry alongside them:
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/home/user"]
},
"hue": {
"url": "http://localhost:8080/mcp"
}
}
}Close Claude Desktop completely and restart it. The Hue MCP tools should now be available.
In Claude Desktop, try asking:
- "Can you list my Philips Hue lights?"
- "Turn on the living room lights"
Claude should be able to see and use the Hue MCP tools.
Claude Desktop can't connect to MCP server:
- Verify server is running:
curl http://YOUR_SERVER:8080/health - Check the Claude Desktop config file has the correct URL
- Ensure no typos in the URL (must end with
/mcp) - Try using IP address instead of hostname
Connection works locally but not from another computer:
- Check firewall settings on server machine
- Verify both computers are on the same network
- Try pinging the server:
ping YOUR_SERVER_IP - See NETWORK_SETUP.md for detailed firewall configuration
Tools show up but don't work:
- Check server logs:
podman logs hue-mcp-serveror check terminal output - Verify
.envfile has correctHUE_BRIDGE_IPandHUE_API_KEY - Test bridge connection:
curl http://YOUR_BRIDGE_IP/api/YOUR_API_KEY/lights
Advanced Configuration:
For detailed information on network setup, firewall configuration, and multi-computer deployment, see NETWORK_SETUP.md.
list_lights- List all lights with their current stateget_light_state- Get detailed state of a specific lightturn_light_on- Turn a light on (optionally set brightness)turn_light_off- Turn a light offset_brightness- Set brightness level (0-254)set_color_temp- Set color temperature in mireds (153-500)set_color- Set color using CIE xy coordinates
list_groups- List all groups/roomscontrol_group- Control all lights in a group at once
list_scenes- List all available scenesactivate_scene- Activate a predefined scene
Once configured with Claude, you can use natural language:
- "Turn on the living room lights"
- "Set the bedroom light to 50% brightness"
- "Make the kitchen lights warm white"
- "Activate my reading scene"
- "Show me all available lights"
- "Turn off all lights in the office"
pip install -e ".[dev]"
pytestblack src/
ruff check src/- Ensure your Hue Bridge is powered on and connected to your network
- Verify the bridge IP address hasn't changed
- Check that your API key is valid
- Make sure you're on the same network as the Hue Bridge
If your API key stops working:
- The bridge may have been reset
- Generate a new API key using the setup instructions
- Update your environment variables
- Check if the light is reachable using
list_lights - Ensure the light is powered on (physical switch)
- Try controlling it from the Philips Hue app first
HTTP-Based Enterprise Design:
fastmcp_http_server.py- FastMCP HTTP server with Streamable HTTP transport- Runs as long-running uvicorn service
- Exposes
/healthendpoint for Kubernetes probes - Exposes
/mcpendpoint for MCP protocol communication - Implements transport security (allowed hosts/origins)
hue_client.py- Async wrapper around aiohue library (Hue API v2)validation.py- Input validation for all tool parameters- Container runs HTTP mode by default for production deployment
Transport Security: The HTTP server supports security restrictions for production use:
MCP_ALLOWED_HOSTS- Whitelist allowed hostnamesMCP_ALLOWED_ORIGINS- Whitelist CORS origins- DNS rebinding protection enabled by default
MIT License - see LICENSE file for details
Contributions are welcome! Please feel free to submit a Pull Request.