Labsco
Benniu logo

EMQX MCP Server

β˜… 25

from Benniu

Interact with an EMQX MQTT broker via a Model Context Protocol (MCP) server.

πŸ”₯πŸ”₯πŸ”₯βœ“ VerifiedPaid serviceAdvanced setup

EMQX MCP Server

smithery badge

<a href="https://glama.ai/mcp/servers/m7zgbcr053"> <img width="380" height="200" src="https://glama.ai/mcp/servers/m7zgbcr053/badge" alt="emqx-mcp-server MCP server" /> </a>

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

MQTT Topic Subscription (SSE)

  • Real-time Subscription: Subscribe to MQTT topics via Server-Sent Events (SSE)
  • Duration Control: Configure how long to listen for messages (1-300 seconds)
  • Message Limiting: Set maximum number of messages to collect per subscription
  • Automatic Parsing: Messages are automatically parsed from SSE event stream

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)

subscribe_mqtt_topic

  • Subscribe to an MQTT topic via SSE on EMQX Cloud and collect messages for a specified duration
  • Inputs:
    • topic (string, required): MQTT topic to subscribe to
    • duration (number, optional): How long to listen in seconds (1-300, default: 30)
    • max_messages (number, optional): Maximum messages to collect (1-1000, default: 100)
  • Returns: Object containing topic, message_count, and messages array

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 subscribe to the topic 'sensor/temperature' for 10 seconds and show me the messages.

LLM:

I'll subscribe to the topic 'sensor/temperature' for 10 seconds to collect messages.
...
I received 3 messages from topic 'sensor/temperature' during the 10-second subscription:

1. {"temperature": 23.5, "unit": "celsius", "timestamp": "2025-03-02T10:00:01Z"}
2. {"temperature": 23.6, "unit": "celsius", "timestamp": "2025-03-02T10:00:04Z"}
3. {"temperature": 23.4, "unit": "celsius", "timestamp": "2025-03-02T10:00:07Z"}

Would you like to subscribe for a longer duration or take any other action?

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.