hue_mcp
A production-ready Model Context Protocol (MCP) server that enables Claude to control Philips Hue lights through natural language commands.
README
Hue MCP Server
A production-ready Model Context Protocol (MCP) server that enables Claude to control Philips Hue lights through natural language commands. Built with FastMCP framework and designed for seamless integration with Claude Desktop.
Features
- š Room-based Control: Control lights by room (kitchen, bedroom, office, basement, living_room)
- š” Individual Light Control: Control specific lights by ID (1-17)
- š Light Discovery: List all lights and get their current states
- š Bridge Integration: Discover and test connectivity to Hue bridge
- ā” High Performance: Async operations with connection pooling and rate limiting
- š”ļø Error Handling: Comprehensive error handling with retry logic
- š Production Ready: Full test coverage, logging, and monitoring
Available MCP Tools
| Tool | Description | Parameters |
|---|---|---|
hue_control_light |
Control individual light by ID | light_id, action, brightness?, color_temp? |
hue_control_room |
Control all lights in a room | room, action, brightness?, color_temp? |
hue_get_light_state |
Get current state of a light | light_id |
hue_list_lights |
List all lights and states | None |
hue_discover_bridge |
Test bridge connectivity | None |
Supported Rooms
kitchen- Controls lights: 10, 12, 13, 17 (stove_1, toaster_1, toaster_2, stove_2)bedroom- Controls lights: 1, 4 (neals_lamp, bonnies_lamp)office- Controls lights: 7 (office)basement- Controls lights: 5, 6, 14, 15, 16 (basement_e, basement_w, stairway, batcave_color_1, batcave_color_2)living_room- Controls lights: 3 (small_reading_lamp)all- Controls all lights using group 0
Supported Actions
on- Turn lights onoff- Turn lights offtoggle- Toggle light state
Installation
Prerequisites
- Python 3.8 or higher
- Philips Hue Bridge on local network
- Bridge username (already configured for IP 192.168.1.64)
Install Dependencies
# Install the package
pip install -e .
# Or install with development dependencies
pip install -e ".[dev]"
Environment Configuration
-
Copy the environment template:
cp .env.example .env -
Edit
.envfile if needed (default values work for the configured setup):HUE_BRIDGE_IP=192.168.1.64 HUE_USERNAME=cJdzxhKlxr2h92jwDkTv-DvpOxglPxn147UEg1Gp LOG_LEVEL=INFO
Usage
Running the MCP Server
# Run directly
python -m hue_mcp
# Or using the console script
hue-mcp
Claude Desktop Integration
Add this configuration to your Claude Desktop MCP settings:
{
"mcpServers": {
"hue-control": {
"command": "python",
"args": ["-m", "hue_mcp"],
"cwd": "/path/to/hue-mcp-server"
}
}
}
Natural Language Examples
Once integrated with Claude Desktop, you can use natural language commands:
- "Turn on the kitchen lights" ā Turns on lights 10, 12, 13, 17
- "Set office light to 50% brightness" ā Dims office light (ID 7) to ~127 brightness
- "Turn off all lights" ā Turns off all lights using group control
- "What lights are currently on?" ā Lists all lights with their current states
- "Toggle the bedroom lights" ā Toggles lights 1 and 4
Testing
Run Unit Tests
# Run all tests
pytest
# Run with coverage
pytest --cov=src --cov-report=term-missing
# Run specific test file
pytest tests/test_hue_client.py -v
Test Bridge Connectivity
# Test basic connectivity
python -c "
import asyncio
from src.hue_mcp.hue_client import AsyncHueClient
async def test():
async with AsyncHueClient() as client:
success = await client.test_connection()
print(f'Bridge connection: {\"SUCCESS\" if success else \"FAILED\"}')
asyncio.run(test())
"
Development
Code Quality
# Linting and formatting
ruff check src/ --fix
ruff format src/
# Type checking
mypy src/
# Run all quality checks
ruff check . --fix && mypy src/ && ruff format .
Project Structure
hue-mcp-server/
āāā src/hue_mcp/
ā āāā __init__.py # Package initialization
ā āāā __main__.py # CLI entry point
ā āāā server.py # Main MCP server
ā āāā hue_client.py # Async HTTP client with rate limiting
ā āāā light_manager.py # Business logic and room mappings
ā āāā config.py # Configuration management
ā āāā tools/ # MCP tool implementations
ā āāā light_control.py # Individual light control
ā āāā room_control.py # Room-based control
ā āāā discovery.py # Light discovery and bridge testing
āāā tests/ # Comprehensive test suite
āāā pyproject.toml # Project configuration
āāā README.md # This file
āāā .env.example # Environment template
Performance
- Light Operations: Under 1 second response time
- Room Operations: Under 3 seconds for multiple lights
- Rate Limiting: 10 light operations/second, 1 group operation/second
- Connection Pooling: Optimized HTTP connections with keepalive
- Concurrent Operations: Up to 5 concurrent light operations per room
Error Handling
The server includes comprehensive error handling for:
- Network Issues: Connection timeouts, DNS failures
- Bridge Errors: Invalid light IDs, bridge unavailable
- Rate Limiting: Automatic retry with exponential backoff
- Validation Errors: Invalid parameters, out-of-range values
Configuration
Environment Variables
| Variable | Default | Description |
|---|---|---|
HUE_BRIDGE_IP |
192.168.1.64 |
IP address of Hue bridge |
HUE_USERNAME |
(configured) | Bridge authentication username |
LOG_LEVEL |
INFO |
Logging level (DEBUG, INFO, WARNING, ERROR) |
HUE_TIMEOUT_CONNECT |
5.0 |
Connection timeout (seconds) |
HUE_TIMEOUT_READ |
10.0 |
Read timeout (seconds) |
HUE_MAX_CONNECTIONS |
10 |
Maximum HTTP connections |
HUE_LIGHT_RATE_LIMIT |
10 |
Light operations per second |
HUE_GROUP_RATE_LIMIT |
1.0 |
Group operations per second |
Troubleshooting
Common Issues
Bridge Not Found
Error: Failed to connect to Hue bridge at 192.168.1.64
Solution: Verify bridge IP and network connectivity
Authentication Failed
Error: Invalid username/authentication
Solution: Verify HUE_USERNAME in .env file
Rate Limiting
Warning: Rate limited, retrying...
Solution: Normal behavior, requests will retry automatically
Debugging
Enable debug logging:
export LOG_LEVEL=DEBUG
python -m hue_mcp
Bridge Information
- IP Address: 192.168.1.64
- Username: cJdzxhKlxr2h92jwDkTv-DvpOxglPxn147UEg1Gp
- Light Range: IDs 1-17
- Configured Rooms: kitchen, bedroom, office, basement, living_room
License
MIT License - see LICENSE file for details.
Contributing
- Fork the repository
- Create a feature branch
- Make changes with tests
- Run quality checks:
ruff check . --fix && mypy src/ && pytest - Submit a pull request
Built with ā¤ļø using FastMCP and designed for seamless Claude integration.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.