
hue mcp
用于通过 Model Context Protocol (MCP) 控制飞利浦 Hue 灯的服务器。
Repository Info
About This Server
用于通过 Model Context Protocol (MCP) 控制飞利浦 Hue 灯的服务器。
Model Context Protocol (MCP) - This server can be integrated with AI applications to provide additional context and capabilities, enabling enhanced AI interactions and functionality.
Documentation
Hue MCP Server
A Model Context Protocol (MCP) server for controlling Philips Hue lights. This package provides a simple way to control your Hue lights through MCP, making it easy to integrate with AI assistants and other tools.
Prerequisites
- Node.js 16 or higher
- A Philips Hue Bridge
- One or more Philips Hue lights
Running Locally
- Clone the repository:
git clone https://github.com/bennewton999/hue-mcp.git
cd hue-mcp
- Install dependencies:
npm install
- Build the project:
npm run build
- Start the server:
npm start
Getting Started
1. Find Your Hue Bridge IP
There are several ways to find your Hue Bridge IP:
a) Using the official Hue discovery endpoint:
curl https://discovery.meethue.com
b) Using the Hue mobile app:
- Open the Hue app
- Go to Settings > Hue Bridges
- Tap on the "i" icon next to your bridge
- Note down the IP address
c) Check your router's DHCP client list for a device named "Philips-hue"
2. Create a Hue Username/Token
You'll need to create a new user/token to control your Hue bridge. Here's how:
- Press the link button on your Hue Bridge (the large circular button)
- Within 30 seconds, run this command (replace YOUR_BRIDGE_IP with your bridge's IP):
curl -X POST http://YOUR_BRIDGE_IP/api -H "Content-Type: application/json" -d '{"devicetype":"mcp_hue_server"}'
The response will contain your username/token in the format:
[{"success":{"username":"your-username-here"}}]
3. Configure Environment Variables
Create a .env file or set these environment variables:
# For macOS/Linux
export HUE_BRIDGE_IP="YOUR_BRIDGE_IP"
export HUE_USERNAME="YOUR_USERNAME"
# For Windows (PowerShell)
$env:HUE_BRIDGE_IP="YOUR_BRIDGE_IP"
$env:HUE_USERNAME="YOUR_USERNAME"
Running the Server
Start the server:
hue-mcp
The server will start on port 3000 by default.
Using with Different Tools
VS Code
Development in VS Code
- Open the project in VS Code:
code .
-
Install recommended extensions:
- ESLint
- TypeScript and JavaScript Language Features
- Model Context Protocol
-
Available Tasks:
- Build:
⇧⌘B(Shift+Cmd+B) or run "Run Build Task" from Command Palette - Start Server: Use the integrated terminal and run
npm run dev - Debug: Press F5 or use the Run and Debug view
- Build:
Using with VS Code and GitHub Copilot
The Hue MCP server integrates with VS Code's agent mode in GitHub Copilot to enable natural language control of your Hue lights.
-
Prerequisites:
- Latest version of VS Code
- GitHub Copilot extension installed and configured
- MCP support enabled in VS Code (enabled by default in VS Code 1.99+)
-
Configure the MCP Server: Create a
.vscode/mcp.jsonfile in your workspace:{ "inputs": [ { "type": "promptString", "id": "hue-bridge-ip", "description": "Hue Bridge IP Address" }, { "type": "promptString", "id": "hue-username", "description": "Hue Bridge Username", "password": true } ], "servers": { "Hue Lights": { "type": "stdio", "command": "node", "args": ["./dist/index.js"], "env": { "HUE_BRIDGE_IP": "${input:hue-bridge-ip}", "HUE_USERNAME": "${input:hue-username}" } } } } -
Use with GitHub Copilot:
- Open the Chat view (⌃⌘I on macOS, Ctrl+Alt+I on Windows/Linux)
- Select "Agent mode" from the dropdown
- Click the "Tools" button to see available Hue commands
- Start controlling your lights with natural language! Examples:
- "Turn on the hallway light"
- "Set the desk light to bright red"
- "Start a disco effect on the living room lights"
-
Advanced Usage:
- Use
#to directly reference specific tools in your prompts - Use the Continue button dropdown to auto-approve specific actions
- View server logs through Command Palette > "MCP: List Servers" > "Show Output"
- Use
Debugging in VS Code
Launch configurations are included for debugging the server:
- Set breakpoints in your TypeScript files
- Press F5 to start debugging
- The Debug Console will show server output
- Use the Debug toolbar to:
- Step through code
- Inspect variables
- View call stack
- Set conditional breakpoints
VS Code Tasks
The following tasks are available:
npm: build- Compiles TypeScript to JavaScriptnpm: dev- Runs the server in development modenpm: start- Runs the compiled server
Using with Other MCP Tools
The server accepts JSON messages over TCP. Each message should be terminated with a newline character.
Available commands:
- Get all lights:
{"type": "get_lights"}
- Set light color:
{
"type": "set_color",
"lightId": "1",
"color": [255, 0, 0]
}
Development
To run the server locally during development:
- Clone the repository:
git clone https://github.com/bennewton999/hue-mcp.git
cd hue-mcp
- Install dependencies:
npm install
- Start in development mode:
npm run dev
Troubleshooting
Common Issues
-
"Cannot connect to bridge"
- Verify your bridge IP is correct
- Check if your bridge is powered on and connected to the network
- Try pinging your bridge:
ping YOUR_BRIDGE_IP
-
"Unauthorized"
- Make sure you've created a username/token
- Verify the username in your environment variables
- Try recreating the username by following step 2 again
-
"Cannot find lights"
- Ensure your Hue lights are powered on
- Check if lights appear in the Hue mobile app
- Try resetting your bridge
License
MIT
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Quick Start
Clone the repository
git clone https://github.com/bennewton999/hue-mcpInstall dependencies
cd hue-mcp
npm installFollow the documentation
Check the repository's README.md file for specific installation and usage instructions.
Repository Details
Recommended MCP Servers
Discord MCP
Enable AI assistants to seamlessly interact with Discord servers, channels, and messages.
Knit MCP
Connect AI agents to 200+ SaaS applications and automate workflows.
Apify MCP Server
Deploy and interact with Apify actors for web scraping and data extraction.
BrowserStack MCP
BrowserStack MCP Server for automated testing across multiple browsers.
Zapier MCP
A Zapier server that provides automation capabilities for various apps.