rms_cancel_rate
Retrieve cancellation rates and counts for orders within a specified date range.
Instructions
Cancellation rate and counts
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| start_date | No | YYYY-MM-DD | |
| end_date | No | YYYY-MM-DD |
Implementation Reference
- rms_mcp/server.py:158-169 (handler)The actual handler function for rms_cancel_rate. Computes cancellation rate by fetching all orders and those with progress 800 (cancel pending) or 900 (cancelled), then returns the rate as a percentage.
async def _cancel_rate(args: dict, api: OrderAPI) -> list[TextContent]: now = _now() start = datetime.fromisoformat(args.get("start_date", (now - timedelta(days=30)).strftime("%Y-%m-%d"))) end = datetime.fromisoformat(args.get("end_date", now.strftime("%Y-%m-%d"))) end = end.replace(hour=23, minute=59, second=59) all_r = api.search_orders(_to_rms(start), _to_rms(end)) total = len(all_r.get("orderNumberList", [])) cancel_r = api.search_orders(_to_rms(start), _to_rms(end), progress_list=[800, 900]) cancelled = len(cancel_r.get("orderNumberList", [])) rate = (cancelled / total * 100) if total else 0 return [TextContent(type="text", text=f"# RMS Cancel Rate: {start.date()} ~ {end.date()}\n- Total: {total}\n- Cancelled: {cancelled}\n- Rate: {rate:.1f}%")] - rms_mcp/server.py:66-70 (schema)Tool definition / schema for rms_cancel_rate. Declares the tool name, description, and input schema (start_date and end_date strings).
Tool(name="rms_cancel_rate", description="Cancellation rate and counts", inputSchema={"type": "object", "properties": { "start_date": {"type": "string", "description": "YYYY-MM-DD"}, "end_date": {"type": "string", "description": "YYYY-MM-DD"}, }}), - rms_mcp/server.py:84-88 (registration)Registration dispatch: routes the tool name 'rms_cancel_rate' to the _cancel_rate handler function when call_tool is invoked.
elif name == "rms_cancel_rate": return await _cancel_rate(arguments, api) return [TextContent(type="text", text=f"Unknown: {name}")] finally: c.close() - rms_mcp/order_api.py:18-27 (helper)OrderAPI.search_orders helper used by _cancel_rate to query orders by date range and optionally filter by progress list (e.g., [800, 900] for cancellations).
def search_orders(self, start_date: str, end_date: str, *, date_type: int = 1, progress_list: list[int] | None = None) -> dict: payload: dict[str, Any] = { "dateType": date_type, "startDatetime": start_date, "endDatetime": end_date, } if progress_list is not None: payload["orderProgressList"] = progress_list return self._c.post("/order/searchOrder/", json=payload).json()