MQTT MCP Server

MQTT MCP Server

Enables interacting with MQTT brokers to publish, subscribe, and manage connections, with a real-time web UI for visual feedback.

Category
Visit Server

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:

  1. Visit https://fastmcp.cloud
  2. Create a project from this GitHub repository
  3. Set entrypoint to mqtt_mcp_server.py
  4. 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:

  1. The web app connects to the MQTT broker and subscribes to the configured topic (default: color/change)
  2. When any MQTT client publishes a color to that topic, the background changes instantly
  3. 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:1883 or mqtts://broker.hivemq.com:8883)
  • client_id (optional): Client ID for the connection
  • username (optional): Username for authentication
  • password (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 to
  • message (required): The message payload
  • qos (optional): Quality of Service level (0, 1, or 2). Default: 0
  • retain (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

  1. Start the web application:

    npm run start:web
    
  2. Open your browser to http://localhost:3000

  3. Ask Claude to publish colors (via MCP):

    Connect to mqtt://broker.hivemq.com:1883 and publish "red" to topic "color/change"
    
  4. Watch the background change in real-time!

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

  1. Connect to a broker:

    Connect to the public MQTT broker at mqtt://broker.hivemq.com:1883
    
  2. Subscribe to a topic:

    Subscribe to topic "test/demo"
    
  3. Publish a message:

    Publish "Hello from Claude!" to topic "test/demo"
    
  4. Check status:

    What's the MQTT connection status?
    
  5. 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

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured