Skip to main content
Glama

commerce_analytics

Retrieve and analyze e-commerce data including sales, inventory, and customer metrics to generate actionable insights for optimizing store performance.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The analytics_report function is the core handler implementation for the commerce_analytics tool. It queries the database for orders, aggregates sales data by channel and product, calculates total orders and revenue, and returns a comprehensive analytics report including sales summary, channel breakdown, product breakdown, and daily sales data.
    def analytics_report(*, db_path: Path | str) -> dict[str, object]:
        database = Database(db_path)
        database.bootstrap()
    
        orders = database.list_orders()
        by_channel: dict[str, dict[str, int]] = defaultdict(lambda: {"orders": 0, "revenue": 0})
        by_product: dict[str, dict[str, int]] = defaultdict(lambda: {"orders": 0, "revenue": 0})
    
        total_orders = len(orders)
        total_revenue = 0
        for order in orders:
            revenue = int(order["selling_price"]) * int(order["quantity"])
            total_revenue += revenue
            by_channel[str(order["channel"])]["orders"] += 1
            by_channel[str(order["channel"])]["revenue"] += revenue
            by_product[str(order["product_id"])]["orders"] += int(order["quantity"])
            by_product[str(order["product_id"])]["revenue"] += revenue
    
        return {
            "sales": {
                "total_orders": total_orders,
                "total_revenue": total_revenue,
            },
            "channels": by_channel,
            "products": by_product,
            "daily_sales": database.list_daily_sales(),
        }
  • core/server.py:102-104 (registration)
    The commerce_analytics tool is registered with the MCP framework using the @app.tool decorator with name="commerce_analytics". This registration wraps the analytics_report handler and exposes it as a tool that can be called through the MCP protocol. The tool takes no input parameters and returns a dictionary containing sales analytics.
    @app.tool(name="commerce_analytics")
    def commerce_analytics() -> dict[str, object]:
        return analytics_report(db_path=resolved_db_path)
  • Import statement that brings analytics_report from tools.analytics into the server module, enabling the commerce_analytics tool registration to call the handler function.
    from __future__ import annotations
    
    import os
    from pathlib import Path
    
    from fastmcp import FastMCP
    
    from core.models import StandardProduct
    from tools.ad_create import create_ad
    from tools.ad_report import report_ad
    from tools.analytics import analytics_report
Behavior1/5

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

Tool has no description.

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

Conciseness1/5

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

Tool has no description.

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

Completeness1/5

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

Tool has no description.

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

Parameters1/5

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

Tool has no description.

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

Purpose1/5

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

Tool has no description.

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

Usage Guidelines1/5

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

Tool has no description.

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/sinmb79/Commerc-MCP'

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