Skip to main content
Glama
lenvolk
by lenvolk

list_lights

Retrieve all smart lights connected to your LIFX account to manage and control your lighting setup.

Instructions

Get lights belonging to the authenticated account

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tokenYesLIFX API token
selectorNoSelector for filtering lights (default: 'all')

Implementation Reference

  • Executes the list_lights tool by calling the LIFX API to fetch lights matching the selector and formatting a detailed text response listing each light's properties.
    case "list_lights": {
      const { token, selector = "all" } = args as { token: string; selector?: string };
      const lights = await makeLIFXRequest(`/lights/${selector}`, { token });
      
      return {
        content: [
          {
            type: "text",
            text: `Found ${lights.length} lights:\n\n${lights.map((light: LIFXLight) => 
              `• ${light.label} (${light.id})\n  Power: ${light.power}\n  Brightness: ${(light.brightness * 100).toFixed(1)}%\n  Color: H:${light.color.hue}° S:${(light.color.saturation * 100).toFixed(1)}% K:${light.color.kelvin}\n  Connected: ${light.connected ? 'Yes' : 'No'}\n  Group: ${light.group.name}\n  Location: ${light.location.name}`
            ).join('\n\n')}`,
          },
        ],
      };
    }
  • Defines the input schema for the list_lights tool, specifying required LIFX API token and optional selector.
    {
      name: "list_lights",
      description: "Get lights belonging to the authenticated account",
      inputSchema: {
        type: "object",
        properties: {
          token: { type: "string", description: "LIFX API token" },
          selector: { type: "string", description: "Selector for filtering lights (default: 'all')" },
        },
        required: ["token"],
      },
    },
  • src/index.ts:142-153 (registration)
    Registers the list_lights tool in the list returned by ListToolsRequestHandler.
    {
      name: "list_lights",
      description: "Get lights belonging to the authenticated account",
      inputSchema: {
        type: "object",
        properties: {
          token: { type: "string", description: "LIFX API token" },
          selector: { type: "string", description: "Selector for filtering lights (default: 'all')" },
        },
        required: ["token"],
      },
    },
  • TypeScript interface defining the structure of a LIFX light object, used in the handler for type safety and response formatting.
    interface LIFXLight {
      id: string;
      uuid: string;
      label: string;
      connected: boolean;
      power: string;
      color: {
        hue: number;
        saturation: number;
        kelvin: number;
      };
      brightness: number;
      group: {
        id: string;
        name: string;
      };
      location: {
        id: string;
        name: string;
      };
      product: {
        name: string;
        identifier: string;
        company: string;
        capabilities: {
          has_color: boolean;
          has_variable_color_temp: boolean;
          has_ir: boolean;
          has_chain: boolean;
          has_matrix: boolean;
          has_multizone: boolean;
        };
      };
    }
  • Helper function to make authenticated HTTP requests to the LIFX API, used by the list_lights handler and other tools.
    async function makeLIFXRequest(
      endpoint: string,
      options: {
        method?: string;
        body?: any;
        token: string;
      }
    ): Promise<any> {
      const { method = "GET", body, token } = options;
      
      const url = `${LIFX_API_BASE}${endpoint}`;
      const headers: Record<string, string> = {
        "Authorization": `Bearer ${token}`,
        "User-Agent": USER_AGENT,
      };
    
      if (body && (method === "POST" || method === "PUT")) {
        headers["Content-Type"] = "application/json";
      }
    
      try {
        const response = await fetch(url, {
          method,
          headers,
          body: body ? JSON.stringify(body) : undefined,
        });
    
        if (!response.ok) {
          const errorText = await response.text();
          throw new Error(`LIFX API error: ${response.status} ${response.statusText} - ${errorText}`);
        }
    
        // Some endpoints return empty responses
        const contentType = response.headers.get("content-type");
        if (contentType?.includes("application/json")) {
          return await response.json();
        }
        
        return await response.text();
      } catch (error) {
        throw new Error(`Failed to make LIFX API request: ${error instanceof Error ? error.message : String(error)}`);
      }
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool retrieves lights but lacks details on response format (e.g., list structure, pagination), error handling, rate limits, or authentication requirements beyond the token parameter. This leaves significant gaps for an agent to understand operational behavior.

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, efficient sentence with zero wasted words. It front-loads the core purpose ('Get lights') and is appropriately sized for a simple retrieval tool, making it easy to parse quickly.

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 lack of annotations and output schema, the description is incomplete. It doesn't explain what the return data looks like (e.g., light attributes, JSON structure), error cases, or authentication context beyond the token. For a tool with two parameters and no structured output, more behavioral context is needed.

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?

The input schema has 100% description coverage, clearly documenting both parameters. The description doesn't add any semantic details beyond what the schema provides (e.g., it doesn't explain what 'selector' values are valid or how filtering works). Baseline 3 is appropriate since the schema does the heavy lifting.

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 ('Get') and target resource ('lights belonging to the authenticated account'), making the tool's purpose immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'list_scenes' or 'set_state', which would require a more specific scope statement to earn a 5.

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., authentication context), compare it to other listing tools like 'list_scenes', or indicate scenarios where filtering with the 'selector' parameter is necessary versus optional.

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/lenvolk/mcp-lifx'

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