MQTT MCP Server
Enables interacting with MQTT brokers to publish, subscribe, and manage connections, with a real-time web UI for visual feedback.
README
MQTT MCP Server
An MCP (Model Context Protocol) server that provides MQTT client functionality. This allows Claude to interact with MQTT brokers - publishing messages, subscribing to topics, and managing connections.
Available in both TypeScript (Node.js) and Python (FastMCP) versions!
Features
- MCP Server: Connect to MQTT brokers through Claude
- Web Application: Real-time background color changes via MQTT
- Dual Implementation: TypeScript (local) + Python (cloud deployment)
- Connect to MQTT brokers (supports mqtt:// and mqtts://)
- Publish messages to topics with QoS and retain options
- Subscribe to topics (including wildcard subscriptions)
- Unsubscribe from topics
- Check connection status
- Disconnect from brokers
- WebSocket real-time updates
- Interactive web UI with color presets
- FastMCP Cloud ready for one-click deployment
Quick Start
TypeScript Version (Local)
npm install
npm run build
Python Version (FastMCP Cloud)
See FASTMCP_DEPLOYMENT.md for one-click cloud deployment!
Usage
As a Claude Desktop MCP Server
Option 1: TypeScript Version (Local - Easy Setup)
Run the automated setup script:
npm run setup # macOS/Linux
npm run setup:windows # Windows
Or manually add this to your Claude Desktop configuration file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"mqtt": {
"command": "node",
"args": ["/Users/sara/TestAlin/build/index.js"]
}
}
}
After adding this configuration, restart Claude Desktop.
Option 2: Python Version (FastMCP Cloud - Recommended)
Deploy to FastMCP Cloud for cloud-hosted MQTT MCP server:
- Visit https://fastmcp.cloud
- Create a project from this GitHub repository
- Set entrypoint to
mqtt_mcp_server.py - Deploy with one click!
See FASTMCP_DEPLOYMENT.md for detailed instructions.
Web Application with Color Changing Background
The web application subscribes to MQTT messages and changes its background color in real-time!
# Start the web server (defaults to port 3000)
npm run start:web
# Or specify custom settings
MQTT_BROKER=mqtt://broker.hivemq.com:1883 MQTT_TOPIC=color/change PORT=3000 npm run start:web
Then open your browser to http://localhost:3000
How it works:
- The web app connects to the MQTT broker and subscribes to the configured topic (default:
color/change) - When any MQTT client publishes a color to that topic, the background changes instantly
- You can test it from the web UI or ask Claude to publish colors via the MCP server
Environment Variables:
MQTT_BROKER: MQTT broker URL (default:mqtt://broker.hivemq.com:1883)MQTT_TOPIC: Topic to subscribe to (default:color/change)PORT: Web server port (default:3000)
MCP Server Standalone
npm start
Available Tools
mqtt_connect
Connect to an MQTT broker.
Parameters:
broker_url(required): MQTT broker URL (e.g.,mqtt://localhost:1883ormqtts://broker.hivemq.com:8883)client_id(optional): Client ID for the connectionusername(optional): Username for authenticationpassword(optional): Password for authentication
Example:
Connect to mqtt://broker.hivemq.com:1883
mqtt_publish
Publish a message to an MQTT topic.
Parameters:
topic(required): The MQTT topic to publish tomessage(required): The message payloadqos(optional): Quality of Service level (0, 1, or 2). Default: 0retain(optional): Whether to retain the message. Default: false
Example:
Publish "Hello World" to topic "test/example"
mqtt_subscribe
Subscribe to an MQTT topic to receive messages.
Parameters:
topic(required): The MQTT topic (supports+for single-level and#for multi-level wildcards)qos(optional): Quality of Service level (0, 1, or 2). Default: 0
Example:
Subscribe to topic "sensors/#"
Note: Received messages are logged to stderr and will appear in Claude's context.
mqtt_unsubscribe
Unsubscribe from an MQTT topic.
Parameters:
topic(required): The MQTT topic to unsubscribe from
mqtt_disconnect
Disconnect from the MQTT broker.
mqtt_status
Get the current connection status including active subscriptions.
Example Workflow
Using the Web App with Claude's MCP Server
-
Start the web application:
npm run start:web -
Open your browser to
http://localhost:3000 -
Ask Claude to publish colors (via MCP):
Connect to mqtt://broker.hivemq.com:1883 and publish "red" to topic "color/change" -
Watch the background change in real-time!
-
Try different colors:
Publish "#FF5733" to topic "color/change" Publish "blue" to topic "color/change" Publish "rgb(46, 204, 113)" to topic "color/change"
Using the MCP Server Only
-
Connect to a broker:
Connect to the public MQTT broker at mqtt://broker.hivemq.com:1883 -
Subscribe to a topic:
Subscribe to topic "test/demo" -
Publish a message:
Publish "Hello from Claude!" to topic "test/demo" -
Check status:
What's the MQTT connection status? -
Disconnect:
Disconnect from the MQTT broker
Public Test Brokers
For testing, you can use these public MQTT brokers:
mqtt://broker.hivemq.com:1883(Eclipse Mosquitto)mqtt://broker.hivemq.com:1883(HiveMQ)mqtt://mqtt.eclipseprojects.io:1883(Eclipse IoT)
Note: Do not send sensitive data to public brokers.
Development
# Install dependencies
npm install
# Build
npm run build
# Watch mode
npm run watch
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
mcp-server-qdrant
这个仓库展示了如何为向量搜索引擎 Qdrant 创建一个 MCP (Managed Control Plane) 服务器的示例。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器