Skip to main content

A Model Context Protocol (MCP) server implementation that provides EMQX MQTT broker interaction.

Project description

EMQX MCP Server

smithery badge

emqx-mcp-server MCP server

A Model Context Protocol (MCP) server implementation that provides EMQX MQTT broker interaction. Enabling MCP clients to interact with the MQTT clusters on EMQX Cloud or self-hosted clusters

Features

MQTT Client Management

  • Client Listing: View all connected MQTT clients with flexible filtering options
  • Client Information: Retrieve detailed information about specific clients
  • Connection Control: Disconnect problematic or stale clients from the broker
  • Flexible Filtering: Filter clients by node, username, client ID, connection state, and more

MQTT Message Publishing

  • Topic-based Publishing: Send messages to any MQTT topics
  • QoS Control: Select Quality of Service level (0, 1, or 2) for reliable delivery
  • Message Retention: Option to persist messages for new subscribers
  • Custom Payloads: Support for any message content format

Tools

list_mqtt_clients

  • List MQTT clients connected to your EMQX Cluster
  • Inputs:
    • page (number, optional): Page number (default: 1)
    • limit (number, optional): Results per page (default: 100, max 10000)
    • node (string, optional): Filter by specific node name
    • clientid (string, optional): Filter by specific client ID
    • username (string, optional): Filter by specific username
    • ip_address (string, optional): Filter by client IP address
    • conn_state (string, optional): Filter by connection state
    • clean_start (boolean, optional): Filter by clean start flag
    • proto_ver (string, optional): Filter by protocol version
    • like_clientid (string, optional): Fuzzy search by client ID pattern
    • like_username (string, optional): Fuzzy search by username pattern
    • like_ip_address (string, optional): Fuzzy search by IP address pattern

get_mqtt_client

  • Get detailed information about a specific MQTT client by client ID
  • Inputs:
    • clientid (string, required): The unique identifier of the client to retrieve

kick_mqtt_client

  • Disconnect a client from the MQTT broker by client ID
  • Inputs:
    • clientid (string, required): The unique identifier of the client to disconnect

publish_mqtt_message

  • Publish an MQTT Message to Your EMQX Cluster on EMQX Cloud or Self-Managed Deployment
  • Inputs:
    • topic (string, required): MQTT topic to publish to
    • payload (string, required): Message content to publish
    • qos (number, optional): Quality of Service level (0, 1, or 2) (default: 0)
    • retain (boolean, optional): Whether to retain the message (default: false)

Setup EMQX Cluster

Before using the EMQX MCP Server tools, you need to set up an EMQX cluster with properly configured API Key and client authentication. There are several options:

  1. EMQX Cloud Serverless Deployment:
  • The easiest way to get started with.
  • Obtain a free serverless deployment from EMQX Cloud
  • Sign up at EMQX Cloud Serverless
  1. EMQX Cloud Dedicated Deployment:
  • Provides dedicated resources for production workloads
  • Offers enhanced performance, reliability, and customization options
  • Supports various cloud providers (AWS, GCP, Azure)
  • Includes professional SLA and support
  • Create a deployment at EMQX Cloud Dedicated
  1. Self-hosted EMQX Platform:
  • Download and deploy EMQX Platform locally
  • Follow installation instructions at EMQX Platform

Running locally with the Claude Desktop App

Option 1: Installing via Smithery

To install emqx-mcp-server for Claude Desktop automatically via Smithery:

npx -y @smithery/cli install @Benniu/emqx-mcp-server --client claude

Option 2: Docker

  1. Install Claude Desktop App if you haven't done so yet.

  2. Pull the image:

    docker pull benniuji/emqx-mcp-server
    
  3. Add the following to your claude_desktop_config.json file:

    • On MacOS: ~/Library/Application\ Support/Claude/claude_desktop_config.json
    • On Windows: %APPDATA%/Claude/claude_desktop_config.json
    {
      "mcpServers": {
        "EMQX_MCP_Server": {
          "command": "docker",
          "args": [
            "run",
            "-i",
            "--rm",
            "-e", "EMQX_API_URL=https://your-emqx-cloud-instance.com:8443/api/v5",
            "-e", "EMQX_API_KEY=<YOUR-API-KEY>",
            "-e", "EMQX_API_SECRET=<YOUR-API-SECRET>",
            "benniuji/emqx-mcp-server"
          ]
        }
      }
    }
    

    Note: Update the env variables:EMQX_API_URL, EMQX_API_KEY, EMQX_API_SECRET

  4. Open or Restart Claude Desktop App

  5. Try asking Claude to do something with the MQTT broker (e.g. ask it to publish an MQTT message to a topic).

Option 3: Manual Installation

