Skip to main content
Glama

get_work_state

Retrieve the current working status of an Ecovacs robot vacuum by querying its nickname. Essential for monitoring cleaning progress and device activity.

Instructions

Query robot working status

Args: nickname: Robot nickname, used to find device

Returns: Dict: Dictionary containing robot working status

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nicknameYesRobot nickname, used to find device

Implementation Reference

  • The @mcp.tool() decorator registers the get_work_state function as an MCP tool.
    @mcp.tool()
  • The handler function implements the logic for the get_work_state tool by calling the Ecovacs API endpoint for robot control with the GetWorkState command.
    async def get_work_state( nickname: str = Field(description="Robot nickname, used to find device") ) -> dict: """ Query robot working status Args: nickname: Robot nickname, used to find device Returns: Dict: Dictionary containing robot working status """ return await call_api(ENDPOINT_ROBOT_CTL, {"nickName": nickname, "cmd": "GetWorkState", "act": ""})
  • Pydantic input schema definition using Field for the nickname parameter, including description for MCP tool schema.
    nickname: str = Field(description="Robot nickname, used to find device")
  • Helper function call_api used by get_work_state to make HTTP requests to the Ecovacs API.
    async def call_api(endpoint: str, params: dict, method: str = 'post') -> dict: """ General API call function Args: endpoint: API endpoint params: Request parameters method: Request method, 'get' or 'post' Returns: Dict: API response result, format {"msg": "OK", "code": 0, "data": [...]} """ # Build complete URL url = f"{API_URL}/{endpoint}" # Ensure all parameters are strings params = {k: str(v) for k, v in params.items()} # Add API key if API_KEY: params.update({"ak": API_KEY}) try: async with httpx.AsyncClient() as client: headers = {"Content-Type": "application/json"} if method.lower() == 'get': response = await client.get(url, params=params, timeout=REQUEST_TIMEOUT) else: response = await client.post(url, json=params, headers=headers, timeout=REQUEST_TIMEOUT) response.raise_for_status() return response.json() except Exception as e: # Return unified error format when an error occurs return {"msg": f"Request failed: {str(e)}", "code": -1, "data": []}

Other Tools

Related 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/ecovacs-ai/ecovacs-mcp'

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