set_brightness
Adjust the brightness level of Nanoleaf smart lights between 0 and 100 using the MCP server. Enables precise control through compatible clients for optimal lighting.
Instructions
Set the brightness of the Nanoleaf lights
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| brightness | Yes | Brightness level (0-100) |
Implementation Reference
- src/index.ts:333-343 (handler)MCP tool handler for 'set_brightness': extracts brightness parameter, calls NanoleafClient.setBrightness, and returns success message.case 'set_brightness': const brightness = request.params.arguments?.brightness as number; await primaryDevice.setBrightness(brightness); return { content: [ { type: 'text', text: `Brightness set to ${brightness}%`, }, ], };
- src/index.ts:81-96 (schema)Input schema definition for the set_brightness tool, specifying brightness as a required number between 0-100.{ name: 'set_brightness', description: 'Set the brightness of the Nanoleaf lights', inputSchema: { type: 'object', properties: { brightness: { type: 'number', description: 'Brightness level (0-100)', minimum: 0, maximum: 100, }, }, required: ['brightness'], }, },
- src/index.ts:54-178 (registration)Registers the set_brightness tool in the MCP server's listTools handler.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [ { name: 'get_nanoleaf_info', description: 'Get information about the Nanoleaf device', inputSchema: { type: 'object', properties: {}, }, }, { name: 'turn_on_nanoleaf', description: 'Turn on the Nanoleaf lights', inputSchema: { type: 'object', properties: {}, }, }, { name: 'turn_off_nanoleaf', description: 'Turn off the Nanoleaf lights', inputSchema: { type: 'object', properties: {}, }, }, { name: 'set_brightness', description: 'Set the brightness of the Nanoleaf lights', inputSchema: { type: 'object', properties: { brightness: { type: 'number', description: 'Brightness level (0-100)', minimum: 0, maximum: 100, }, }, required: ['brightness'], }, }, { 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'], }, }, { name: 'set_effect', description: 'Set an effect on the Nanoleaf lights', inputSchema: { type: 'object', properties: { effect: { type: 'string', description: 'Name of the effect to apply', }, }, required: ['effect'], }, }, { name: 'get_effects', description: 'Get list of available effects', inputSchema: { type: 'object', properties: {}, }, }, { name: 'discover_nanoleaf', description: 'Discover Nanoleaf devices on the network', inputSchema: { type: 'object', properties: {}, }, }, { name: 'connect_to_ip', description: 'Connect to a Nanoleaf device at a specific IP address', inputSchema: { type: 'object', properties: { ip: { type: 'string', description: 'IP address of the Nanoleaf device', }, port: { type: 'number', description: 'Port number (default: 16021)', default: 16021, }, }, required: ['ip'], }, }, { name: 'authorize_nanoleaf', description: 'Authorize connection to Nanoleaf device (device must be in pairing mode)', inputSchema: { type: 'object', properties: {}, }, }, ], }; });
- src/nanoleaf-client.ts:168-175 (helper)Core implementation of brightness setting in NanoleafClient class: validates input and sends PUT request to Nanoleaf API state endpoint.async setBrightness(brightness: number): Promise<void> { if (brightness < 0 || brightness > 100) { throw new Error('Brightness must be between 0 and 100'); } await this.httpClient.put(this.getAuthUrl('/state'), { brightness: { value: brightness } }); }