ioehub-mqtt-mcp-server

ioehub-mqtt-mcp-server

0

IoEHub MQTT MCP Server is a system designed to monitor and control IoT devices, specifically temperature sensors and LEDs, through MQTT communication and the Model Context Protocol. It uses FastMCP for protocol handling and supports JSON-RPC for client-server communication. The project is implemented in Python and enables interfacing with physical devices for real-time data monitoring and control.

IoEHub MQTT MCP Server

Overview

This document describes an MCP (Model Context Protocol) server using MQTT to read temperature sensor data and control LEDs. The server is based on the FastMCP framework and communicates using the JSON-RPC protocol.

Key Components:

  1. MCP Client (Claude AI)
    • Provides a user interface
    • Sends JSON-RPC requests to MCP Server
    • Displays results to users
  2. MCP Server (Python/FastMCP)
    • Processes client requests
    • Communicates with MQTT Broker
    • Translates between JSON-RPC and MQTT protocols
  3. MQTT Broker (172.30.1.100)
    • Central hub for MQTT messages
    • Routes messages between server and devices
  4. IoT Device (Temperature Sensor/LED)
    • Physical hardware devices
    • Provides temperature data
    • Controls LED states based on commands

System Components:

  • Framework: FastMCP
  • Protocols: MQTT, JSON-RPC 2.0
  • Language: Python
  • Features: Temperature measurement, LED control

Data Flow:

  1. Client → Server: Function call for temperature reading or LED control
  2. Server → Broker: Publishes MQTT message
  3. Broker → Device: Forwards command to the device
  4. Device → Broker: Publishes response
  5. Broker → Server: Delivers response to subscribed server
  6. Server → Client: Returns processed data result

Usage

Server Execution

Run python mcp_server.py to start the server.

Function Calls

Example for client invocation:

  • Temperature: Call ioehub_mqtt_get_temperature
  • LED Control: Call ioehub_mqtt_set_led with appropriate parameters