lifx-mcp-server

lifx-mcp-server

A Model Context Protocol server for controlling LIFX smart lights, enabling AI assistants to manage power, color, brightness, effects, and scenes.

Category
访问服务器

README

LIFX MCP Server

A comprehensive Model Context Protocol (MCP) server for controlling LIFX smart lights, built with TypeScript and Bun. This server provides seamless integration between AI assistants and LIFX lighting systems.

Features

💡 LIFX Control Tools

  • List Lights: Discover and list all LIFX lights with detailed information
  • Set State: Control light power, color, brightness, and transitions
  • Toggle Power: Smart power toggling based on current state
  • Effects: Apply breathe, pulse, and other lighting effects
  • Scenes: List and activate LIFX scenes
  • Color Validation: Validate and convert color formats

📚 LIFX Resources

  • Server Information: Runtime information and LIFX API status
  • Color Examples: Comprehensive guide to LIFX color formats
  • Selector Examples: Examples of LIFX light selector syntax

💬 Smart Prompts

  • Lighting Scenes: Generate custom lighting setups for moods and activities
  • Troubleshooting: Diagnose and fix LIFX lighting issues
  • Color Recommendations: Get scientifically-backed color suggestions

🚀 Transport Support

  • Stdio Transport: For Claude Desktop and command-line integration
  • HTTP Transport: For web-based clients with session management

Installation

Prerequisites

  • Bun installed on your system
  • Node.js v18+ (for compatibility)
  • LIFX API token from LIFX Cloud

Setup

# Clone or create the project
cd lifx-mcp-server

# Install dependencies
bun install

# Configure your LIFX API token
cp .env.example .env
# Edit .env and add your LIFX_API_TOKEN

Get Your LIFX API Token

  1. Go to LIFX Cloud Settings
  2. Generate a new personal access token
  3. Copy the token to your .env file or pass it as a command line argument

Usage

Stdio Mode (for Claude Desktop, etc.)

# Start with token from environment
bun run start:stdio

# Or pass token directly
bun run src/index.ts --token=YOUR_LIFX_TOKEN

# Development mode with auto-reload
bun run dev

HTTP Mode (for web clients)

# Start HTTP server (requires token in .env)
bun run start:http

# The server will be available at:
# http://localhost:3000

Configuration for Claude Desktop

Add this to your Claude Desktop configuration:

{
  "mcpServers": {
    "lifx-mcp-server": {
      "command": "bun",
      "args": ["run", "src/index.ts", "--token=YOUR_LIFX_TOKEN"],
      "cwd": "/path/to/your/lifx-mcp-server"
    }
  }
}

LIFX Tools Reference

list-lights

Discover and list LIFX lights with detailed information.

Parameters:

  • selector: string (default: "all") - Light selector (e.g., "all", "label:Kitchen", "group:Living Room")

Example:

{
  "name": "list-lights",
  "arguments": {
    "selector": "group:Living Room"
  }
}

set-state

Control light properties including power, color, brightness.

Parameters:

  • selector: string (default: "all") - Light selector
  • power: "on" | "off" (optional) - Power state
  • color: string (optional) - Color (e.g., "red", "#ff0000", "kelvin:3500")
  • brightness: number (optional) - Brightness (0.0 to 1.0)
  • duration: number (optional) - Transition duration in seconds
  • fast: boolean (optional) - Use fast mode for quicker response

Example:

{
  "name": "set-state",
  "arguments": {
    "selector": "label:Bedroom",
    "power": "on",
    "color": "blue saturation:0.5",
    "brightness": 0.7,
    "duration": 2
  }
}

toggle-power

Smart power toggle - turns off if any lights are on, turns on if all are off.

Parameters:

  • selector: string (default: "all") - Light selector
  • duration: number (optional) - Transition duration in seconds

breathe-effect

Apply a breathing effect to lights.

Parameters:

  • selector: string (default: "all") - Light selector
  • color: string - Effect color
  • fromColor: string (optional) - Starting color
  • period: number (default: 1.0) - Period in seconds
  • cycles: number (default: 1.0) - Number of cycles
  • persist: boolean (default: false) - Keep final color
  • powerOn: boolean (default: true) - Turn on lights if off
  • peak: number (default: 1.0) - Brightness peak (0.0 to 1.0)

pulse-effect

Apply a pulsing effect to lights.

