Skip to main content
Glama
t2hnd

Bakery Data MCP Server

by t2hnd

query_transactions

Retrieve and filter bakery POS transaction records by date, product, payment method, or amount to analyze sales data.

Instructions

Query POS transaction data. Supports filtering by date range, product code/name, payment method, and amount range. Returns transaction details.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
start_dateNoStart date (YYYY-MM-DD format). Optional.
end_dateNoEnd date (YYYY-MM-DD format). Optional.
product_codeNoProduct code to filter by. Optional.
product_nameNoProduct name to search (partial match). Optional.
payment_methodNoPayment method (e.g., '現金', 'クレジット'). Optional.
min_amountNoMinimum transaction amount. Optional.
max_amountNoMaximum transaction amount. Optional.
limitNoMaximum number of results to return. Default: 100.

Implementation Reference

  • The core handler logic within the call_tool function that processes input arguments, dynamically builds an SQL query to filter transactions table based on provided parameters, executes the query using the database cursor, fetches results, and returns them as JSON-formatted text content.
    if name == "query_transactions":
        # Build query with filters
        query = "SELECT * FROM transactions WHERE 1=1"
        params = []
    
        if "start_date" in arguments:
            query += " AND datetime >= ?"
            params.append(arguments["start_date"])
    
        if "end_date" in arguments:
            query += " AND datetime <= ?"
            params.append(arguments["end_date"] + " 23:59:59")
    
        if "product_code" in arguments:
            query += " AND product_code = ?"
            params.append(arguments["product_code"])
    
        if "product_name" in arguments:
            query += " AND product_name LIKE ?"
            params.append(f"%{arguments['product_name']}%")
    
        if "payment_method" in arguments:
            query += " AND payment_method = ?"
            params.append(arguments["payment_method"])
    
        if "min_amount" in arguments:
            query += " AND amount >= ?"
            params.append(arguments["min_amount"])
    
        if "max_amount" in arguments:
            query += " AND amount <= ?"
            params.append(arguments["max_amount"])
    
        query += " ORDER BY datetime DESC LIMIT ?"
        params.append(arguments.get("limit", 100))
    
        cursor.execute(query, params)
        results = cursor.fetchall()
    
        return [TextContent(
            type="text",
            text=json.dumps(results, ensure_ascii=False, indent=2)
        )]
  • Input schema for the query_transactions tool, defining optional parameters for filtering by date range, product details, payment method, amount range, and result limit.
    inputSchema={
        "type": "object",
        "properties": {
            "start_date": {
                "type": "string",
                "description": "Start date (YYYY-MM-DD format). Optional."
            },
            "end_date": {
                "type": "string",
                "description": "End date (YYYY-MM-DD format). Optional."
            },
            "product_code": {
                "type": "string",
                "description": "Product code to filter by. Optional."
            },
            "product_name": {
                "type": "string",
                "description": "Product name to search (partial match). Optional."
            },
            "payment_method": {
                "type": "string",
                "description": "Payment method (e.g., '現金', 'クレジット'). Optional."
            },
            "min_amount": {
                "type": "number",
                "description": "Minimum transaction amount. Optional."
            },
            "max_amount": {
                "type": "number",
                "description": "Maximum transaction amount. Optional."
            },
            "limit": {
                "type": "number",
                "description": "Maximum number of results to return. Default: 100."
            }
        }
    }
  • Registration of the query_transactions tool in the list_tools() function via the MCP Tool object, including name, description, and input schema.
    Tool(
        name="query_transactions",
        description="Query POS transaction data. Supports filtering by date range, product code/name, payment method, and amount range. Returns transaction details.",
        inputSchema={
            "type": "object",
            "properties": {
                "start_date": {
                    "type": "string",
                    "description": "Start date (YYYY-MM-DD format). Optional."
                },
                "end_date": {
                    "type": "string",
                    "description": "End date (YYYY-MM-DD format). Optional."
                },
                "product_code": {
                    "type": "string",
                    "description": "Product code to filter by. Optional."
                },
                "product_name": {
                    "type": "string",
                    "description": "Product name to search (partial match). Optional."
                },
                "payment_method": {
                    "type": "string",
                    "description": "Payment method (e.g., '現金', 'クレジット'). Optional."
                },
                "min_amount": {
                    "type": "number",
                    "description": "Minimum transaction amount. Optional."
                },
                "max_amount": {
                    "type": "number",
                    "description": "Maximum transaction amount. Optional."
                },
                "limit": {
                    "type": "number",
                    "description": "Maximum number of results to return. Default: 100."
                }
            }
        }
    ),
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions the tool 'Returns transaction details' but provides no information about permissions required, rate limits, pagination behavior (beyond the 'limit' parameter), error conditions, or what format the transaction details take. For a query tool with 8 parameters, this leaves significant behavioral aspects undocumented.

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 appropriately concise with two sentences that efficiently convey the core functionality. The first sentence states the purpose and supported filters, while the second specifies the return type. There's no wasted text, though it could be slightly more structured by explicitly grouping related parameters or mentioning default behaviors.

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

Completeness3/5

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

For a query tool with 8 optional parameters and no output schema, the description is moderately complete. It covers the basic purpose and filtering capabilities but lacks important context about the return format (what 'transaction details' includes), result ordering, error handling, and performance characteristics. With no annotations and no output schema, the agent has insufficient information about what to expect from this tool's behavior.

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 description lists the filtering capabilities (date range, product code/name, payment method, amount range), which aligns with the 8 parameters in the schema. Since schema description coverage is 100%, the schema already documents all parameters thoroughly. The description adds minimal value beyond what's in the schema - it provides a high-level grouping of parameters but no additional semantic context about how filters combine or their precedence.

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's purpose: 'Query POS transaction data' specifies both the verb (query) and resource (POS transaction data). It distinguishes from siblings like 'query_products' or 'sales_summary' by focusing specifically on transaction data rather than products or aggregated sales. However, it doesn't explicitly contrast with 'execute_sql' which could also query transactions.

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?

The description provides no guidance on when to use this tool versus alternatives. With siblings like 'execute_sql' (which could query transactions directly), 'sales_summary' (which provides aggregated data), and 'query_products' (which focuses on products), there's no indication of when this filtered transaction query is preferable. The description only states what it does, not when to choose it.

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/t2hnd/bakery_data_mcp'

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