set_color
Adjust the hue and saturation of Nanoleaf smart lights directly through the MCP server. Specify hue (0-360) and saturation (0-100) values for precise color customization.
Instructions
Set the color of the Nanoleaf lights
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| hue | Yes | Hue value (0-360) | |
| saturation | Yes | Saturation value (0-100) |
Input Schema (JSON Schema)
{
"properties": {
"hue": {
"description": "Hue value (0-360)",
"maximum": 360,
"minimum": 0,
"type": "number"
},
"saturation": {
"description": "Saturation value (0-100)",
"maximum": 100,
"minimum": 0,
"type": "number"
}
},
"required": [
"hue",
"saturation"
],
"type": "object"
}
Implementation Reference
- src/index.ts:345-356 (handler)MCP tool handler for 'set_color' that extracts hue and saturation from arguments and calls primaryDevice.setColorcase 'set_color': const hue = request.params.arguments?.hue as number; const saturation = request.params.arguments?.saturation as number; await primaryDevice.setColor(hue, saturation); return { content: [ { type: 'text', text: `Color set to hue: ${hue}, saturation: ${saturation}`, }, ], };
- src/index.ts:97-118 (registration)Registration of the 'set_color' tool in the listTools response, including input schema definition{ name: 'set_color', description: 'Set the color of the Nanoleaf lights', inputSchema: { type: 'object', properties: { hue: { type: 'number', description: 'Hue value (0-360)', minimum: 0, maximum: 360, }, saturation: { type: 'number', description: 'Saturation value (0-100)', minimum: 0, maximum: 100, }, }, required: ['hue', 'saturation'], }, },
- src/nanoleaf-client.ts:177-188 (helper)Implementation of setColor method in NanoleafClient that sends HTTP PUT request to update hue and saturation on the deviceasync setColor(hue: number, saturation: number): Promise<void> { if (hue < 0 || hue > 360) { throw new Error('Hue must be between 0 and 360'); } if (saturation < 0 || saturation > 100) { throw new Error('Saturation must be between 0 and 100'); } await this.httpClient.put(this.getAuthUrl('/state'), { hue: { value: hue }, sat: { value: saturation } }); }