disconnect_client
Force disconnect a client from a UniFi network by providing its MAC address to manage network access and resolve connectivity issues.
Instructions
Force disconnect a client from the network
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| mac | Yes | MAC address of the client to disconnect |
Implementation Reference
- src/unifi_mcp/server.py:88-101 (registration)Tool registration including name, description, and input schema for disconnect_client tool.Tool( name="disconnect_client", description="Force disconnect a client from the network", inputSchema={ "type": "object", "properties": { "mac": { "type": "string", "description": "MAC address of the client to disconnect", } }, "required": ["mac"], }, ),
- src/unifi_mcp/server.py:206-214 (handler)MCP tool handler logic within the main call_tool function: extracts MAC from arguments, calls UniFiClient.disconnect_client, and returns success message.case "disconnect_client": mac = arguments.get("mac", "") await client.disconnect_client(mac) return [ TextContent( type="text", text=f"Client {mac} has been disconnected.", ) ]
- Core UniFiClient method that performs the actual API call to disconnect (kick-sta) the client by MAC address.async def disconnect_client(self, mac: str) -> bool: """Force disconnect a client. Args: mac: Client MAC address. Returns: True if disconnect command was sent successfully. """ await self._request( "POST", "/api/s/{site}/cmd/stamgr", json={"cmd": "kick-sta", "mac": mac.lower()}, ) return True
- src/unifi_mcp/tools/clients.py:151-170 (handler)Modular tool handler function for disconnect_client (potentially alternative or exported implementation).async def disconnect_client(mac: str) -> list[TextContent]: """Disconnect a client. Args: mac: MAC address of the client. Returns: List of text content with result. """ try: async with UniFiClient() as client: await client.disconnect_client(mac) return [ TextContent( type="text", text=f"Client {mac} has been disconnected.", ) ] except UniFiError as e: return [TextContent(type="text", text=f"Error: {e}")]
- src/unifi_mcp/tools/clients.py:65-78 (registration)Tool registration definition within list_client_tools for modular client tools.Tool( name="disconnect_client", description="Force disconnect a client from the network", inputSchema={ "type": "object", "properties": { "mac": { "type": "string", "description": "MAC address of the client to disconnect", } }, "required": ["mac"], }, ),