MQTT MCP Server
Connects AI assistants to MQTT brokers for smart home automation and IoT device control, enabling topic discovery, sensor reading, command sending, and event monitoring.
README
MQTT MCP Server
MCP server that connects AI assistants to MQTT brokers for smart home automation and IoT device control.
What it does:
- Discovers MQTT topics and devices on your network
- Reads sensor values and device states
- Sends commands to control devices
- Monitors real-time MQTT events
Use cases:
- Control smart home devices through AI assistants
- Monitor IoT sensor networks
- Automate home automation workflows
- Debug MQTT integrations
Quick Navigation
Choose your system:
Linux
- Claude Code ⭐ Recommended
- Codex CLI
- Cursor
- Cline
- Other Clients
macOS
Windows
Linux
Linux • Claude Code
Step 1: Install the package
pip install mqtt-mcp-server
Step 2: Add to Claude Code
claude mcp add --transport stdio mqtt \
--env MQTT_HOST=YOUR_BROKER_IP \
--env MQTT_PORT=1883 \
--env MQTT_USERNAME=YOUR_USERNAME \
--env MQTT_PASSWORD=YOUR_PASSWORD \
-- python3 -m mqtt_mcp.server
Step 3: Verify
claude mcp list
You should see: mqtt: python3 -m mqtt_mcp.server - ✓ Connected
Linux • Codex CLI
Step 1: Install the package
pip install mqtt-mcp-server
Step 2: Add to Codex
codex mcp add mqtt \
--env MQTT_HOST=YOUR_BROKER_IP \
--env MQTT_PORT=1883 \
--env MQTT_USERNAME=YOUR_USERNAME \
--env MQTT_PASSWORD=YOUR_PASSWORD \
-- python3 -m mqtt_mcp.server
Step 3: Verify
codex mcp list
Linux • Cursor
Step 1: Install the package
pip install mqtt-mcp-server
Step 2: Add to Cursor
Open Cursor Settings → MCP, or create ~/.cursor/mcp.json (global) or .cursor/mcp.json (project-only):
{
"mcpServers": {
"mqtt": {
"command": "python3",
"args": ["-m", "mqtt_mcp.server"],
"env": {
"MQTT_HOST": "YOUR_BROKER_IP",
"MQTT_PORT": "1883",
"MQTT_USERNAME": "YOUR_USERNAME",
"MQTT_PASSWORD": "YOUR_PASSWORD"
}
}
}
}
Step 3: Restart Cursor
Linux • Cline
Step 1: Install the package
pip install mqtt-mcp-server
Step 2: Add to Cline
In VS Code, click MCP Servers icon → Configure MCP Servers, or edit cline_mcp_settings.json:
{
"mcpServers": {
"mqtt": {
"command": "python3",
"args": ["-m", "mqtt_mcp.server"],
"env": {
"MQTT_HOST": "YOUR_BROKER_IP",
"MQTT_PORT": "1883",
"MQTT_USERNAME": "YOUR_USERNAME",
"MQTT_PASSWORD": "YOUR_PASSWORD"
}
}
}
}
Step 3: Restart VS Code
Linux • Other Clients
For any MCP client that supports stdio transport:
1. Install the package:
pip install mqtt-mcp-server
2. Configure with these values:
- Command:
python3 - Args:
["-m", "mqtt_mcp.server"] - Environment variables:
MQTT_HOST- Your broker IP/hostnameMQTT_PORT- Broker port (usually 1883)MQTT_USERNAME- Optional usernameMQTT_PASSWORD- Optional password
macOS
macOS • Claude Code
Step 1: Install the package
pip3 install mqtt-mcp-server
Step 2: Add to Claude Code
claude mcp add --transport stdio mqtt \
--env MQTT_HOST=YOUR_BROKER_IP \
--env MQTT_PORT=1883 \
--env MQTT_USERNAME=YOUR_USERNAME \
--env MQTT_PASSWORD=YOUR_PASSWORD \
-- python3 -m mqtt_mcp.server
Step 3: Verify
claude mcp list
You should see: mqtt: python3 -m mqtt_mcp.server - ✓ Connected
macOS • Codex CLI
Step 1: Install the package
pip3 install mqtt-mcp-server
Step 2: Add to Codex
codex mcp add mqtt \
--env MQTT_HOST=YOUR_BROKER_IP \
--env MQTT_PORT=1883 \
--env MQTT_USERNAME=YOUR_USERNAME \
--env MQTT_PASSWORD=YOUR_PASSWORD \
-- python3 -m mqtt_mcp.server
Step 3: Verify
codex mcp list
macOS • Claude Desktop
Step 1: Install the package
pip3 install mqtt-mcp-server
Step 2: Configure Claude Desktop
Open: ~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"mqtt": {
"command": "python3",
"args": ["-m", "mqtt_mcp.server"],
"env": {
"MQTT_HOST": "YOUR_BROKER_IP",
"MQTT_PORT": "1883",
"MQTT_USERNAME": "YOUR_USERNAME",
"MQTT_PASSWORD": "YOUR_PASSWORD"
}
}
}
}
Step 3: Restart Claude Desktop
macOS • Cursor
Step 1: Install the package
pip3 install mqtt-mcp-server
Step 2: Add to Cursor
Open Cursor Settings → MCP, or create ~/.cursor/mcp.json (global) or .cursor/mcp.json (project-only):
{
"mcpServers": {
"mqtt": {
"command": "python3",
"args": ["-m", "mqtt_mcp.server"],
"env": {
"MQTT_HOST": "YOUR_BROKER_IP",
"MQTT_PORT": "1883",
"MQTT_USERNAME": "YOUR_USERNAME",
"MQTT_PASSWORD": "YOUR_PASSWORD"
}
}
}
}
Step 3: Restart Cursor
macOS • Cline
Step 1: Install the package
pip3 install mqtt-mcp-server
Step 2: Add to Cline
In VS Code, click MCP Servers icon → Configure MCP Servers, or edit cline_mcp_settings.json:
{
"mcpServers": {
"mqtt": {
"command": "python3",
"args": ["-m", "mqtt_mcp.server"],
"env": {
"MQTT_HOST": "YOUR_BROKER_IP",
"MQTT_PORT": "1883",
"MQTT_USERNAME": "YOUR_USERNAME",
"MQTT_PASSWORD": "YOUR_PASSWORD"
}
}
}
}
Step 3: Restart VS Code
macOS • Other Clients
For any MCP client that supports stdio transport:
1. Install the package:
pip3 install mqtt-mcp-server
2. Configure with these values:
- Command:
python3 - Args:
["-m", "mqtt_mcp.server"] - Environment variables:
MQTT_HOST- Your broker IP/hostnameMQTT_PORT- Broker port (usually 1883)MQTT_USERNAME- Optional usernameMQTT_PASSWORD- Optional password
Windows
Windows • Claude Code
Step 1: Install the package
pip install mqtt-mcp-server
Step 2: Add to Claude Code
claude mcp add --transport stdio mqtt `
--env MQTT_HOST=YOUR_BROKER_IP `
--env MQTT_PORT=1883 `
--env MQTT_USERNAME=YOUR_USERNAME `
--env MQTT_PASSWORD=YOUR_PASSWORD `
-- python -m mqtt_mcp.server
Step 3: Verify
claude mcp list
You should see: mqtt: python -m mqtt_mcp.server - ✓ Connected
Windows • Codex CLI
Step 1: Install the package
pip install mqtt-mcp-server
Step 2: Add to Codex
codex mcp add mqtt `
--env MQTT_HOST=YOUR_BROKER_IP `
--env MQTT_PORT=1883 `
--env MQTT_USERNAME=YOUR_USERNAME `
--env MQTT_PASSWORD=YOUR_PASSWORD `
-- python -m mqtt_mcp.server
Step 3: Verify
codex mcp list
Windows • Claude Desktop
Step 1: Install the package
pip install mqtt-mcp-server
Step 2: Configure Claude Desktop
Open: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"mqtt": {
"command": "python",
"args": ["-m", "mqtt_mcp.server"],
"env": {
"MQTT_HOST": "YOUR_BROKER_IP",
"MQTT_PORT": "1883",
"MQTT_USERNAME": "YOUR_USERNAME",
"MQTT_PASSWORD": "YOUR_PASSWORD"
}
}
}
}
Step 3: Restart Claude Desktop
Windows • Cursor
Step 1: Install the package
pip install mqtt-mcp-server
Step 2: Add to Cursor
Open Cursor Settings → MCP, or create ~/.cursor/mcp.json (global) or .cursor/mcp.json (project-only):
{
"mcpServers": {
"mqtt": {
"command": "python",
"args": ["-m", "mqtt_mcp.server"],
"env": {
"MQTT_HOST": "YOUR_BROKER_IP",
"MQTT_PORT": "1883",
"MQTT_USERNAME": "YOUR_USERNAME",
"MQTT_PASSWORD": "YOUR_PASSWORD"
}
}
}
}
Step 3: Restart Cursor
Windows • Cline
Step 1: Install the package
pip install mqtt-mcp-server
Step 2: Add to Cline
In VS Code, click MCP Servers icon → Configure MCP Servers, or edit cline_mcp_settings.json:
{
"mcpServers": {
"mqtt": {
"command": "python",
"args": ["-m", "mqtt_mcp.server"],
"env": {
"MQTT_HOST": "YOUR_BROKER_IP",
"MQTT_PORT": "1883",
"MQTT_USERNAME": "YOUR_USERNAME",
"MQTT_PASSWORD": "YOUR_PASSWORD"
}
}
}
}
Step 3: Restart VS Code
Windows • Other Clients
For any MCP client that supports stdio transport:
1. Install the package:
pip install mqtt-mcp-server
2. Configure with these values:
- Command:
python(notpython3) - Args:
["-m", "mqtt_mcp.server"] - Environment variables:
MQTT_HOST- Your broker IP/hostnameMQTT_PORT- Broker port (usually 1883)MQTT_USERNAME- Optional usernameMQTT_PASSWORD- Optional password
Available Tools
After installation, ask your AI assistant: "What MQTT tools are available?"
You should see 4 tools:
topics
Discover MQTT topics on your broker.
Parameters:
- scan_timeout: Scan duration in seconds (1-60, default: 10)
- keywords: Filter topics by keywords
- limit: Max results (1-200, default: 50)
value
Read current values from topics (uses cache for speed).
Parameters:
- topics: List of topic paths (required)
- timeout: Wait time per topic (1-60, default: 5)
publish
Send commands to MQTT devices.
Parameters:
- messages: List of {topic, payload, qos, retain}
- timeout: Network timeout (1-30, default: 3)
record
Monitor MQTT events in real-time.
Parameters:
- timeout: Recording duration (1-300, default: 30)
- topics: Specific topics to monitor
- keywords: Filter by keywords
Troubleshooting
"python3 not found" (Windows)
Use 'python' instead of 'python3' in all commands
"Connection refused"
1. Check MQTT broker is running
2. Verify MQTT_HOST and MQTT_PORT are correct
3. Check firewall settings
4. Test connection: mosquitto_sub -h YOUR_HOST -p 1883 -t "#"
"Module not found: mqtt_mcp"
Install the package: pip install mqtt-mcp-server
If using venv, make sure it's activated
Tools not appearing
1. Restart your AI client
2. Check JSON syntax in config file
3. Verify connection: claude mcp list (or codex mcp list)
4. Check logs (location depends on client)
Permission errors (Linux/macOS)
Use pip3 install --user mqtt-mcp-server
Or install in virtual environment
Development
For contributors and developers:
Install from source
# Clone repository
git clone https://github.com/eduard256/mqtt-mcp-server.git
cd mqtt-mcp-server
# Create virtual environment
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install in development mode
pip install -e .
Run tests
# Linux/macOS
python3 tests/test_topics.py
python3 tests/test_value.py
python3 tests/test_publish.py
python3 tests/test_record.py
# Windows
python tests\test_topics.py
python tests\test_value.py
python tests\test_publish.py
python tests\test_record.py
Requirements
- Python 3.10+
- MQTT broker (Mosquitto, EMQX, HiveMQ, etc.)
Links
- PyPI: https://pypi.org/project/mqtt-mcp-server/
- GitHub: https://github.com/eduard256/mqtt-mcp-server
- Issues: https://github.com/eduard256/mqtt-mcp-server/issues
License
MIT License - See LICENSE for details
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。