Skip to main content
Glama

connect_to_ip

Establish a connection to a Nanoleaf smart light device using its specific IP address and port number for subsequent control operations.

Instructions

Connect to a Nanoleaf device at a specific IP address

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ipYesIP address of the Nanoleaf device
portNoPort number (default: 16021)

Implementation Reference

  • MCP tool handler for 'connect_to_ip': extracts IP and port from arguments, calls NanoleafClient.connectToIP static method, initializes primaryDevice if successful, returns appropriate text response.
    case 'connect_to_ip':
      try {
        const ip = request.params.arguments?.ip as string;
        const port = (request.params.arguments?.port as number) || 16021;
        const device = await NanoleafClient.connectToIP(ip, port);
        if (device) {
          primaryDevice = new NanoleafClient(device);
          return {
            content: [
              {
                type: 'text',
                text: `Successfully connected to Nanoleaf device at ${ip}:${port}`,
              },
            ],
          };
        } else {
          return {
            content: [
              {
                type: 'text',
                text: `No Nanoleaf device found at ${ip}:${port}`,
              },
            ],
          };
        }
      } catch (error) {
        return {
          content: [
            {
              type: 'text',
              text: `Error connecting to ${request.params.arguments?.ip}: ${error}`,
            },
          ],
        };
      }
  • src/index.ts:149-167 (registration)
    Tool registration in ListToolsRequestSchema handler, including name, description, and input schema for 'connect_to_ip'.
    {
      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'],
      },
    },
  • Input schema definition for the 'connect_to_ip' tool.
      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'],
      },
    },
  • Core helper method NanoleafClient.connectToIP that probes the given IP/port for a Nanoleaf device by attempting HTTP/HTTPS requests and detecting valid responses or 403 auth required.
    static async connectToIP(ip: string, port: number = 16021): Promise<NanoleafDevice | null> {
      // Try different protocols and ports
      const attempts = [
        { ip, port, protocol: 'http' },
        { ip, port: 80, protocol: 'http' },
        { ip, port: 443, protocol: 'https' },
        { ip, port, protocol: 'https' }
      ];
    
      for (const attempt of attempts) {
        try {
          const httpClient = axios.create({
            baseURL: `${attempt.protocol}://${attempt.ip}:${attempt.port}/api/v1`,
            timeout: 5000,
            // Ignore SSL certificate errors for self-signed certs
            httpsAgent: attempt.protocol === 'https' ? new https.Agent({
              rejectUnauthorized: false
            }) : undefined
          });
          
          // Try to make a basic request to see if it's a Nanoleaf device
          const response = await httpClient.get('/');
          // If we get here without error, it's likely a Nanoleaf device
          return { ip: attempt.ip, port: attempt.port, protocol: attempt.protocol };
        } catch (error: any) {
          console.error(`Attempt ${attempt.protocol}://${attempt.ip}:${attempt.port} failed:`, error.message);
          // Check if it's a 403 Forbidden (typical for Nanoleaf without auth)
          if (error.response && error.response.status === 403) {
            console.error(`Found Nanoleaf device at ${attempt.protocol}://${attempt.ip}:${attempt.port} (403 Forbidden - needs auth)`);
            return { ip: attempt.ip, port: attempt.port, protocol: attempt.protocol };
          }
          // Continue to next attempt if other error
          continue;
        }
      }
      
      return null;
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the action ('connect to') but doesn't explain what this entails—whether it establishes a persistent session, validates connectivity, requires authentication, has side effects like network changes, or what happens on failure. For a connection tool with zero annotation coverage, this leaves critical behavior unspecified.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, direct sentence with zero wasted words. It's front-loaded with the core action and resource, making it highly efficient and easy to parse.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of a connection operation (likely involving network interaction and potential prerequisites), no annotations, and no output schema, the description is inadequate. It doesn't cover behavioral aspects like error handling, session management, or integration with sibling tools, leaving significant gaps for an AI agent to use it correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with clear descriptions for both parameters (IP address and port with default). The description adds no additional meaning beyond the schema, such as IP format examples or port usage context. Baseline 3 is appropriate when the schema fully documents parameters.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('connect to') and target resource ('Nanoleaf device at a specific IP address'), making the purpose immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'discover_nanoleaf' or 'authorize_nanoleaf', which might also involve connection-related operations.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., whether authorization is required first), when this connection is needed (e.g., before controlling the device), or how it relates to siblings like 'discover_nanoleaf' (which might find IPs).

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/srnetadmin/nanoleaf-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server