discover_mokus
Find Moku devices on your network using zeroconf discovery to enable LLM control and configuration management.
Instructions
Discover Moku devices on network via zeroconf
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| timeout | No | Discovery timeout in seconds (default: 2) |
Implementation Reference
- src/moku_mcp/server.py:66-125 (handler)The implementation of the discover_mokus handler, which uses Zeroconf to find Moku devices on the network.
async def discover_mokus(self, timeout: int = 2): """ Discover Moku devices on network via zeroconf. Args: timeout: Discovery timeout in seconds (default: 2) Returns: { "devices": [ { "ip": "192.168.1.100", "name": "Lilo", "serial": "MG106B", "port": 80, "last_seen": "2025-10-25T20:00:00Z" } ], "count": 1 } Implementation: See IMPLEMENTATION_GUIDE.md Section 3.1 """ from moku import Moku from .utils import update_cache_with_device discovered = [] zc = Zeroconf() def on_service_change(zeroconf, service_type, name, state_change): """Handle zeroconf service discovery events.""" if state_change == ServiceStateChange.Added: info = zeroconf.get_service_info(service_type, name) if info: # Extract IPv4 address addresses = info.parsed_addresses() ipv4 = [addr for addr in addresses if ":" not in addr] ip = ipv4[0] if ipv4 else addresses[0] if addresses else None if ip: device = MokuDeviceInfo( ip=ip, port=info.port if info.port else 80, zeroconf_name=name, last_seen=datetime.now(timezone.utc).isoformat(), ) discovered.append(device) logger.info(f"Discovered device at {ip}:{info.port}") # Start discovery browser = ServiceBrowser(zc, "_moku._tcp.local.", handlers=[on_service_change]) # Wait for discovery await asyncio.sleep(timeout) # Close zeroconf zc.close() # Enrich with metadata (name, serial) via Moku API for device in discovered: - src/moku_mcp/tools.py:22-29 (registration)The registration of the discover_mokus tool definition.
Tool( name="discover_mokus", description="Discover Moku devices on network via zeroconf", inputSchema={ "type": "object", "properties": { "timeout": { "type": "number",