authorize_nanoleaf
Authorize connection to Nanoleaf smart lights by establishing secure pairing with devices currently in pairing mode.
Instructions
Authorize connection to Nanoleaf device (device must be in pairing mode)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:253-283 (handler)Handler for the 'authorize_nanoleaf' tool. Checks if primaryDevice exists, calls authorize() on it, and returns appropriate success or error response.case 'authorize_nanoleaf': if (!primaryDevice) { return { content: [ { type: 'text', text: 'No device connected. Please run connect_to_ip or discover_nanoleaf first.', }, ], }; } try { const authToken = await primaryDevice.authorize(); return { content: [ { type: 'text', text: `Successfully authorized! Auth token: ${authToken.substring(0, 8)}... (truncated for security)`, }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Authorization failed: ${error}`, }, ], }; }
- src/index.ts:168-175 (schema)Input schema definition for the 'authorize_nanoleaf' tool, registered in the ListTools response. No input parameters required.{ name: 'authorize_nanoleaf', description: 'Authorize connection to Nanoleaf device (device must be in pairing mode)', inputSchema: { type: 'object', properties: {}, }, },
- src/nanoleaf-client.ts:133-142 (helper)Implementation of the authorize method in NanoleafClient class. Sends POST request to /new endpoint to obtain authentication token and stores it.async authorize(): Promise<string> { try { const response = await this.httpClient.post('/new'); const authToken = response.data.auth_token; this.device.authToken = authToken; return authToken; } catch (error) { throw new Error('Failed to authorize. Make sure to hold the power button on your Nanoleaf device for 5-7 seconds.'); } }