mcp2mqtt
Bridges AI models with the physical world using the MQTT protocol, enabling the publishing of control commands and subscription to device status updates for IoT hardware.
Enables AI-driven control and monitoring of Raspberry Pi devices and microcontrollers (such as the Pico) by translating natural language into MQTT-based hardware commands for PWM and LED management.
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 LED and set the PWM to 80%"
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 | 简体中文
系统架构
工作流程
项目愿景
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?
No annotations are provided, so the description carries the full burden of behavioral disclosure. The description only states what the tool does ('获取Pico开发板信息') without revealing any behavioral traits such as whether it's read-only, requires authentication, has rate limits, or what the output format might be. For a 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 a single, efficient sentence in Chinese ('获取Pico开发板信息'), which is appropriately concise and front-loaded with the core action. There's no wasted text, making it easy to parse quickly. However, it could be slightly improved by adding a bit more context without losing conciseness.
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 (0 parameters, no output schema, no annotations), the description is incomplete. It lacks details on what specific information is retrieved, the format of the output, or any behavioral context. While the tool is straightforward, the description should provide more completeness to help an AI agent understand the full scope and expected results.
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, and schema description coverage is 100%, so there are no parameters to document. The description doesn't need to add parameter semantics, and it appropriately doesn't mention any. This meets the baseline for tools with no parameters, as it avoids unnecessary information.
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 purpose with a verb ('获取' - get) and resource ('Pico开发板信息' - Pico development board information). However, it lacks specificity about what information is retrieved (e.g., hardware specs, firmware version, status) and doesn't differentiate from siblings like 'led_control' or 'set_pwm', which are clearly different operations. This makes it vague but functional.
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 any prerequisites, context for usage, or comparisons to sibling tools like 'led_control' or 'set_pwm'. Without such information, an AI agent must infer usage based on the tool name alone, which is insufficient for optimal selection.
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?
With no annotations provided, the description carries full burden for behavioral disclosure. It implies a mutation ('control') but doesn't specify if this requires permissions, has side effects, rate limits, or what happens on success/failure. The description is too minimal to provide adequate behavioral context for a tool that likely changes hardware state.
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 with just three characters in Chinese, which is efficient. However, it's arguably under-specified rather than appropriately concise. It gets straight to the point but lacks necessary detail.
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 this is a hardware control tool with no annotations and no output schema, the description is incomplete. It doesn't explain what the tool returns, error conditions, or important behavioral aspects. For a tool that likely interacts with physical hardware, more context is needed about its operation and effects.
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 schema description coverage is 100% with clear enum values ('on'/'off'), so the schema already documents the parameter fully. The description doesn't add any meaning beyond what the schema provides, such as explaining what 'on' or 'off' means in context. Baseline 3 is appropriate when 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 a clear verb ('control') and resource ('LED switch'), but it's vague about what specific action is performed. It doesn't distinguish from potential siblings like 'set_pwm' which might also control LEDs. The purpose is understandable but lacks specificity.
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 'set_pwm'. There's no mention of prerequisites, context, or exclusions. It's a basic statement of function without usage instructions.
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?
With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool sets PWM frequency, implying a write/mutation operation, but doesn't describe effects (e.g., on hardware, persistence), permissions needed, error conditions, or side effects. The range constraint is noted, but overall behavioral context is minimal.
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 sentence that directly states the tool's function and key constraint (range 0-100). It is front-loaded with the core purpose and wastes no words, making it highly concise and well-structured for quick understanding.
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 and no output schema, the description is incomplete for a mutation tool. It lacks details on behavioral effects, return values, error handling, and how it relates to sibling tools. While concise, it doesn't provide enough context for safe or effective use by an AI agent.
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 'frequency' well-documented in the schema as an integer in range 0-100. The description adds no additional semantic meaning beyond restating the range, 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 clearly states the action ('设置PWM频率' - set PWM frequency) and the resource (PWM), making the purpose immediately understandable. It doesn't explicitly differentiate from sibling tools like 'led_control' or 'get_pico_info', but the specificity of PWM frequency setting is distinct enough to avoid confusion.
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' (which might involve PWM for LEDs) or other potential tools. It mentions the frequency range (0-100) but doesn't explain application contexts, prerequisites, or when not to use it.
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
v0.1.0- 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 handles LED on/off states, and set_pwm manages PWM frequency settings. There is no overlap or ambiguity between these functions, making tool selection straightforward for an agent.
All tool names follow a consistent snake_case pattern with clear verb_noun structures: get_pico_info, led_control, and set_pwm. This uniformity enhances readability and predictability across the tool set.
With only 3 tools, the set is minimal but reasonable for controlling a Pico board, covering basic operations like info retrieval, LED control, and PWM settings. It might feel slightly thin for broader IoT tasks, but it aligns well with the apparent scope.
The tools cover core functions for Pico board interaction, but there are notable gaps such as missing read operations for LED or PWM states, and no update or delete capabilities. This could limit agent workflows that require full lifecycle management.
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
MCP server for AI dialogue using various LLM models via AceDataCloud
An MCP server that provides an API to LLMs to manage their JumpCloud resources.
- UnifAPIOAuthcom.unifapi
Hosted MCP server for live public-data APIs and Skills for AI agents.
- ZapierOAuthcom.zapier
Hosted MCP server connecting AI assistants to 9,000+ apps and 40,000+ actions via Zapier.
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/swesmith-repos/mcp2everything__mcp2mqtt.58670549'
If you have feedback or need assistance with the MCP directory API, please join our Discord server