Skip to main content
Glama
handsomejustin

Xiaomi smart home MCP server

list_ble_devices

Retrieve all registered Bluetooth sensor devices and their latest temperature and humidity readings.

Instructions

列出所有已注册的蓝牙传感器设备,返回设备信息和最新温湿度读数。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • MCP tool registration for 'list_ble_devices' using @mcp.tool() decorator. The tool is registered as an async function that calls GET /ble/devices via the internal _request helper.
    @mcp.tool()
    async def list_ble_devices() -> dict:
        """列出所有已注册的蓝牙传感器设备,返回设备信息和最新温湿度读数。"""
        return await _request("GET", "/ble/devices")
  • Actual business logic: BLEService.list_devices() queries BLEDevice by user_id, converts each to dict via _device_to_dict(), and attaches latest_reading via _get_latest_reading().
    @staticmethod
    def list_devices(user_id: int) -> list[dict]:
        devices = BLEDevice.query.filter_by(user_id=user_id).all()
        result = []
        for d in devices:
            info = BLEService._device_to_dict(d)
            latest = BLEService._get_latest_reading(d.id)
            info["latest_reading"] = latest
            result.append(info)
        return result
  • Flask HTTP handler that receives GET /ble/devices, extracts user_id from auth, calls BLEService.list_devices(user_id), and returns JSON success response.
    @ble_bp.route("/ble/devices", methods=["GET"])
    @auth_required
    def list_ble_devices():
        user_id = get_current_user_id()
        devices = BLEService.list_devices(user_id)
        return success(data=devices)
  • Internal _request() helper used by the MCP tool to make HTTP calls to the backend API with authorization headers.
    async def _request(method: str, path: str, *, json_data: dict | None = None, params: dict | None = None):
        async with httpx.AsyncClient(timeout=30) as client:
            resp = await client.request(method, f"{_BASE_URL}{path}", json=json_data, params=params, headers=_headers())
            return resp.json()
  • Helper method _device_to_dict() that converts a BLEDevice model instance into a dictionary for API serialization.
    def _device_to_dict(device: BLEDevice) -> dict:
        return {
            "id": device.id,
            "did": device.did,
            "mac_address": device.mac_address,
            "model": device.model,
            "capabilities": device.capabilities or [],
            "is_enabled": device.is_enabled,
            "last_seen_at": device.last_seen_at.isoformat() if device.last_seen_at else None,
        }
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It states it lists devices and returns readings, which implies a read operation, but it does not explicitly disclose whether it is safe, requires authentication, or has rate limits. The description lacks behavioral context beyond the obvious.

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 a single efficient sentence that is front-loaded and to the point. Every word is necessary, no filler.

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

Completeness4/5

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

Given no parameters and no output schema, the description is fairly complete for a list tool. It mentions the type of returned data. However, it could be improved by noting whether the list is paginated or if there are any filtering capabilities.

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?

There are zero parameters, so baseline is 4 per instructions. The description adds value by explaining the return content (device info and latest temperature/humidity readings), which goes beyond the empty schema.

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 it lists all registered BLE sensor devices and returns device info with latest temp/humidity readings. It distinguishes from siblings like list_devices which likely lists all device types, and get_ble_readings which may return historical readings.

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

Usage Guidelines3/5

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

The description implies this tool is for getting an overview of BLE sensors, but no explicit when-to-use or when-not-to-use guidance is given. Siblings include get_ble_readings and get_ble_sensor, but the description does not differentiate use cases or provide exclusions.

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/handsomejustin/mijia-control'

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