create_robot_command
Send commands like start, pause, or stop tasks to a GS cleaning robot using its serial number.
Instructions
Creates a robot command.
Based on: https://developer.gs-robot.com/zh_CN/Robot%20Command%20Service/Create%20Robot%20Command
Args:
serial_number: The serial number of the target robot.
command_type: The type of command (e.g., 'START_TASK', 'PAUSE_TASK', 'STOP_TASK').
command_parameter: Optional command parameters as a dictionary.
Returns:
A dictionary containing the command creation result.Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| serial_number | Yes | ||
| command_type | Yes | ||
| command_parameter | No |
Implementation Reference
- src/gs_openapi/main.py:65-88 (registration)The MCP tool 'create_robot_command' is registered via the @mcp.tool() decorator. It's an async function that delegates to mcp.create_robot_command(), passing serial_number, command_type, and command_parameter.
# Define create_robot_command tool @mcp.tool() async def create_robot_command( serial_number: str, command_type: str, command_parameter: Optional[dict] = None ): """Creates a robot command. Based on: https://developer.gs-robot.com/zh_CN/Robot%20Command%20Service/Create%20Robot%20Command Args: serial_number: The serial number of the target robot. command_type: The type of command (e.g., 'START_TASK', 'PAUSE_TASK', 'STOP_TASK'). command_parameter: Optional command parameters as a dictionary. Returns: A dictionary containing the command creation result. """ return await mcp.create_robot_command( serial_number=serial_number, command_type=command_type, command_parameter=command_parameter ) - The actual handler implementation of create_robot_command in the GausiumMCP class. Validates inputs, builds the request payload with serialNumber, remoteTaskCommandType, and optional commandParameter, then calls the API endpoint 'create_command' via GausiumAPIClient.
async def create_robot_command( self, serial_number: str, command_type: str, command_parameter: Optional[Dict[str, Any]] = None ) -> Dict[str, Any]: """ 创建机器人指令。 Args: serial_number: 机器人序列号 command_type: 指令类型 (如 'START_TASK', 'PAUSE_TASK', 等) command_parameter: 指令参数 Returns: 指令创建结果 Raises: ValueError: 参数无效 httpx.HTTPStatusError: API调用错误 httpx.RequestError: 网络问题 """ if not serial_number: raise ValueError("Serial number cannot be empty") if not command_type: raise ValueError("Command type cannot be empty") request_data = { "serialNumber": serial_number, "remoteTaskCommandType": command_type } if command_parameter: request_data["commandParameter"] = command_parameter async with GausiumAPIClient() as client: return await client.call_endpoint( 'create_command', path_params={'serial_number': serial_number}, json_data=request_data ) - The endpoint definition for 'create_command' used by the handler. Defines the API path as 'v1alpha1/robots/{serial_number}/commands' with POST method, mapping to the 'create_robot_command' API service.
# 机器人指令服务端点 ROBOT_COMMAND_ENDPOINTS = { 'create_command': APIEndpoint( name="create_robot_command", path="robots/{serial_number}/commands", method=HTTPMethod.POST, version=APIVersion.V1_ALPHA1, description="创建机器人指令" ), 'get_command': APIEndpoint( name="get_robot_command", path="robots/{serial_number}/commands/{command_id}", method=HTTPMethod.GET, version=APIVersion.V1_ALPHA1, description="获取单条指令结果" ), 'list_commands': APIEndpoint( name="list_robot_commands", path="robots/{serial_number}/commands", method=HTTPMethod.GET, version=APIVersion.V1_ALPHA1, description="获取机器人历史发出指令" ) }