home / mcp / mcp2mqtt mcp server

MCP2MQTT MCP Server

本项目通过将 MCP 协议转换为 MQTT 协议,我们能够利用强大的大型语言模型(LLMs),就能轻松操控您的智能家居、机器人或其他硬件设备。

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "mcp2everything-mcp2mqtt": {
      "command": "uv",
      "args": [
        "run",
        "src/mcp2mqtt/server.py"
      ]
    }
  }
}

mcp2mqtt bridges your physical IoT devices with AI models through the Model Context Protocol (MCP) and MQTT. You can control hardware with natural language, get real-time AI responses, and connect devices via MQTT for seamless intercommunication.

How to use

You interact with your IoT setup through an MCP client that speaks MCP and MQTT. Start by connecting your devices to an MQTT broker and configuring your MCP client to talk to the mcp2mqtt server. Your commands flow through the MCP pipeline to hardware actions, while the server relays device state back to you and enables AI-generated prompts to control parameters in real time.

How to install

Prerequisites you need before installation are Python and the uv toolchain for running the MCP server, plus an MCP-compatible client like Claude Desktop or Cline.

1. Clone the project repository to your development machine.

2. Create a Python virtual environment and install development dependencies.

3. Run the MCP server using the standard entry, or start with a specific configuration file if you want to load a dedicated setup.

4. Start your MCP client and point it at the running server to begin sending commands.

Additional sections

Configuration details include MQTT connectivity and command routing. The server exposes commands via MQTT topics and supports loading multiple configuration profiles for different devices. You can tailor prompts, resource management, and tool invocation to your hardware and AI provider.

Security considerations include using MQTT authentication (username and password) and restricting topics to your trusted devices and clients. Regularly review access controls and rotate credentials.

Troubleshooting tips: check MQTT broker availability, verify the MCP client configuration, and monitor logs for errors during device command processing. If a command fails, look for the error message prefixed by ERROR to identify the issue.