get-lights
List all connected Philips Hue lights or retrieve details for a specific light by ID or room. Integrates with OpenHue MCP Server for easy light management via LLM interfaces.
Instructions
List all Hue lights or get details for a specific light
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| lightId | No | Optional light ID or name to get specific light details | |
| room | No | Optional room name to filter lights |
Implementation Reference
- src/index.ts:228-246 (handler)The handler function for the 'get-lights' tool. Constructs a 'get light' OpenHue CLI command with optional lightId or room filters, appends --json, executes it using executeHueCommand, and returns the result as text content.case "get-lights": { let command = "get light"; if (args?.lightId) { command += ` "${args.lightId}"`; } if (args?.room) { command += ` --room "${args.room}"`; } command += " --json"; const result = await executeHueCommand(command); return { content: [ { type: "text", text: result, }, ], }; }
- src/index.ts:85-97 (schema)JSON input schema for the 'get-lights' tool, defining optional 'lightId' and 'room' string parameters.inputSchema: { type: "object", properties: { lightId: { type: "string", description: "Optional light ID or name to get specific light details", }, room: { type: "string", description: "Optional room name to filter lights", }, }, },
- src/index.ts:82-98 (registration)Tool registration in the listTools handler, specifying name, description, and inputSchema for 'get-lights'.{ name: "get-lights", description: "List all Hue lights or get details for a specific light", inputSchema: { type: "object", properties: { lightId: { type: "string", description: "Optional light ID or name to get specific light details", }, room: { type: "string", description: "Optional room name to filter lights", }, }, }, },
- src/index.ts:64-76 (helper)Helper function used by 'get-lights' handler to execute OpenHue CLI commands via Docker container, capturing stdout or throwing errors.async function executeHueCommand(command: string): Promise<string> { try { const { stdout, stderr } = await execAsync(buildDockerCommand(command)); if (stderr) { console.error("Command error:", stderr); throw new Error(stderr); } return stdout; } catch (error) { console.error("Execution error:", error); throw error; } }
- src/index.ts:22-25 (helper)Helper to build Docker command for running openhue/cli with mounted config, used indirectly by get-lights via executeHueCommand.const buildDockerCommand = (command: string) => { const configPath = getConfigPath(); return `docker run -v "${configPath}:/.openhue" --rm openhue/cli ${command}`; };