Skip to main content

FastMCP service for controlling Philips Hue lights

Project description

Philips Hue MCP Service

A FastMCP service that provides tools and resources for controlling Philips Hue lights through the Model Context Protocol.

Installation

  1. Install dependencies:
pip install fastmcp qhue requests

Or install from the project directory:

pip install -e .

Setup

1. Find your Hue Bridge IP

  • Open the Philips Hue app on your phone
  • Go to Settings > My Hue System > [Your Bridge Name]
  • Note the IP address

2. Create a Username/API Key

You need to create a username (API key) for your bridge:

  1. Press the physical button on your Hue bridge
  2. Within 30 seconds, run this Python script:
import requests
import json

bridge_ip = "192.168.1.123"  # Replace with your bridge IP
response = requests.post(f"http://{bridge_ip}/api", 
                        json={"devicetype": "hue_mcp_service#user"})
print(json.dumps(response.json(), indent=2))
  1. Save the returned username/API key

Usage

Running the Service

python hue_mcp_service.py

Available Tools

  • connect_to_bridge(bridge_ip, username) - Connect to your Hue bridge
  • turn_light_on(light_id) - Turn on a specific light
  • turn_light_off(light_id) - Turn off a specific light
  • set_light_brightness(light_id, brightness) - Set brightness (0-254)
  • set_light_color(light_id, hue, saturation) - Set color using hue/saturation values
  • set_light_xy_color(light_id, x, y) - Set color using CIE xy coordinates

Available Resources

  • lights - Get information about all lights
  • light/{light_id} - Get detailed information about a specific light
  • bridge-status - Get current bridge connection status

Example Usage

First, connect to your bridge:

connect_to_bridge("192.168.1.123", "your-username-here")

Then control your lights:

# Turn on light 1
turn_light_on("1")

# Set brightness to 50%
set_light_brightness("1", 127)

# Set to red color
set_light_color("1", 0, 254)

Color Values

Hue and Saturation

  • Hue: 0-65535 (color wheel position)
    • 0: Red
    • 10922: Yellow
    • 21845: Green
    • 32768: Cyan
    • 43690: Blue
    • 54613: Magenta
  • Saturation: 0-254 (color intensity, 0=white, 254=full color)

CIE xy Coordinates

  • x, y: 0.0-1.0 (precise color specification in CIE color space)
  • Common colors:
    • Red: (0.675, 0.322)
    • Green: (0.4091, 0.518)
    • Blue: (0.167, 0.04)
    • White: (0.3127, 0.329)

Requirements

  • Python 3.8+
  • FastMCP 2.0+
  • qhue 2.0+
  • requests 2.25+

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hue_mcp_service-0.1.0.tar.gz (12.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hue_mcp_service-0.1.0-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file hue_mcp_service-0.1.0.tar.gz.

File metadata

  • Download URL: hue_mcp_service-0.1.0.tar.gz
  • Upload date:
  • Size: 12.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.0

File hashes

Hashes for hue_mcp_service-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1d90a36ebc9dabb765b3bd1543a78e8a066e932c5f858a54c328cd239f3835c6
MD5 ed2af1130b14a0d2b0a2f32966b9868a
BLAKE2b-256 179dfd96a3bd28186ee9a41d90de58db82da5bf7edc577b92e73ba558d3cdc24

See more details on using hashes here.

File details

Details for the file hue_mcp_service-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for hue_mcp_service-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8e8ad4caa9a57941209fc7c0f2c85d2e63bf4f1f8893416e9733f3c708782f03
MD5 c3c270a01926f1d8d5f1928f4b837180
BLAKE2b-256 0874ae0ee7993801414d5d45d7cbb6e11a559770bdf672782643c414a16acdb1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page