mcp2mqtt
The mcp2mqtt server acts as a bridge between AI models and physical hardware via MQTT, enabling:
Control Hardware Devices: Interact with IoT devices using natural language commands
Set PWM Frequency: Adjust PWM frequency within a range of 0-100
Get Pico Information: Retrieve details from the connected Pico development board
Control LED State: Turn an LED on or off
Offers dedicated installation support for macOS systems through installation scripts
Core integration allowing communication with IoT devices using MQTT protocol for publishing/subscribing to commands and responses
Supports installation and compatibility with Raspberry Pi devices through dedicated installation scripts
Provides dedicated installation support for Ubuntu systems through installation scripts
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mcp2mqttturn on the living room lights"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
mcp2mqtt: 连接物理世界与AI大模型的桥梁
English | 简体中文
系统架构
Related MCP server: mcp2mqtt
工作流程
项目愿景
mcp2mqtt 是一个将物联网设备接入AI大模型的项目,它通过 Model Context Protocol (MCP) 和 MQTT 协议将物理世界与 AI 大模型无缝连接。最终实现:
用自然语言控制你的硬件设备
AI 实时响应并调整物理参数
让你的设备具备理解和执行复杂指令的能力
通过MQTT协议实现设备间的互联互通
主要特性
智能MQTT通信
支持MQTT协议的发布/订阅模式
支持多种MQTT服务器(如Mosquitto、EMQ X等)
支持QoS服务质量保证
支持主题过滤和消息路由
实时状态监控和错误处理
MCP 协议集成
完整支持 Model Context Protocol
支持资源管理和工具调用
灵活的提示词系统
通过MQTT实现命令的发布与响应
配置说明
MQTT配置
mqtt:
broker: "localhost" # MQTT服务器地址
port: 1883 # MQTT服务器端口
client_id: "mcp2mqtt_client" # MQTT客户端ID
username: "mqtt_user" # MQTT用户名
password: "mqtt_password" # MQTT密码
keepalive: 60 # 保持连接时间
topics:
command:
publish: "mcp/command" # 发送命令的主题
subscribe: "mcp/response" # 接收响应的主题
status:
publish: "mcp/status" # 发送状态的主题
subscribe: "mcp/control" # 接收控制命令的主题命令配置
commands:
set_pwm:
command: "CMD_PWM {frequency}"
need_parse: false
data_type: "ascii"
prompts:
- "把PWM调到最大"
- "把PWM调到最小"
mqtt_topic: "mcp/pwm" # MQTT发布主题
response_topic: "mcp/pwm/response" # MQTT响应主题MQTT 命令和响应
命令格式
命令使用简单的文本格式:
PWM 控制:
命令:
PWM {值}示例:
PWM 100(最大值)PWM 0(关闭)PWM 50(50%)
响应:
CMD PWM {值} OK
LED 控制:
命令:
LED {状态}示例:
LED on(打开)LED off(关闭)
响应:
CMD LED {状态} OK
设备信息:
命令:
INFO响应:
CMD INFO {设备信息}
错误响应
如果发生错误,响应格式将为:
ERROR: {错误信息}
支持的客户端
mcp2mqtt 支持所有实现了 MCP 协议的客户端,以及支持MQTT协议的物联网设备:
客户端类型 | 特性支持 | 说明 |
Claude Desktop | 完整支持 | 推荐使用,支持所有 MCP 功能 |
Continue | 完整支持 | 优秀的开发工具集成 |
Cline | 资源+工具 | 支持多种 AI 提供商 |
MQTT设备 | 发布/订阅 | 支持所有MQTT协议的物联网设备 |
快速开始
1. 安装
Windows用户
下载 install.py
python install.pymacOS用户
# 下载安装脚本
curl -O https://raw.githubusercontent.com/mcp2everything/mcp2mqtt/main/install_macos.py
# 运行安装脚本
python3 install_macos.pyUbuntu/Raspberry Pi用户
# 下载安装脚本
curl -O https://raw.githubusercontent.com/mcp2everything/mcp2mqtt/main/install_ubuntu.py
# 运行安装脚本
python3 install_ubuntu.py安装脚本会自动完成以下操作:
检查系统环境
安装必要的依赖
创建默认配置文件
配置Claude桌面版(如果已安装)
手动分步安装依赖
windows
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
MacOS
curl -LsSf https://astral.sh/uv/install.sh | sh主要依赖uv工具,所以当python和uv以及Claude或Cline安装好后就可以了。
基本配置
在你的 MCP 客户端(如 Claude Desktop 或 Cline)配置文件中添加以下内容: 注意:如果使用的自动安装那么会自动配置Calude Desktop无需此步。 使用默认配置文件:
{
"mcpServers": {
"mcp2mqtt": {
"command": "uvx",
"args": [
"mcp2mqtt"
]
}
}
}注意:修改配置后需要重启Cline或者Claude客户端软件
配置说明
配置文件位置
复制配置文件(config.yaml)可以放在位置:
用户主目录(推荐个人使用)
# Windows系统
C:\Users\用户名\.mcp2mqtt\config.yaml
# macOS系统
/Users/用户名/.mcp2mqtt/config.yaml
# Linux系统
/home/用户名/.mcp2mqtt/config.yaml适用场景:个人配置
需要创建
.mcp2mqtt目录:# Windows系统(在命令提示符中) mkdir "%USERPROFILE%\.mcp2mqtt" # macOS/Linux系统 mkdir -p ~/.mcp2mqtt
指定配置文件: 比如指定加载Pico配置文件:Pico_config.yaml
{
"mcpServers": {
"mcp2mqtt": {
"command": "uvx",
"args": [
"mcp2mqtt",
"--config",
"Pico" //指定配置文件名,不需要添加_config.yaml后缀
]
}
}
}为了能使用多个mqtt,我们可以新增多个mcp2mqtt的服务 指定不同的配置文件名即可。 如果要接入多个设备,如有要连接第二个设备: 指定加载Pico2配置文件:Pico2_config.yaml
{
"mcpServers": {
"mcp2mqtt2": {
"command": "uvx",
"args": [
"mcp2mqtt",
"--config",
"Pico2" //指定配置文件名,不需要添加_config.yaml后缀
]
}
}
}硬件连接
将你的设备通过网络连接到mqtt服务器
也可以用tests目录下的responder.py来模拟设备
运行测试
启动设备模拟器
项目在 tests 目录中包含了一个设备模拟器。它可以模拟一个硬件设备,能够:
响应 PWM 控制命令
提供设备信息
控制 LED 状态
启动模拟器:
python tests/responder.py你应该能看到模拟器正在运行并已连接到 MQTT 服务器的输出信息。
启动客户端Claude 桌面版或Cline
从源码快速开始
从源码安装
# 通过源码安装:
git clone https://github.com/mcp2everything/mcp2mqtt.git
cd mcp2mqtt
# 创建虚拟环境
uv venv .venv
# 激活虚拟环境
# Windows:
.venv\Scripts\activate
# Linux/macOS:
source .venv/bin/activate
# 安装开发依赖
uv pip install --editable .MCP客户端配置
在使用支持MCP协议的客户端(如Claude Desktop或Cline)时,需要在客户端的配置文件中添加以下内容: 直接自动安装的配置方式 源码开发的配置方式
使用默认演示参数:
{
"mcpServers": {
"mcp2mqtt": {
"command": "uv",
"args": [
"--directory",
"你的实际路径/mcp2mqtt", // 例如: "C:/Users/Administrator/Documents/develop/my-mcp-server/mcp2mqtt"
"run",
"mcp2mqtt"
]
}
}
}指定参数文件名
{
"mcpServers": {
"mcp2mqtt": {
"command": "uv",
"args": [
"--directory",
"你的实际路径/mcp2mqtt", // 例如: "C:/Users/Administrator/Documents/develop/my-mcp-server/mcp2mqtt"
"run",
"mcp2mqtt",
"--config", // 可选参数,指定配置文件名
"Pico" // 可选参数,指定配置文件名,不需要添加_config.yaml后缀
]
}
}
}2. 用户主目录(推荐个人使用)
# Windows系统
C:\Users\用户名\.mcp2mqtt\config.yaml
# macOS系统
/Users/用户名/.mcp2mqtt/config.yaml
# Linux系统
/home/用户名/.mcp2mqtt/config.yaml适用场景:个人配置
需要创建
.mcp2mqtt目录:# Windows系统(在命令提示符中) mkdir "%USERPROFILE%\.mcp2mqtt" # macOS/Linux系统 mkdir -p ~/.mcp2mqtt
3. 系统级配置(适合多用户环境)
# Windows系统(需要管理员权限)
C:\ProgramData\mcp2mqtt\config.yaml
# macOS/Linux系统(需要root权限)
/etc/mcp2mqtt/config.yaml适用场景:多用户共享配置
创建目录并设置权限:
# Windows系统(以管理员身份运行) mkdir "C:\ProgramData\mcp2mqtt" # macOS/Linux系统(以root身份运行) sudo mkdir -p /etc/mcp2mqtt sudo chown root:root /etc/mcp2mqtt sudo chmod 755 /etc/mcp2mqtt
程序会按照上述顺序查找配置文件,使用找到的第一个有效配置文件。根据你的需求选择合适的位置:
开发测试:使用当前目录
个人使用:建议使用用户主目录(推荐)
多用户环境:使用系统级配置(ProgramData或/etc)
运行服务器:
# 确保已激活虚拟环境
.venv\Scripts\activate
# 运行服务器(使用默认配置config.yaml 案例中用的LOOP_BACK 模拟串口,无需真实串口和串口设备)
uv run src/mcp2mqtt/server.py
或
uv run mcp2mqtt
# 运行服务器(使用指定配置Pico_config.yaml)
uv run src/mcp2mqtt/server.py --config Pico
或
uv run mcp2mqtt --config Pico文档
Available Tools
3 toolsget_pico_infoC
获取Pico开发板信息
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries full burden for behavioral disclosure. '获取' (get) implies a read operation, but the description doesn't specify whether this requires authentication, has rate limits, returns structured data, or has any side effects. For a tool with zero annotation coverage, this is inadequate behavioral transparency.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single Chinese phrase that directly states the tool's purpose. There's no wasted language or unnecessary elaboration. However, it could be more front-loaded with additional context, but for a simple tool, this is appropriately concise.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given no annotations, no output schema, and a simple parameterless design, the description is incomplete. It doesn't explain what information is returned (hardware specs, status, configuration?), format of response, or any behavioral constraints. For even a simple tool, more context would help the agent understand what to expect.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The tool has 0 parameters with 100% schema description coverage. The description doesn't need to explain parameters since none exist. A baseline of 4 is appropriate for parameterless tools where the schema fully documents the absence of inputs.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description '获取Pico开发板信息' (Get Pico development board information) states a clear verb ('获取' - get) and resource ('Pico开发板信息' - Pico development board information). However, it doesn't distinguish from sibling tools like 'led_control' or 'set_pwm' - those are clearly different operations, but this description doesn't clarify what specific information is retrieved versus other possible information tools.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites, timing considerations, or relationships to sibling tools. The agent must infer usage purely from the tool name and description without any explicit context.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
led_controlC
控制LED开关
| Name | Required | Description | Default |
|---|---|---|---|
| state | Yes | LED状态(on/off) |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries full burden. It states the action ('控制LED开关') but doesn't disclose behavioral traits such as required permissions, whether it's a read/write operation, side effects, or response format. The description is minimal and lacks context needed for safe invocation.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, efficient phrase ('控制LED开关') with zero waste. It's appropriately sized for a simple tool, though it could be more informative. The structure is front-loaded but lacks depth, earning a high score for brevity.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's simplicity (1 parameter, 100% schema coverage) but lack of annotations and output schema, the description is incomplete. It doesn't explain what the tool returns or any behavioral context, making it inadequate for full understanding despite the straightforward input.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, with the parameter 'state' fully documented in the schema (including enum values 'on'/'off'). The description adds no additional meaning beyond what the schema provides, so it meets the baseline of 3 where the schema does the heavy lifting.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description '控制LED开关' (control LED switch) states the basic function but is vague about what specific LED resource it controls. It uses a verb ('控制') and resource ('LED开关'), but doesn't distinguish from sibling tools like 'set_pwm' which might also control LEDs. The purpose is understandable but lacks specificity about scope or target.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No guidance is provided on when to use this tool versus alternatives like 'set_pwm'. The description implies it's for turning LEDs on/off, but there's no explicit context, prerequisites, or exclusions mentioned. Without annotations or sibling differentiation, usage is implied rather than clearly defined.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
set_pwmC
设置PWM频率,范围0-100
| Name | Required | Description | Default |
|---|---|---|---|
| frequency | Yes | PWM频率值(0-100) |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the action is to set PWM frequency, implying a write/mutation operation, but doesn't describe effects (e.g., whether this changes hardware output, requires specific permissions, or has side effects). It lacks details on rate limits, error handling, or what happens if the tool fails. For a mutation tool with zero annotation coverage, this is a significant gap in transparency.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is extremely concise ('设置PWM频率,范围0-100' - set PWM frequency, range 0-100), consisting of a single, front-loaded sentence that directly states the purpose and key constraint. There is no wasted text, and every part earns its place by conveying essential information efficiently.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's complexity (a mutation operation to set PWM frequency), lack of annotations, and no output schema, the description is incomplete. It doesn't explain what the tool returns, potential errors, or behavioral traits like whether the setting is persistent. For a tool that likely interacts with hardware or low-level systems, more context on effects and limitations is needed to be fully helpful.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The input schema has 100% description coverage, with the 'frequency' parameter fully documented in the schema (type: integer, description: 'PWM频率值(0-100)'). The description adds the same range information ('范围0-100'), providing no additional meaning beyond what the schema already states. According to the rules, when schema_description_coverage is high (>80%), the baseline is 3 even with no extra param info in the description.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the action ('设置PWM频率' - set PWM frequency) and specifies the resource (PWM), making the purpose understandable. It distinguishes from sibling tools like 'get_pico_info' (which likely reads info) and 'led_control' (which might control LEDs differently), though it doesn't explicitly contrast with them. The description is specific but lacks explicit sibling differentiation.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides no guidance on when to use this tool versus alternatives like 'led_control' or other potential tools. It mentions the frequency range (0-100), which hints at valid usage contexts, but doesn't specify scenarios, prerequisites, or exclusions. Without explicit when/when-not instructions or named alternatives, it offers minimal usage direction.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.
3 tool updates
- First observed
get_pico_info - First observed
led_control - First observed
set_pwm
TDQS
Each tool has a clearly distinct purpose: get_pico_info retrieves board information, led_control manages LED state, and set_pwm configures PWM frequency. There is no overlap in functionality, making tool selection unambiguous for an agent.
All tool names follow a consistent verb_noun pattern (get_pico_info, led_control, set_pwm) with clear, descriptive actions. The naming is uniform and predictable across the set.
With 3 tools, the count is reasonable for controlling a Pico board, though it feels slightly minimal. The tools cover core operations (info, LED, PWM), but additional features like sensor reading might be expected in a broader scope.
The tools provide essential control functions for a Pico board (info, LED, PWM), covering basic hardware interactions. However, there are minor gaps, such as missing tools for reading sensors or configuring other peripherals, which agents might need for more complex tasks.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
Zero-setup MCP gateway securely connecting AI to your tools with authentication and workflows
MCP server for AI dialogue using various LLM models via AceDataCloud
Connect MCP clients to 2,000+ AI models without managing provider API keys.
Related MCP Servers
- AlicenseCqualityDmaintenanceA bridge connecting physical hardware with AI large language models through the Model Context Protocol (MCP), enabling natural language control of TCP devices.38MIT
- AlicenseBqualityNot gradedmaintenanceAn MCP server that bridges the physical world and AI models by enabling natural language control of IoT hardware via the MQTT protocol. It supports real-time device monitoring, command publishing, and response handling for seamless integration between AI clients and physical devices.3-
- AlicenseNot gradedqualityDmaintenanceBridges Web of Things (WoT) devices to AI assistants via MCP, enabling discovery, monitoring, and control of IoT devices through natural language.9GPL 3.0
- AlicenseNot gradedqualityBmaintenanceEnables LLM agents to securely monitor and control MQTT devices for building automation, industrial control, and smart home systems through a standardized MCP interface.20MIT
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/mcp2everything/mcp2mqtt'
If you have feedback or need assistance with the MCP directory API, please join our Discord server