Parameters:

  • selector: string (default: "all") - Light selector
  • color: string - Effect color
  • fromColor: string (optional) - Starting color
  • period: number (default: 1.0) - Period in seconds
  • cycles: number (default: 1.0) - Number of cycles
  • persist: boolean (default: false) - Keep final color
  • powerOn: boolean (default: true) - Turn on lights if off

list-scenes

List all available LIFX scenes in your account.

activate-scene

Activate a LIFX scene by UUID.

Parameters:

  • sceneUuid: string - Scene UUID
  • duration: number (optional) - Transition duration
  • ignore: string[] (optional) - Device IDs to ignore
  • overrides: object (optional) - State overrides

validate-color

Validate a color string and get its HSBK representation.

Parameters:

  • color: string - Color to validate

Color Format Guide

LIFX supports various color formats:

Named Colors

  • Basic: "red", "blue", "green", "yellow", "orange", "purple", "pink", "cyan", "white"
  • Extended: "gold", "coral", "lime", "navy", etc.

Hex Colors

  • Standard: "#ff0000", "#00ff00", "#0000ff"
  • Short: "#f00", "#0f0", "#00f"

HSL Format

  • "hue:120 saturation:1.0"
  • "hue:240 saturation:0.5 brightness:0.8"

Kelvin Temperature

  • "kelvin:2700" (warm white)
  • "kelvin:6500" (cool white)
  • "kelvin:9000" (very cool)

Combined Formats

  • "red brightness:0.3"
  • "blue saturation:0.5"
  • "kelvin:3500 brightness:0.8"

Light Selectors

LIFX uses powerful selectors to target specific lights:

Basic Selectors

  • all - All lights
  • id:d3b2f1d97452 - Specific light by ID

Label Selectors

  • label:Kitchen - Single light by label
  • label:Kitchen,Bedroom - Multiple lights by label

Group Selectors

  • group:Living Room - All lights in a group
  • group:Living Room,Kitchen - Multiple groups

Location Selectors

  • location:Home - All lights at a location
  • location:Home,Office - Multiple locations

Combined Selectors

  • group:Living Room label:Lamp - Intersection
  • location:Home group:Bedroom - Complex targeting

Example Usage Scenarios

1. Morning Routine

// Gradually turn on bedroom lights
{
  "name": "set-state",
  "arguments": {
    "selector": "group:Bedroom",
    "power": "on",
    "color": "kelvin:2700",
    "brightness": 0.3,
    "duration": 10
  }
}

2. Work Focus Setup

// Set office lights to cool white, high brightness
{
  "name": "set-state",
  "arguments": {
    "selector": "location:Office",
    "power": "on",
    "color": "kelvin:6500",
    "brightness": 0.9,
    "duration": 3
  }
}

3. Party Mode

// Apply colorful pulse effect
{
  "name": "pulse-effect",
  "arguments": {
    "selector": "all",
    "color": "hue:300 saturation:1.0",
    "period": 0.5,
    "cycles": 10,
    "persist": false
  }
}

4. Relaxation Scene

// Dim warm lights with breathing effect
{
  "name": "breathe-effect",
  "arguments": {
    "selector": "group:Living Room",
    "color": "kelvin:2200 brightness:0.2",
    "period": 4,
    "cycles": 5,
    "persist": true
  }
}

Development

Project Structure

src/
├── index.ts          # Main LIFX MCP server implementation
├── server-http.ts    # HTTP transport server
└── test-client.ts    # Test client for development

package.json         # Dependencies and scripts
tsconfig.json       # TypeScript configuration
.env                 # Environment configuration
README.md           # This file

Testing

# Run the test client
bun run test:manual

# Build for production
bun run build

# Format code
bun run format

# Lint code
bun run lint

Security & Best Practices

  • Store your LIFX API token securely
  • Use environment variables instead of hardcoding tokens
  • Be mindful of rate limits when making frequent API calls
  • Test selectors to ensure they target the correct lights
  • Use fast=true mode sparingly for better reliability

Troubleshooting

Common Issues

  1. API Token Invalid: Check your token at LIFX Cloud Settings
  2. No Lights Found: Verify lights are online and connected to WiFi
  3. Selector Not Working: Check light labels and group names in LIFX app
  4. Rate Limit Errors: Reduce frequency of API calls
  5. Effects Not Working: Ensure lights support the requested effect type

Debug Mode

Set DEBUG=true in your .env file for detailed API request/response logging.

License

MIT License - see LICENSE file for details.

Resources

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选