Skip to main content
Glama
Benniu

emqx-mcp-server

by Benniu

kick_mqtt_client

Disconnect a client from the MQTT broker using its client ID to manage connections and enforce access control.

Instructions

Disconnect a client from the MQTT broker by client ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
requestYes

Implementation Reference

  • MCP tool handler for 'kick_mqtt_client'. Validates input, logs, delegates to EMQXClient.kick_client, and returns result. Also serves as registration via @mcp.tool decorator.
    @mcp.tool(name="kick_mqtt_client", 
              description="Disconnect a client from the MQTT broker by client ID")
    async def kick_client(request):
        """Handle kick client request
        
        Args:
            request: MCP request containing client identifier
                - clientid: Client ID (required) - The unique identifier of the client to disconnect
    
        Returns:
            MCPResponse: Response object with the result of the disconnect operation
        """
        self.logger.info("Handling kick client request")
        
        # Extract required client ID parameter
        clientid = request.get("clientid")
        if not clientid:
            self.logger.error("Client ID is required but was not provided")
            return {"error": "Client ID is required"}
        
        # Kick client from EMQX
        result = await self.emqx_client.kick_client(clientid)
        
        self.logger.info(f"Client '{clientid}' disconnect request processed")
        return result 
  • Core helper method in EMQXClient that executes the HTTP DELETE request to /clients/{clientid} to disconnect the MQTT client.
    async def kick_client(self, clientid: str):
        """
        Kick out (disconnect) a client from the MQTT broker.
        
        Uses the EMQX HTTP API to forcibly disconnect a client identified by its client ID.
        
        Args:
            clientid (str): The unique identifier of the client to disconnect
            
        Returns:
            dict: Response from the EMQX API or error information
        """
        url = f"{self.api_url}/clients/{clientid}"
        
        self.logger.info(f"Kicking out client with ID: {clientid}")
        
        async with httpx.AsyncClient() as client:
            try:
                response = await client.delete(
                    url,
                    headers=self._get_auth_header(),
                    timeout=30
                )
                response.raise_for_status()
                # For successful delete operations, return a success message
                if response.status_code == 204:  # No Content
                    return {"success": True, "message": f"Client {clientid} has been disconnected"}
                return self._handle_response(response)
            except Exception as e:
                self.logger.error(f"Error kicking out client {clientid}: {str(e)}")
                return {"error": str(e)}
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but only states the action without behavioral details. It doesn't disclose if this is destructive (likely yes), requires specific permissions, has side effects (e.g., message loss), rate limits, or error conditions (e.g., invalid client ID).

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero waste. It's front-loaded with the core action and resource, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (destructive action, 1 parameter), lack of annotations, 0% schema coverage, and no output schema, the description is incomplete. It fails to address key aspects like parameter meaning, behavioral traits, or expected outcomes, leaving significant gaps for agent understanding.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, and the description adds no parameter semantics beyond the schema. It mentions 'by client ID' but doesn't clarify that the 'request' parameter is the client ID, its format, or constraints, leaving the single required parameter undocumented.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Disconnect') and target resource ('a client from the MQTT broker by client ID'). It distinguishes from siblings like 'get_mqtt_client' (retrieve) and 'list_mqtt_clients' (enumerate) by focusing on termination of connections.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., client must be connected), exclusions, or compare with sibling tools like 'publish_mqtt_message' for messaging versus disconnection.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

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/Benniu/emqx-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server