Skip to main content
Glama

list_devices

Retrieve cached WeMo smart home devices discovered in previous network scans to view available device names and IP addresses for management.

Instructions

List all discovered WeMo devices from the cache.

Returns a list of devices that were found in previous network scans. Run scan_network first to populate the device cache.

Returns

Dictionary containing:
- device_count: Number of cached devices
- devices: List of device names and IPs

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The list_devices function is implemented as an MCP tool, querying the _device_cache and falling back to a persistent JSON cache if the in-memory cache is empty.
    @mcp.tool()
    async def list_devices() -> dict[str, Any]:
        """List all discovered WeMo devices from the cache.
    
        Returns a list of devices that were found in previous network scans.
        Run scan_network first to populate the device cache.
    
        Returns
        -------
            Dictionary containing:
            - device_count: Number of cached devices
            - devices: List of device names and IPs
    
        """
        try:
            # Get unique devices from in-memory cache (device cache may have duplicates by name and IP)
            unique_devices: dict[str, dict[str, Any]] = {}
            for key, device in _device_cache.items():
                device_name = device.name
                if device_name not in unique_devices:
                    unique_devices[device_name] = {
                        "name": device_name,
                        "ip_address": getattr(device, "host", "unknown"),
                        "model": getattr(device, "model", "Unknown"),
                        "type": type(device).__name__,
                        "source": "memory",
                    }
    
            # If in-memory cache is empty, fall back to persistent JSON cache
            if not unique_devices:
                cached_data = _cache_manager.load()
                if cached_data:
                    for _key, info in cached_data.items():
                        if not isinstance(info, dict):
                            continue
                        name = info.get("name", _key)
                        if name not in unique_devices:
                            unique_devices[name] = {
                                "name": name,
                                "ip_address": info.get("host", "unknown"),
                                "model": info.get("model_name") or info.get("model", "Unknown"),
                                "type": info.get("device_type", "Unknown"),
                                "source": "file_cache",
                            }
    
            result: dict[str, Any] = {
                "device_count": len(unique_devices),
                "devices": list(unique_devices.values()),
            }
            if unique_devices and all(d.get("source") == "file_cache" for d in unique_devices.values()):
                result["note"] = (
                    "Devices loaded from persistent cache file (server was restarted). "
                    "Control commands will automatically reconnect to devices as needed."
                )
            return result
        except Exception as e:
            logger.error(f"Error listing devices: {e}", exc_info=True)
            error_response = build_error_response(e, "List devices")
            error_response.update({"device_count": 0, "devices": []})
            return error_response
Behavior4/5

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

With no annotations provided, the description carries full burden and does well: it discloses that this tool reads from a cache (not live network), requires prior execution of scan_network, and returns specific data structure. It doesn't mention error conditions or performance characteristics, but covers the essential behavioral context adequately.

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 perfectly front-loaded with the core purpose in the first sentence, followed by prerequisite guidance and return format. Every sentence earns its place with no redundant information. The structure with clear section headers ('Returns') enhances readability.

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

Completeness5/5

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

Given the tool's simplicity (0 parameters, read-only operation) and the presence of an output schema (implied by 'Has output schema: true'), the description is complete: it explains what the tool does, when to use it, prerequisites, and the return structure. No additional information is needed for effective use.

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

Parameters4/5

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

The tool has 0 parameters with 100% schema description coverage. The description appropriately doesn't discuss parameters since none exist, and instead focuses on prerequisites and return values. A baseline of 4 is appropriate for zero-parameter tools when the description provides useful context.

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 ('List all discovered WeMo devices from the cache') and resource ('WeMo devices'), distinguishing it from siblings like scan_network (which populates the cache) or get_device_status (which checks individual device status). The verb 'List' is precise and the scope 'from the cache' is well-defined.

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

Usage Guidelines5/5

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

The description provides explicit guidance on when to use this tool ('Run scan_network first to populate the device cache') and implies when not to use it (if the cache is empty). It also distinguishes from alternatives by specifying this lists cached devices from previous scans, not current network devices.

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/apiarya/wemo-mcp-server'

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