authorize_nanoleaf
Authorize connection to Nanoleaf smart lights in pairing mode through the Nanoleaf MCP Server for seamless integration and control.
Instructions
Authorize connection to Nanoleaf device (device must be in pairing mode)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Input Schema (JSON Schema)
{
"properties": {},
"type": "object"
}
Implementation Reference
- src/index.ts:253-283 (handler)Tool handler for 'authorize_nanoleaf' that checks if a device is connected and calls authorize() on NanoleafClient, returning success or error message.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 (registration)Registration of the 'authorize_nanoleaf' tool in the listTools response, including name, description, and empty input schema.{ 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)Core authorization logic in NanoleafClient class: sends POST to /new endpoint to obtain auth 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.'); } }