Skip to main content
Glama
tebinraouf
by tebinraouf

change_hue_light

Control Philips Hue lights by adjusting brightness, color, and power state. Set specific light parameters including hue, saturation, and on/off status through the Hue MCP Server.

Instructions

Change the state of a Philips Hue light.

Args: light_id: The ID of the light to control (1-based index) brightness: Brightness level (0-254), where 0 is minimum and 254 is maximum hue: Hue color value (0-65535), where 0 and 65535 are red, 25500 is green, and 46920 is blue saturation: Color saturation (0-254), where 0 is white and 254 is most saturated on: Turn the light on (True) or off (False)

Returns: A message indicating the result of the operation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
light_idYes
brightnessNo
hueNo
saturationNo
onNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • main.py:48-127 (handler)
    The main handler function for the 'change_hue_light' tool. It connects to the Philips Hue Bridge, validates input parameters, constructs a command dictionary based on provided arguments (light_id, brightness, hue, saturation, on), and updates the light's state accordingly. Returns success or error messages.
    def change_hue_light(
        light_id: int,
        brightness: Optional[int] = None,
        hue: Optional[int] = None,
        saturation: Optional[int] = None,
        on: Optional[bool] = None
    ) -> str:
        """
        Change the state of a Philips Hue light.
        
        Args:
            light_id: The ID of the light to control (1-based index)
            brightness: Brightness level (0-254), where 0 is minimum and 254 is maximum
            hue: Hue color value (0-65535), where 0 and 65535 are red, 25500 is green, and 46920 is blue
            saturation: Color saturation (0-254), where 0 is white and 254 is most saturated
            on: Turn the light on (True) or off (False)
        
        Returns:
            A message indicating the result of the operation
        """
        try:
            bridge = get_bridge()
            
            # Verify we have lights
            if not bridge.lights:
                return "Error: No lights found on the Hue Bridge. Please check your bridge connection."
            
            # Get the light (phue uses 1-based indexing)
            if light_id < 1 or light_id > len(bridge.lights):
                return f"Error: Light ID {light_id} is out of range. Available lights: 1-{len(bridge.lights)}"
            
            light = bridge.lights[light_id - 1]
            
            # Build the command dictionary
            command = {}
            
            if on is not None:
                command['on'] = on
            
            if brightness is not None:
                if not 0 <= brightness <= 254:
                    return f"Error: Brightness must be between 0 and 254, got {brightness}"
                command['bri'] = brightness
            
            if hue is not None:
                if not 0 <= hue <= 65535:
                    return f"Error: Hue must be between 0 and 65535, got {hue}"
                command['hue'] = hue
            
            if saturation is not None:
                if not 0 <= saturation <= 254:
                    return f"Error: Saturation must be between 0 and 254, got {saturation}"
                command['sat'] = saturation
            
            # Apply the command
            if command:
                # Use the light's state property to set multiple values at once
                for key, value in command.items():
                    setattr(light, key, value)
                
                status_parts = []
                if 'on' in command:
                    status_parts.append(f"turned {'on' if command['on'] else 'off'}")
                if 'bri' in command:
                    status_parts.append(f"brightness set to {command['bri']}")
                if 'hue' in command:
                    status_parts.append(f"hue set to {command['hue']}")
                if 'sat' in command:
                    status_parts.append(f"saturation set to {command['sat']}")
                
                return f"Successfully updated light {light_id} ({light.name}): {', '.join(status_parts)}"
            else:
                return f"No changes specified for light {light_id} ({light.name})"
                
        except ValueError as e:
            return f"Configuration error: {str(e)}"
        except IndexError:
            return f"Error: Light {light_id} not found. Please check the light ID."
        except Exception as e:
            return f"Error controlling light: {str(e)}"
  • main.py:47-47 (registration)
    The @mcp.tool() decorator registers the change_hue_light function as an MCP tool with FastMCP server.
    @mcp.tool()
  • main.py:48-67 (schema)
    Function signature and docstring define the tool schema: parameters light_id (int), brightness (Optional[int]), hue (Optional[int]), saturation (Optional[int]), on (Optional[bool]), with ranges and descriptions.
    def change_hue_light(
        light_id: int,
        brightness: Optional[int] = None,
        hue: Optional[int] = None,
        saturation: Optional[int] = None,
        on: Optional[bool] = None
    ) -> str:
        """
        Change the state of a Philips Hue light.
        
        Args:
            light_id: The ID of the light to control (1-based index)
            brightness: Brightness level (0-254), where 0 is minimum and 254 is maximum
            hue: Hue color value (0-65535), where 0 and 65535 are red, 25500 is green, and 46920 is blue
            saturation: Color saturation (0-254), where 0 is white and 254 is most saturated
            on: Turn the light on (True) or off (False)
        
        Returns:
            A message indicating the result of the operation
        """
  • main.py:30-44 (helper)
    get_bridge() utility caches and returns the phue Bridge instance, initialized from HUE_BRIDGE_IP env var.
    def get_bridge() -> Bridge:
        """Get or initialize the Hue Bridge connection."""
        global _bridge_instance
        
        if not BRIDGE_IP:
            raise ValueError(
                "HUE_BRIDGE_IP environment variable not set. "
                "Please set it to your Hue Bridge IP address."
            )
        
        # Reuse existing connection or create new one
        if _bridge_instance is None:
            _bridge_instance = Bridge(BRIDGE_IP)
        
        return _bridge_instance
Behavior2/5

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

No annotations are provided, so the description carries full burden. It states the tool changes light state, implying mutation, but doesn't disclose behavioral traits like required permissions, rate limits, error conditions, or whether changes are reversible. The description adds minimal context beyond the basic action.

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

Conciseness4/5

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

The description is well-structured with clear sections (Args, Returns) and front-loaded purpose statement. Each sentence earns its place by providing essential information. Minor improvement possible by integrating parameter details more seamlessly rather than as a separate list.

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

Completeness4/5

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

Given 5 parameters with 0% schema coverage and no annotations, the description does an excellent job explaining parameter semantics. The output schema exists, so return values needn't be detailed. However, it lacks behavioral context for a mutation tool (e.g., error handling, side effects), which slightly reduces completeness.

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

Parameters5/5

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

Schema description coverage is 0%, so the description must compensate fully. It provides detailed semantics for all 5 parameters: light_id (1-based index), brightness (0-254 range with min/max), hue (0-65535 range with color mappings), saturation (0-254 range with white/most saturated), and on (True/False for on/off). This adds substantial value beyond the bare schema.

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

Purpose5/5

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

The description clearly states the verb ('Change') and resource ('state of a Philips Hue light'), making the purpose specific and unambiguous. It distinguishes from the sibling tool 'list_hue_lights' by focusing on state modification rather than listing.

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

Usage Guidelines3/5

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

The description implies usage for controlling a specific light's state, but lacks explicit guidance on when to use this tool versus alternatives or any prerequisites. It doesn't mention the sibling tool 'list_hue_lights' as a way to discover light IDs, which would be helpful context.

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/tebinraouf/hue-mcp'

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