Skip to main content
Glama

set_charging

Control robot vacuum charging actions on Ecovacs MCP Server. Use 'go-start' to return the robot to the charging station or 'stopGo' to halt the process. Specify the robot nickname for targeted control.

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
actNoRobot action, go-start begin returning to charging station, stopGo stop returning to charging stationgo-start
nicknameYesRobot nickname, used to find device

Implementation Reference

  • The main handler implementation for the 'set_charging' tool. This async function is decorated with @mcp.tool() for automatic registration and uses Pydantic Field for input schema validation. It invokes the API to command the robot to charge.
    @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})
  • The @mcp.tool() decorator registers the set_charging function as an MCP tool.
    @mcp.tool()
  • Input schema defined using Pydantic Field in the function signature, specifying parameters for robot nickname and charging action.
    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:
  • Shared helper function call_api used by set_charging 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