First, ensure you have the uv executable installed. If not, you can install it by following the instructions here.

  1. Install Claude Desktop App if you haven't done so yet.
  2. Clone this repository.
  3. Add the following to your claude_desktop_config.json file:
    • On MacOS: ~/Library/Application\ Support/Claude/claude_desktop_config.json
    • On Windows: %APPDATA%/Claude/claude_desktop_config.json
    {
      "mcpServers": {
        "EMQX_MCP_Server": {
          "command": "uv",
          "args": [
            "--directory",
            "path/to/repo/src/emqx_mcp_server",
            "run",
            "emqx-mcp-server"
          ],
          "env":{
            "EMQX_API_URL":"https://your-emqx-cloud-instance.com:8443/api/v5",
            "EMQX_API_KEY":"<YOUR-API-KEY>",
            "EMQX_API_SECRET":"<YOUR-API-SECRET>"
          }
        }
      }
    }
    
    Note: Make sure to update path/to/repo/src/emqx_mcp_server to the actual path and modify the environment variables EMQX_API_URL, EMQX_API_KEY, and EMQX_API_SECRET to match your EMQX instance.
  4. Open or Restart Claude Desktop App
  5. Try asking Claude to do something with the MQTT broker (e.g. ask it to publish an MQTT message to a topic).

Example Prompts

User:

Please list the clients connected to the MQTT broker.

LLM:

Here are the clients currently connected to your MQTT broker:
Connected Client:
  - Client ID: mqttx_2232bdb1
  - Username: test
  - Protocol: MQTT v5
  ...
There is currently 1 client connected to your MQTT broker. Would you like more detailed information about this specific client or would you like to perform another action with your MQTT broker?

User:

Yes, please provide the detail info of this client. 

LLM:

I'll retrieve the detailed information for this client for you.
...
Here's the detailed information for client "mqttx_2232bdb1":

**Basic Information:**
-   **Client ID:** mqttx_2232bdb1
-   **Username:** test
...
**Connection Details:**
-   **Connected:** Yes
-   **Created At:** 2025-03-02T05:29:51.103+00:00
...
Would you like to perform any actions with this client, such as publishing a message to a topic or disconnecting the client?

User:

Please write a poem and send it to the topic '/poem' with QoS 1.

LLM:

I'll create a poem and publish it to the topic '/poem' with QoS 1. Let me do that for you.
...
I've successfully published the poem to the topic '/poem' with QoS 1. The message has been delivered with ID: 00062F55A1EFB1156ABC481240B30000.

The poem I sent was:

- Signals in the ether,
- Invisible threads that bind,
- Devices speak in whispers,
- Across the digital divide.
- Messages like leaves falling,
- From cloud to waiting ground,
- Connected yet untethered,
- Where silence makes no sound.
- Brokers of the modern age,
- Routing dreams from here to there,
- In this web of connections,
- We find ourselves everywhere.
- Like stars in constellation,
- Each point of light has worth,
- The language of machines,
- Redefining our Earth.

Is there anything else you'd like to do with your MQTT broker?

User:

Please kick out the client mqttx_2232bdb1

LLM

I'll disconnect the client from the MQTT broker for you.
...
The client has been successfully disconnected. The system returned:
> Client mqttx_2232bdb1 has been disconnected
The MQTT client with ID "mqttx_2232bdb1" is now disconnected from your broker. Is there anything else you would like to do with your MQTT broker?

License

This project is licensed under the Apache License Version 2.0 - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

iflow_mcp_benniu_emqx_mcp_server-0.1.0.tar.gz (27.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file iflow_mcp_benniu_emqx_mcp_server-0.1.0.tar.gz.

File metadata

  • Download URL: iflow_mcp_benniu_emqx_mcp_server-0.1.0.tar.gz
  • Upload date:
  • Size: 27.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for iflow_mcp_benniu_emqx_mcp_server-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2808632ed8f45f7ee2ff535811fff79dc12b5aba389c577e71e0dc7f263dd911
MD5 998d3ed337b07bbef7323cc5cb4320b5
BLAKE2b-256 3d0e0cdde65190f05b1978840a02324325b64d1a68fe4a1f9e21ea953bb81b91

See more details on using hashes here.

File details

Details for the file iflow_mcp_benniu_emqx_mcp_server-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: iflow_mcp_benniu_emqx_mcp_server-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 19.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for iflow_mcp_benniu_emqx_mcp_server-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1020a26716d1323b70bf49d8d21f73099d82a1f24cf009894b9df2a6f4fd14ac
MD5 47b0a4748286c6ad69dff4e345cc9e56
BLAKE2b-256 325c0baec4b14a416e02e22fc5b1b0b17f73dde2c0a620b49bbb85474363d4d2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page