Sponsored by Deepsite.site

Smart Bulb Control via MCP Server With Claude

Created By
Arpitmahajan1237 months ago
This project creates an MCP server using Node.js and TypeScript to autonomously control a smart bulb via UDP communication. It integrates with AI interfaces like ChatGPT or Claude, enabling seamless, anonymous, and automated lighting control with color and brightness adjustments.
Content

Smart Bulb Control via MCP Server With Claude

This project demonstrates how to build an MCP (Machine Control Protocol). server using Node.js and TypeScript to autonomously control a smart bulb using AI-driven commands. It enables seamless, anonymous, and automated smart lighting management through UDP communication and AI interfaces like ChatGPT or Claude.

Overview

The project showcases:

  • Autonomous control of a smart bulb via MCP Server.
  • Use of Cursor ID and AI clients to manage lighting.
  • UDP communication with the bulb using structured JSON commands.
  • Real-time color and brightness adjustments.

How It Works

Smart Bulb Communication

  • Smart bulbs (e.g., Philips Hue) operate over a UDP server on a predefined port.
  • Each bulb connects via a private IP address on your Wi-Fi network.
  • JSON-formatted commands (e.g., turn on/off, change RGB) are sent as UDP datagrams.

Development Tools

  • Node.js: For writing the UDP client.

  • TypeScript: Ensures type-safe, scalable code.

  • NPM: Package manager for installing dependencies.

  • MCP SDK: Official SDK for building MCP servers.

  • dgram module: Node’s built-in module for UDP sockets.

MCP Server Structure

Tool Creation Each tool maps to a bulb control action (e.g., turn_on, set_color), with schemas defining expected input.

Bulb Functions

  • turnOnBulb(): Sends a UDP command to turn the bulb on.

  • turnOffBulb(): Sends a command to turn it off.

  • setColor(r, g, b, dimming): Adjusts color and brightness.

Error Handling Ensures clean connection handling and logs network errors.

Transport Layer MCP server uses stdio transport to interface with Cursor or other AI platforms for real-time control.

Features

  • Turn bulb on/off via AI or command-line input.

  • Set RGB color dynamically.

  • Adjust brightness using dimming percentage.

  • AI Integration with MCP for automated routines.

How to Run

  • Install dependencies

  • pnpm install

  • Build the TypeScript project

  • pnpm build

  • Run the MCP server

  • npm start

Ensure your smart bulb is:

  • Connected to the same network.

  • Configured with the correct IP and UDP port.

Future Ideas

  • React lighting to coding activity or weather.

  • Add color temperature support.

  • Integrate with other IoT devices (e.g., fans, curtains).

  • Build a GUI for real-time control visualization.

Contributions

  • Pull requests and feedback are welcome! Let’s build the future of AI-driven smart homes.

  • Let me know if you'd like to include command-line examples, setup videos, or API docs in the README.md.


Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
ChatWiseThe second fastest AI chatbot™
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
Serper MCP ServerA Serper MCP Server
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
Amap Maps高德地图官方 MCP Server
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
WindsurfThe new purpose-built IDE to harness magic
Tavily Mcp
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
DeepChatYour AI Partner on Desktop
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
Playwright McpPlaywright MCP server
CursorThe AI Code Editor