Skip to main content
Glama

rms_product_ranking

Rank products by sales revenue for a specified date range, returning the top N products.

Instructions

Product sales ranking by revenue (from PackageModelList)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
start_dateNoYYYY-MM-DD
end_dateNoYYYY-MM-DD
top_nNoTop N

Implementation Reference

  • Handler function that fetches orders, aggregates product sales from PackageModelList/ItemModelList, ranks by revenue, and returns a formatted markdown table.
    async def _product_ranking(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)
        top_n = args.get("top_n", 20)
    
        orders = _fetch_all_orders(api, start, end, ACTIVE_PROGRESS)
        if not orders:
            return [TextContent(type="text", text="No orders found.")]
    
        ps: dict[str, dict] = defaultdict(lambda: {"n": "", "q": 0, "r": 0})
        for order in orders:
            for pkg in order.get("PackageModelList", []):
                for item in pkg.get("ItemModelList", []):
                    nm = item.get("itemName", "?")
                    qty = item.get("units", 0)
                    pr = item.get("price", 0)
                    key = f"{item.get('itemNumber','')}:{nm}"
                    ps[key]["n"] = nm
                    ps[key]["q"] += qty
                    ps[key]["r"] += qty * pr
    
        ranked = sorted(ps.items(), key=lambda x: x[1]["r"], reverse=True)[:top_n]
        lines = [f"# RMS Product Ranking: {start.date()} ~ {end.date()}\n| # | Product | Qty | Revenue | Avg |\n|---|---|---|---|---|"]
        for i, (_, s) in enumerate(ranked, 1):
            avg = s["r"] // s["q"] if s["q"] else 0
            lines.append(f"| {i} | {s['n']} | {s['q']} | ¥{s['r']:,} | ¥{avg:,} |")
        return [TextContent(type="text", text="\n".join(lines))]
  • Tool definition and input schema for rms_product_ranking, declaring start_date, end_date (strings) and top_n (integer, default 20).
    Tool(name="rms_product_ranking", description="Product sales ranking by revenue (from PackageModelList)",
         inputSchema={"type": "object", "properties": {
             "start_date": {"type": "string", "description": "YYYY-MM-DD"},
             "end_date": {"type": "string", "description": "YYYY-MM-DD"},
             "top_n": {"type": "integer", "description": "Top N", "default": 20},
         }}),
  • Registration/dispatch in call_tool that routes the 'rms_product_ranking' name to the _product_ranking handler.
    elif name == "rms_product_ranking":
        return await _product_ranking(arguments, api)
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden for behavioral disclosure. It only mentions data source ('PackageModelList') but does not specify if the operation is read-only, whether it aggregates data, or any performance implications.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence, very concise, and front-loaded with the main purpose. However, it could be slightly expanded with key context without losing conciseness.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple ranking tool, the description omits essential context: what the output looks like, whether results are ordered, and how to interpret the ranking. It lacks guidance on usage and behavioral transparency, making it incomplete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, so baseline is 3. The description adds context that the ranking is 'by revenue' from a specific list, but does not provide additional semantics for individual parameters (e.g., date range behavior, default for top_n).

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool ranks products by revenue from PackageModelList, which distinguishes it from sibling tools like cancellation rates or daily sales. However, it assumes knowledge of 'PackageModelList' without explanation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus siblings. There is no mention of prerequisites, exclusions, or scenarios where alternative tools would be more appropriate.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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/yasuhidekoizumi-afk/rms-mcp'

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