MQTT-Bridge
Supports connecting to HiveMQ public test broker (broker.hivemq.com) for testing MQTT functionality, allowing evaluation of publish/subscribe workflows.
Provides MQTT communication capabilities, enabling connections to MQTT brokers, publishing and subscribing to topics with configurable QoS and retain settings, and managing real-time messaging workflows.
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., "@MQTT-Bridgesubscribe to 'sensors/#'"
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.
MQTT-Bridge
MQTT-Bridge provides MQTT communication capabilities for Large Language Models and other clients. It enables connections to MQTT brokers, publishing and subscribing to topics, and managing real-time messaging workflows.
Features
MQTT Broker Connection: Connect to any MQTT broker with authentication support
Message Publishing: Publish messages to topics with configurable QoS and retain settings
Topic Subscription: Subscribe to topics with wildcard support (+ and #)
Connection Management: Manage multiple concurrent MQTT connections
Message Monitoring: Track and analyze received messages
Real-time Updates: Live message reception and connection status monitoring
Subscription Persistence: Maintain subscriptions across server restarts
Related MCP server: OMNI-MQTT-MCP
Components
Resources
MQTT-Bridge provides these resources:
Connection Status: Real-time status and details for each MQTT connection
Message History: Recent MQTT messages with filtering capabilities
Prompts
MQTT-Bridge offers intelligent prompts for:
mqtt-connection-status: Get formatted status of all MQTT connections
mqtt-message-analysis: Analyze recent MQTT messages with topic filtering
Tools
MQTT-Bridge implements these MQTT tools:
mqtt-connect: Connect to an MQTT broker
Supports authentication (username/password)
Configurable client ID, keep-alive, and port settings
Automatically restores saved subscriptions
mqtt-disconnect: Disconnect from an MQTT broker
mqtt-publish: Publish messages to topics
Configurable QoS levels (0, 1, 2)
Retain message support
mqtt-subscribe: Subscribe to topics
Wildcard support (+ for single level, # for multi-level)
Configurable QoS levels
Subscriptions are persisted automatically
mqtt-unsubscribe: Unsubscribe from topics
Automatically updates persistence storage
mqtt-list-connections: List all connections and their status
mqtt-get-messages: Retrieve recent messages with optional filtering
mqtt-get-persistent-subscriptions: Retrieve persisted subscription information
View all subscriptions across connections
Filter by connection ID
Shows topic and QoS information
mqtt-delete-subscription: Delete specific subscriptions from persistence
Delete from specific connection or all connections
Updates runtime tracking for active connections
mqtt-delete-all-subscriptions: Delete all persistent subscriptions
Nuclear option with confirmation required
Completely clears subscription persistence
Installation
Prerequisites
Python 3.12 or higher
uv package manager (recommended) or pip
Setup
Clone or download this repository
Install dependencies:
uv sync --dev --all-extras
Alternatively with pip:
pip install -e .Configuration
Claude Desktop
Add this configuration to your Claude Desktop config file:
MacOS: ~/Library/Application\ Support/Claude/claude_desktop_config.json
Windows: %APPDATA%/Claude/claude_desktop_config.json
{
"mcpServers": {
"mqtt-bridge": {
"command": "python",
"args": ["-m", "mqtt_bridge.server"]
}
}
}Project Structure
src/
mqtt_bridge/
__init__.py
server.py # Main server implementation
subscription_persistence.py # Subscription persistence implementation
.github/
copilot-instructions.md # GitHub Copilot workspace instructions
.vscode/
mcp.json # VS Code MCP configuration
tasks.json # Build and run tasksSubscription Persistence
The server implements subscription persistence to maintain MQTT subscriptions across server restarts:
Features
Automatically saves subscriptions to disk when they are created or removed
Restores subscriptions when connections are re-established
Preserves QoS levels for each subscription
Gracefully handles shutdown to ensure latest subscription state is saved
Configuration
Subscription persistence can be configured via environment variables:
Variable | Description | Default |
| Directory for persistence files |
|
| Filename for subscriptions |
|
Storage Format
Subscriptions are stored in a JSON file with the following structure:
{
"connection_id1": [
{"topic": "topic1", "qos": 0},
{"topic": "topic2", "qos": 1}
],
"connection_id2": [
{"topic": "topic3", "qos": 2}
]
}Testing
The scripts/test_subscription_persistence.py script can be used to test the subscription persistence functionality.
Subscription Management
The server provides advanced subscription management capabilities:
Viewing Subscriptions
Use the mqtt-get-persistent-subscriptions tool to view all persistent subscriptions:
Show me all persistent MQTT subscriptionsFilter by connection ID:
Show the persistent subscriptions for connection "my-connection"Deleting Subscriptions
Delete a specific subscription from all connections:
Delete subscription for topic "sensors/temperature"Delete a subscription from a specific connection:
Delete the "sensors/temperature" subscription from connection "my-connection"Nuclear Option
Delete all persistent subscriptions (requires confirmation):
Delete all persistent subscriptionspyproject.toml # Project configuration README.md # This file
### Running the Server
For development:
```bash
uv run python -m mqtt_bridge.serverFor production:
python -m mqtt_bridge.serverTesting MQTT Functionality
You can test the server with public MQTT brokers:
test.mosquitto.org: Public test broker (port 1883)
broker.emqx.io: Public test broker (port 1883)
broker.hivemq.com: Public test broker (port 1883)
Debugging
The server logs to stderr, which you can monitor for debugging:
Connection events
Message reception
Error conditions
Security Considerations
Use secure MQTT brokers (TLS) in production
Implement proper authentication credentials
Consider message encryption for sensitive data
Monitor and limit message rate for public brokers
License
MIT two-clause license applies to this project.
Contributing
Follow the MCP server development guidelines
Ensure all MQTT operations handle errors gracefully
Add tests for new functionality
Update documentation for new features
Support
For issues and questions:
Check the MCP documentation: https://modelcontextprotocol.io/
Review MQTT protocol specifications: https://mqtt.org/
Test with public MQTT brokers before reporting connectivity issues
Development
Building and Publishing
To prepare the package for distribution:
Sync dependencies and update lockfile:
uv syncBuild package distributions:
uv buildThis will create source and wheel distributions in the dist/ directory.
Debugging
Since MCP servers run over stdio, debugging can be challenging. For the best debugging experience, we recommend using the MCP Inspector.
Upon launching, the Inspector will display a URL that you can access in your browser to begin debugging.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- 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/rsbohn/mqtt-bridge'
If you have feedback or need assistance with the MCP directory API, please join our Discord server