Skip to main content
Glama
sealablab

Moku MCP Server

by sealablab

attach_moku

Connect to a Moku device and assume control for configuration and signal routing. Specify device by IP, name, or serial number to manage ownership.

Instructions

Connect to Moku device and assume ownership

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
device_idYesIP address, device name, or serial number
forceNoForce connection even if owned by another client

Implementation Reference

  • The attach_moku method implementation in MokuServer, responsible for connecting to a Moku device and handling ownership.
    async def attach_moku(self, device_id: str, force: bool = False):
        """
        Connect to Moku device and assume ownership.
    
        Args:
            device_id: IP address, name, or serial number
            force: Force connection even if owned by another client
    
        Returns:
            {
                "status": "connected",
                "device": {
                    "ip": "192.168.1.100",
                    "name": "Lilo",
                    "serial": "MG106B",
                    "platform": "Moku:Go"
                }
            }
    
        Implementation: See IMPLEMENTATION_GUIDE.md Section 3.2
        """
        from moku.instruments import MultiInstrument
        from .utils import resolve_device_identifier, load_device_cache
    
        # Check if already connected
        if self.moku_instance:
            if self.connected_device == device_id:
                return {
                    "status": "already_connected",
                    "message": f"Already connected to {device_id}",
                    "device": {"ip": self.connected_device, "platform": "Moku:Go"},
                }
            else:
                return {
                    "status": "error",
                    "message": f"Already connected to {self.connected_device}. Release first.",
                    "suggestion": "Call release_moku() before connecting to a different device",
                }
    
        # Resolve device_id to IP
        ip = resolve_device_identifier(device_id)
        if not ip:
            # If not in cache, check if it's a valid IP
            if "." in device_id and device_id.replace(".", "").isdigit():
                ip = device_id
            else:
                return {
                    "status": "error",
                    "message": f"Device '{device_id}' not found in cache",
                    "suggestion": "Run discover_mokus() first to find devices",
                }
    
        # Try to connect (platform_id=2 for Moku:Go)
        try:
            logger.info(f"Attempting to connect to {ip} (force={force})")
            self.moku_instance = MultiInstrument(ip, platform_id=2, force_connect=force)
            self.connected_device = ip
    
            # Get device info from cache
            cache = load_device_cache()
            device_info = cache.find_by_ip(ip)
    
            logger.info(f"Successfully connected to Moku at {ip}")
    
            return {
                "status": "connected",
                "device": {
                    "ip": ip,
                    "name": device_info.canonical_name if device_info else "Unknown",
                    "serial": device_info.serial_number if device_info else "Unknown",
                    "platform": "Moku:Go",
                },
            }
    
        except ConnectionError as e:
            logger.error(f"Connection failed: {e}")
            return {
                "status": "error",
                "message": f"Could not connect to {ip}. Device may be offline or owned by another client.",
                "suggestion": "Try with force=True to take ownership, or wait for current owner to disconnect.",
                "details": str(e),
            }
        except Exception as e:
            logger.error(f"Unexpected error connecting to {ip}: {e}")
            self.moku_instance = None
            self.connected_device = None
            return {
                "status": "error",
                "message": f"Failed to connect to {ip}",
                "details": str(e),
            }
Behavior3/5

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

With no annotations provided, the description carries the full burden. The phrase 'assume ownership' hints at exclusive access semantics, but fails to explain failure modes (what happens if another client owns it without 'force'?), session persistence, or cleanup requirements. The mention of ownership is valuable but insufficient for a stateful connection tool.

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

Conciseness4/5

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

Single sentence is front-loaded with the core action. However, given the lack of annotations and the complex stateful nature of device ownership, the description is overly minimal rather than appropriately concise—leaving critical behavioral gaps.

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?

For a stateful connection tool with ownership semantics, the description is incomplete. It lacks: prerequisites (discovery), success/failure outcomes, the exclusive nature of ownership, cleanup obligations, and the fact that this is required before using configuration siblings. No output schema exists to compensate.

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

Parameters3/5

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

Input schema has 100% description coverage, establishing a baseline of 3. The main description adds no parameter-specific guidance (e.g., when to use 'force=true', or format examples for 'device_id' like IP vs serial number), but the schema adequately documents both parameters.

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

Purpose4/5

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

The description uses specific verbs ('Connect', 'assume ownership') and identifies the resource ('Moku device'). However, it doesn't explicitly distinguish from sibling tools like 'discover_mokus' (which finds devices) or 'release_moku' (which drops ownership), though 'assume ownership' implies the state transition.

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 on when to use this tool versus alternatives. Missing crucial workflow context: it should mention that 'discover_mokus' typically precedes this call, that this must be called before configuration tools like 'push_config', and that 'release_moku' should be called when finished.

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/sealablab/moku-mcp'

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