Hue智控
通过 Claude 和其他 LLM 接口使用 OpenHue CLI 控制 [Philips Hue](https://www.philips-hue.com/) 灯光。
可用工具 (6 个)
该服务在 MCP 协议中暴露的工具,AI 可按需调用
get-lights 2 个参数
List all Hue lights or get details for a specific light
该工具无需必填参数,直接调用即可
control-light 5 个参数 需填 2 项
Control a specific Hue light
必填参数:target、action
get-rooms 1 个参数
List all rooms or get details for a specific room
该工具无需必填参数,直接调用即可
control-room 5 个参数 需填 2 项
Control all lights in a room
必填参数:target、action
get-scenes 1 个参数
List all scenes or get details for specific scenes
该工具无需必填参数,直接调用即可
activate-scene 3 个参数 需填 1 项
Activate a specific scene
必填参数:name
服务介绍
OpenHue MCP 服务器
一个通过 OpenHue CLI 使用 Claude 及其他 LLM 接口控制飞利浦 Hue 灯光的 MCP 服务器。
前提条件
- Node.js (v16 或更高版本)
- Docker
- Claude for Desktop(可选,用于测试)
桥接设置
在使用服务器之前,你需要用你的 Hue Bridge 设置 OpenHue CLI:
- 运行设置命令:
# On Linux/macOS:
docker run -v "${HOME}/.openhue:/.openhue" --rm --name=openhue -it openhue/cli setup
# On Windows (PowerShell):
docker run -v "${env:USERPROFILE}\.openhue:/.openhue" --rm --name=openhue -it openhue/cli setup
-
按照屏幕上的指示操作:
- CLI 将会搜索你的 Hue Bridge
- 当提示时按下 Hue Bridge 上的链接按钮
- 等待确认设置已完成
-
通过列出你的灯光来验证设置是否成功:
# On Linux/macOS:
docker run -v "${HOME}/.openhue:/.openhue" --rm --name=openhue -it openhue/cli get lights
# On Windows (PowerShell):
docker run -v "${env:USERPROFILE}\.openhue:/.openhue" --rm --name=openhue -it openhue/cli get lights
如果你能看到列出的灯光,那么设置就完成了,你可以开始使用 MCP 服务器了。
安装
- 克隆仓库:
git clone <your-repo-url>
cd claude-mcp-openhue
- 安装依赖项:
npm install
- 构建项目:
npm run build
- 运行服务器:
npm start
功能
此服务器通过 MCP 暴露以下功能:
灯光控制
- 列出所有灯光或获取特定灯光的详细信息
- 开关灯光
- 调整亮度
- 设置颜色
- 控制色温
房间控制
- 列出所有房间或获取房间详情
- 一起控制房间内的所有灯光
- 设置整个房间的亮度和颜色
场景管理
- 列出可用场景
- 以不同模式激活场景
- 按房间筛选场景
与 Claude Desktop 的使用
-
打开你的 Claude Desktop 配置文件:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
- macOS:
-
添加服务器配置:
{
"mcpServers": {
"hue": {
"command": "node",
"args": ["/absolute/path/to/build/index.js"]
}
}
}
-
重启 Claude Desktop
-
查找锤子图标以验证服务器已连接
示例命令
连接后,你可以向 Claude 提出自然语言问题,例如:
- "客厅里有哪些灯?"
- "打开厨房的所有灯"
- "将卧室灯光调到50%亮度"
- "将办公室灯光改为蓝色"
- "激活'放松'场景"
- "休息室有哪些可用场景?"
可用工具
get-lights
列出所有灯光或获取特定灯光的详细信息
{
lightId?: string; // Optional light ID or name
room?: string; // Optional room name filter
}
control-light
控制单个灯光
{
target: string; // Light ID or name
action: "on" | "off";
brightness?: number; // 0-100
color?: string; // Color name
temperature?: number; // 153-500 Mirek
}
get-rooms
列出所有房间或获取特定房间的详细信息
{
roomId?: string; // Optional room ID or name
}
control-room
控制房间内的所有灯光
{
target: string; // Room ID or name
action: "on" | "off";
brightness?: number;
color?: string;
temperature?: number;
}
get-scenes
列出可用场景
{
room?: string; // Optional room name filter
}
activate-scene
激活特定场景
{
name: string; // Scene name or ID
room?: string; // Optional room name
mode?: "active" | "dynamic" | "static";
}
开发
项目结构
.
├── src/
│ └── index.ts # Main server implementation
├── build/ # Compiled JavaScript
├── package.json
├── tsconfig.json
└── README.md
构建
npm run build
运行
npm start
故障排除
服务器无法连接
- 检查 Docker 是否正在运行
- 验证 OpenHue 配置是否存在
- 检查 Claude Desktop 日志
- 尝试直接运行 OpenHue CLI
命令失败
- 检查 OpenHue CLI 权限
- 验证灯光/房间/场景名称
- 检查 Docker 容器日志
- 验证 Hue Bridge 连接性
许可证
请注意,原文档中的代码块(如 #0、#1 等)保留不变。这些占位符应替换为实际的命令或配置内容。
MIT 许可
贡献指南
- Fork 该仓库
- 创建你的功能分支
- 提交你的更改
- 将更改推送到分支
- 创建一个新的 Pull Request