Featured

Deploy OpenClaw in 60 seconds — 20% off logoDeploy OpenClaw in 60 seconds — 20% off

Launch OpenClaw on Hostinger in about 60 seconds and keep your agent live 24/7. Our referral link gives you 20% off, no coupon code needed.

Launch on Hostinger
Run your Hermes agent on Hostinger, fully managed logoRun your Hermes agent on Hostinger, fully managed

Launch Hermes on Hostinger in one click, fully managed, no VPS knowledge needed. Use code ZACAARON10 for 10% off.

Launch on Hostinger
Crawl and scrape any site into clean data, 10% off logoCrawl and scrape any site into clean data, 10% off

Firecrawl crawls and scrapes any site into clean markdown for your agent. Get 1,000 free credits, and new users get 10% off their first purchase.

Try Firecrawl free
Your own AI agent, running 24/7 with QwikClaw logoYour own AI agent, running 24/7 with QwikClaw

QwikClaw sets up and runs an always-on OpenClaw agent for you. One click, no config files, no server setup.

Deploy now
One API to scrape, enrich, and extract the internet. logoOne API to scrape, enrich, and extract the internet.

Context.dev gives your agents a single API to scrape, enrich, and extract live web data — no proxies, no parsers, no maintenance.

Start building free
SetupClaw: done-for-you OpenClaw for founders & exec teams logoSetupClaw: done-for-you OpenClaw for founders & exec teams

White-glove OpenClaw for founders and exec teams (4–50+ employees): we install, harden, integrate your tools, and maintain it — secured from day one.

Get it set up for you
SEO data APIs for your agent, $1 free credit logoSEO data APIs for your agent, $1 free credit

DataForSEO gives your agent live access to SERP results, keyword data, backlinks, and on-page SEO data through one API. New accounts get a $1 credit, good for up to 20,000 keyword or backlink lookups.

Try DataForSEO free
Reach 47,000+ AI builders

A flat monthly placement in front of developers actively installing AI tools. No lock-in, cancel anytime.

Advertise here

Works with

Claude CodeClaude DesktopCursorVS CodeClineCodex CLIOpenClaw+ any MCP client

Install to Claude Code

This server doesn't publish a one-line install command. Follow the setup in the source repository.

Summary

Provides MQTT communication capabilities for Large Language Models and other clients, enabling connections to MQTT brokers, publishing and subscribing to topics, and managing real-time messaging workflows.

README.md

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

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:

  1. mqtt-connect: Connect to an MQTT broker
  • Supports authentication (username/password)
  • Configurable client ID, keep-alive, and port settings
  • Automatically restores saved subscriptions
  1. mqtt-disconnect: Disconnect from an MQTT broker
  1. mqtt-publish: Publish messages to topics
  • Configurable QoS levels (0, 1, 2)
  • Retain message support
  1. mqtt-subscribe: Subscribe to topics
  • Wildcard support (+ for single level, # for multi-level)
  • Configurable QoS levels
  • Subscriptions are persisted automatically
  1. mqtt-unsubscribe: Unsubscribe from topics
  • Automatically updates persistence storage
  1. mqtt-list-connections: List all connections and their status
  1. mqtt-get-messages: Retrieve recent messages with optional filtering
  1. mqtt-get-persistent-subscriptions: Retrieve persisted subscription information
  • View all subscriptions across connections
  • Filter by connection ID
  • Shows topic and QoS information
  1. mqtt-delete-subscription: Delete specific subscriptions from persistence
  • Delete from specific connection or all connections
  • Updates runtime tracking for active connections
  1. 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

  1. Clone or download this repository
  2. Install dependencies:
   uv sync --dev --all-extras

Alternatively with pip: ``bash 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 tasks

Subscription 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 | |----------|-------------|---------| | MQTT_BRIDGE_PERSISTENCE_DIR | Directory for persistence files | ~/.mqtt-bridge | | MQTT_BRIDGE_SUBSCRIPTIONS_FILE | Filename for subscriptions | subscriptions.json |

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 subscriptions ``

Filter 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 subscriptions ` pyproject.toml # Project configuration README.md # This file ``

Running the Server

For development:

uv run python -m mqtt_bridge.server

For production: ``bash python -m mqtt_bridge.server ``

Testing 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

  1. Follow the MCP server development guidelines
  2. Ensure all MQTT operations handle errors gracefully
  3. Add tests for new functionality
  4. 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:

  1. Sync dependencies and update lockfile:
uv sync
  1. Build package distributions:
uv build

This 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.

See related servers & alternatives →

Related MCP servers

Browse all →

Related guides

Hand-picked reading to help you choose and use Communication servers.