block_client
Block network access for a specific client device using its MAC address to restrict unauthorized connections or manage network security.
Instructions
Block a client from accessing the network
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| mac | Yes | MAC address of the client to block |
Implementation Reference
- src/unifi_mcp/server.py:60-73 (registration)Registration of the block_client MCP tool, defining its name, description, and input schema requiring a 'mac' string.Tool( name="block_client", description="Block a client from accessing the network", inputSchema={ "type": "object", "properties": { "mac": { "type": "string", "description": "MAC address of the client to block", } }, "required": ["mac"], }, ),
- src/unifi_mcp/server.py:186-194 (handler)Handler in @server.call_tool() that processes the tool call by extracting the MAC address, calling UniFiClient.block_client, and returning a success message.case "block_client": mac = arguments.get("mac", "") await client.block_client(mac) return [ TextContent( type="text", text=f"Client {mac} has been blocked from the network.", ) ]
- src/unifi_mcp/unifi_client.py:234-248 (handler)Core UniFiClient method implementing the block logic by sending a POST request to the UniFi controller's stamgr endpoint with the 'block-sta' command.async def block_client(self, mac: str) -> bool: """Block a client from the network. Args: mac: Client MAC address. Returns: True if block command was sent successfully. """ await self._request( "POST", "/api/s/{site}/cmd/stamgr", json={"cmd": "block-sta", "mac": mac.lower()}, ) return True