Skip to main content
Glama
handsomejustin

Xiaomi smart home MCP server

run_scene

Activate a Xiaomi smart home scene to run all preset device actions by supplying the scene ID.

Instructions

执行一个米家场景,触发该场景中预设的所有设备操作。

Args:
    scene_id: 场景ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
scene_idYes

Implementation Reference

  • MCP tool handler: registers 'run_scene' as an MCP tool that sends POST /api/scenes/{scene_id}/run to the backend API.
    @mcp.tool()
    async def run_scene(scene_id: str) -> dict:
        """执行一个米家场景,触发该场景中预设的所有设备操作。
    
        Args:
            scene_id: 场景ID
        """
        return await _request("POST", f"/scenes/{scene_id}/run")
  • Input/Output schema: accepts a single 'scene_id' string parameter, returns a dict (the JSON response from the API).
    @mcp.tool()
    async def run_scene(scene_id: str) -> dict:
        """执行一个米家场景,触发该场景中预设的所有设备操作。
    
        Args:
            scene_id: 场景ID
        """
        return await _request("POST", f"/scenes/{scene_id}/run")
  • Registration: the @mcp.tool() decorator registers 'run_scene' as an MCP tool on the FastMCP server.
    @mcp.tool()
    async def run_scene(scene_id: str) -> dict:
  • Flask API handler for POST /scenes/<scene_id>/run, the REST endpoint that the MCP tool calls.
    @scenes_ns.route("/<scene_id>/run", methods=["POST"])
    @auth_required
    @limiter.limit("30 per minute")
    def run_scene(scene_id):
        """执行场景
        ---
        tags:
          - 场景
        security:
          - cookieAuth: []
          - bearerAuth: []
        parameters:
          - in: path
            name: scene_id
            type: string
            required: true
        responses:
          200:
            description: 执行成功
        """
        try:
            result = SceneService.run_scene(get_current_user_id(), scene_id)
            return success(result)
        except Exception as e:
            return error(str(e), 500)
  • Helper service: the SceneService.run_scene method that looks up the home_id from cache and calls the MiJia API to execute the scene.
    def run_scene(user_id: int, scene_id: str) -> dict:
        api = api_pool.get_api(user_id)
        scene = SceneCache.query.filter_by(user_id=user_id, scene_id=scene_id).first()
        home_id = scene.home_id if scene else None
        api.run_scene(scene_id=scene_id, home_id=home_id)
        return {"scene_id": scene_id, "status": "executed"}
  • Automation helper: calls SceneService.run_scene when an automation rule's action_type is 'run_scene'.
    elif rule.action_type == "run_scene":
        cfg = rule.action_config
        SceneService.run_scene(rule.user_id, cfg["scene_id"])
Behavior2/5

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

No annotations are provided, so the description must carry the full burden. It only mentions that the scene triggers 'all device operations preset' but does not disclose side effects, destructive potential, or failure behavior.

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

Conciseness3/5

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

The description is very short and to the point, but lacks structure or additional information that would improve usability. It is concise but under-specified.

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?

Given the low complexity (single parameter, no output schema), the description could be considered minimally adequate, but it omits important details such as return values, error handling, or effects on the system.

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

Parameters2/5

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

Schema description coverage is 0%, and the description adds minimal extra meaning ('场景ID' for scene_id) beyond the schema's type definition. It does not explain how to obtain the scene ID or any constraints.

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 clearly states the action ('execute a Mijia scene') and identifies the resource ('scene'), distinguishing it from sibling tools like 'list_scenes' and 'run_action'. However, it is only in Chinese and lacks additional context for non-Chinese users.

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 vs alternatives, no prerequisites or conditions provided. The description only specifies the parameter without usage context.

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