Skip to main content
Glama

set_charging

Control robot vacuum charging by sending it to the charging station or stopping the return process using the Ecovacs MCP Server.

Instructions

Make robot return to charging station

Args: nickname: Robot nickname, used to find device act: Robot action, go-start begin returning to charging station, stopGo stop returning to charging station

Returns: Dict: Dictionary containing execution results

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nicknameYesRobot nickname, used to find device
actNoRobot action, go-start begin returning to charging station, stopGo stop returning to charging stationgo-start

Implementation Reference

  • The handler function for the 'set_charging' tool, decorated with @mcp.tool() for registration. It takes nickname and act parameters, validates with Pydantic Fields (schema), and calls the shared API helper with 'Charge' command.
    @mcp.tool()
    async def set_charging(
        nickname: str = Field(description="Robot nickname, used to find device"),
        act: str = Field(description="Robot action, go-start begin returning to charging station, stopGo stop returning to charging station", default="go-start")
    ) -> dict:
        """
        Make robot return to charging station
        
        Args:
            nickname: Robot nickname, used to find device
            act: Robot action, go-start begin returning to charging station, stopGo stop returning to charging station
        
        Returns:
            Dict: Dictionary containing execution results
        """
        return await call_api(ENDPOINT_ROBOT_CTL, {"nickName": nickname, "cmd": "Charge", "act": act})
  • Shared helper function used by set_charging to make HTTP API calls 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": []}

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