Skip to main content
Glama
LightWaveRF Link Plus MCP Server

LightWaveRF Link Plus MCP Server

by ryanisibor

LightWaveRF Link Plus MCP Server

A production-ready Model Context Protocol (MCP) server for controlling LightWaveRF Link Plus Smart Series devices. This server enables AI applications like Claude Desktop to discover, monitor, and control your smart home devices through a persistent WebSocket connection to the LightWaveRF cloud service.

Features

  • Device Discovery: List all devices with their capabilities and features

  • Status Monitoring: Read current state of any device (brightness, power, etc.)

  • Device Control: Turn devices on/off, adjust brightness, and control other features

  • Group Management: View room/group hierarchy and query devices by group

  • Persistent Connection: WebSocket connection with automatic reconnection

  • Token Management: Automatic authentication and token refresh

  • Comprehensive Error Handling: Clear, actionable error messages

  • Security Best Practices: Environment-based credentials, no hardcoded secrets

Related MCP server: lightwave-mcp

Prerequisites

  • Node.js 18 or higher

  • npm or yarn

  • A LightWaveRF Link Plus account (sign up at https://my.lightwaverf.com/)

  • LightWaveRF Link Plus hub connected to your network

Installation

  1. Clone or download this repository:

git clone <repository-url>
cd lightwave-mcp-server
  1. Install dependencies:

npm install
  1. Build the TypeScript code:

npm run build
  1. Create a .env file with your credentials:

cp .env.example .env
  1. Get your API credentials from the LightWaveRF app (RECOMMENDED):

    • Open the LightWaveRF mobile app

    • Go to Settings > API Integration

    • Copy the Basic token and Refresh Token

    Then edit .env and add your API tokens:

    LIGHTWAVE_API_TOKEN=your_api_token_from_app
    LIGHTWAVE_REFRESH_TOKEN=your_refresh_token_from_app

    Alternative: Use email/password (less secure):

    LIGHTWAVE_EMAIL=your.email@example.com
    LIGHTWAVE_PASSWORD=your_password_here

SECURITY WARNING: Never commit your .env file to version control. The .gitignore file is configured to exclude it.

Configuration

Environment Variables

The server supports two authentication methods. API tokens are strongly recommended for security and simplicity.

Variable

Description

Required

LIGHTWAVE_API_TOKEN

API token from LightWaveRF app (Settings > API Integration > Basic)

Yes

LIGHTWAVE_REFRESH_TOKEN

Refresh token from LightWaveRF app (Settings > API Integration > Refresh Token)

Yes

Method 2: Email/Password (Alternative)

Variable

Description

Required

LIGHTWAVE_EMAIL

Your LightWaveRF account email

Yes

LIGHTWAVE_PASSWORD

Your LightWaveRF account password

Yes

MCP Client Configuration

Claude Desktop

Add the server to your Claude Desktop configuration file:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json Windows: %APPDATA%/Claude/claude_desktop_config.json

Using API tokens (recommended):

{
  "mcpServers": {
    "lightwave": {
      "command": "node",
      "args": ["/absolute/path/to/lightwave-mcp-server/build/index.js"],
      "env": {
        "LIGHTWAVE_API_TOKEN": "your_api_token_from_app",
        "LIGHTWAVE_REFRESH_TOKEN": "your_refresh_token_from_app"
      }
    }
  }
}

Or using email/password (alternative):

{
  "mcpServers": {
    "lightwave": {
      "command": "node",
      "args": ["/absolute/path/to/lightwave-mcp-server/build/index.js"],
      "env": {
        "LIGHTWAVE_EMAIL": "your.email@example.com",
        "LIGHTWAVE_PASSWORD": "your_password_here"
      }
    }
  }
}

Important: Replace /absolute/path/to/lightwave-mcp-server with the actual path to this directory.

Other MCP Clients

For other MCP clients, use the stdio transport with the following command:

node /path/to/lightwave-mcp-server/build/index.js

Ensure the environment variables are set in the client's configuration.

Available Tools

1. list_devices

Lists all LightWaveRF devices with their IDs, names, types, and available features.

Parameters: None

Returns: Device list with:

  • Device ID (needed for status queries)

  • Device name

  • Product type

  • Available features (with feature IDs and writable flags)

Example Use:

User: "What devices do I have?"
Assistant: [Calls list_devices to show all devices]

2. get_device_status

Gets the current status of a specific device including power state, brightness, and feature values.

Parameters:

  • deviceId (string, required): The device ID from list_devices

Returns: Current device state with:

  • Device name and type

  • All feature values (brightness, power, etc.)

  • Feature status indicators

Example Use:

User: "What's the brightness of the living room light?"
Assistant: [First calls list_devices to find device ID, then calls get_device_status]

3. control_device

Controls a device by writing to one of its features (turn on/off, set brightness, etc.).

Parameters:

  • featureId (string, required): The feature ID to control (from get_device_status)

  • value (number, required): Value to set

    • For switches: 0 = off, 1 = on

    • For dimmers: 0-100 = brightness percentage

Returns: Success confirmation message

Example Use:

User: "Turn off the bedroom light"
Assistant: [Finds device and switch feature ID, then calls control_device with value=0]

User: "Turn on the bedroom light"
Assistant: [Finds device and switch feature ID, then calls control_device with value=1]

User: "Set kitchen light to 50%"
Assistant: [Finds dimLevel feature ID, then calls control_device with value=50]

4. list_groups

Gets the complete room and group hierarchy including all groups and their contained devices.

Parameters: None

Returns: Hierarchical structure of:

  • All groups/rooms with their IDs

  • Devices within each group

  • Nested subgroups

Example Use:

User: "Show me how my devices are organized"
Assistant: [Calls list_groups to display room structure]

5. get_group_devices

Lists all devices within a specific group or room.

Parameters:

  • groupId (string, required): The group ID from list_groups

Returns: List of devices in the group with their IDs and types

Example Use:

User: "What devices are in the living room?"
Assistant: [Calls list_groups to find living room group ID, then calls get_group_devices]

Architecture

Components

  1. LightwaveClient (src/lightwaveClient.ts)

    • Manages WebSocket connection to LightWaveRF cloud

    • Handles authentication and token refresh

    • Implements request-response correlation

    • Provides reconnection with exponential backoff

    • Transaction ID management

  2. MCP Server (src/index.ts)

    • Implements MCP protocol using official SDK

    • Defines tool schemas with Zod validation

    • Routes tool calls to LightwaveClient

    • Formats responses for AI consumption

    • Comprehensive error handling

Connection Management

  • Persistent WebSocket: Single connection maintained for entire session

  • Automatic Reconnection: Exponential backoff strategy (up to 10 attempts)

  • Token Refresh: Tokens refreshed automatically 1 hour before expiry

  • Transaction Tracking: Unique transaction IDs for request-response correlation

Security Features

  • Environment-based Credentials: No hardcoded secrets

  • Token Management: Tokens stored in memory only, never persisted

  • Input Validation: All tool inputs validated with Zod schemas

  • Error Sanitization: Error messages don't expose credentials or tokens

  • HTTPS/WSS Only: All connections use TLS encryption

Development

Build the Project

npm run build

Watch Mode (Auto-rebuild)

npm run watch

Run Development Server

npm run dev

Testing

Using MCP Inspector

The MCP Inspector is the official tool for testing MCP servers:

  1. Install the MCP Inspector:

npx @modelcontextprotocol/inspector node build/index.js
  1. Set environment variables before running:

export LIGHTWAVE_EMAIL="your.email@example.com"
export LIGHTWAVE_PASSWORD="your_password_here"
npx @modelcontextprotocol/inspector node build/index.js
  1. The inspector will open in your browser, allowing you to:

    • View available tools

    • Test tool calls with different parameters

    • See request/response messages

    • Debug connection issues

Manual Testing

You can also test the server manually using stdio:

# Set environment variables
export LIGHTWAVE_EMAIL="your.email@example.com"
export LIGHTWAVE_PASSWORD="your_password_here"

# Run the server
node build/index.js

The server will wait for JSON-RPC messages on stdin and respond on stdout.

Troubleshooting

Connection Issues

Problem: "Failed to authenticate with LightWaveRF: Invalid credentials" Solution:

  • Verify your email and password are correct

  • Check that you can log in to https://my.lightwaverf.com/

  • Ensure there are no extra spaces in your credentials

Problem: "WebSocket is not connected" Solution:

  • Check your internet connection

  • Verify the LightWaveRF cloud service is accessible

  • Wait for automatic reconnection (up to 10 attempts)

Device Control Issues

Problem: "Device not found" Solution:

  • Run list_devices first to get valid device IDs

  • Ensure the device ID is correct (numeric string)

  • Check that the device is online in the LightWaveRF app

Problem: "Feature not found" Solution:

  • Use get_device_status to see available feature IDs

  • Verify the feature ID belongs to the correct device

  • Check that the feature is writable

Token Issues

Problem: Token expired errors Solution:

  • The server automatically refreshes tokens

  • If issues persist, restart the server to re-authenticate

  • Check system clock is correct (affects token expiry calculation)

Environment Variable Issues

Problem: "LIGHTWAVE_EMAIL and LIGHTWAVE_PASSWORD environment variables must be set" Solution:

  • For command line: Export variables before running

  • For Claude Desktop: Add to env section in config

  • For MCP Inspector: Set variables in terminal before running npx command

API Documentation

LightWaveRF Protocol

This server implements the unofficial LightWaveRF Link Plus protocol. For detailed protocol documentation, see: https://github.com/washcroft/LightwaveRF-LinkPlus/blob/master/README.md

MCP Protocol

This server follows the Model Context Protocol specification. For MCP documentation, see: https://modelcontextprotocol.io/

Limitations

  • Cloud Dependency: Requires internet connection and LightWaveRF cloud service

  • Read-Only Device Discovery: Device list cannot be modified through MCP

  • Feature Type Support: Only dimLevel and switch features are commonly tested

  • Single Account: One server instance supports one LightWaveRF account

Contributing

When contributing, please ensure:

  1. Security: Never commit credentials or tokens

  2. Error Handling: Add comprehensive error messages

  3. Validation: Use Zod schemas for all inputs

  4. Documentation: Update README for new features

  5. Testing: Test with MCP Inspector before submitting

License

MIT License - see LICENSE file for details

Acknowledgments

Support

For issues related to:

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI agents to discover and control LightwaveRF Smart Series devices (lights, switches, sockets) via the official REST API, using natural language commands like 'turn off the kitchen light'.
      MIT
    • A
      license
      B
      quality
      B
      maintenance
      Enables LLM assistants to control SprutHub smart homes through a local WebSocket connection by listing rooms/devices, reading hub and accessory states, and toggling switches or setting characteristics.
      18
      3
      MIT