Skip to main content
Glama
by t2hnd

query_products

Search bakery product data by code, name, department, price range, or tags to find items in the catalog.

Instructions

Query product master data. Search by product code, name, department, price range, or tags.

Input Schema

NameRequiredDescriptionDefault
plu_codeNoProduct PLU code. Optional.
product_nameNoProduct name to search (partial match). Optional.
department_idNoDepartment ID. Optional.
min_priceNoMinimum price. Optional.
max_priceNoMaximum price. Optional.
tagNoSearch products by tag (uses extended product table). Optional.
include_tagsNoInclude tag information in results. Default: false.
limitNoMaximum number of results. Default: 100.

Input Schema (JSON Schema)

{ "properties": { "department_id": { "description": "Department ID. Optional.", "type": "number" }, "include_tags": { "description": "Include tag information in results. Default: false.", "type": "boolean" }, "limit": { "description": "Maximum number of results. Default: 100.", "type": "number" }, "max_price": { "description": "Maximum price. Optional.", "type": "number" }, "min_price": { "description": "Minimum price. Optional.", "type": "number" }, "plu_code": { "description": "Product PLU code. Optional.", "type": "string" }, "product_name": { "description": "Product name to search (partial match). Optional.", "type": "string" }, "tag": { "description": "Search products by tag (uses extended product table). Optional.", "type": "string" } }, "type": "object" }

Implementation Reference

  • Handler function for 'query_products' tool. Builds dynamic SQL query based on input parameters to fetch products from 'products' or 'products_extended' table, applies filters, and returns JSON results.
    elif name == "query_products": # Determine which table to use include_tags = arguments.get("include_tags", False) has_tag_filter = "tag" in arguments table = "products_extended" if (include_tags or has_tag_filter) else "products" query = f"SELECT * FROM {table} WHERE 1=1" params = [] if "plu_code" in arguments: query += " AND plu_code = ?" params.append(arguments["plu_code"]) if "product_name" in arguments: query += " AND product_name LIKE ?" params.append(f"%{arguments['product_name']}%") if "department_id" in arguments: query += " AND department_id = ?" params.append(arguments["department_id"]) if "min_price" in arguments: query += " AND price >= ?" params.append(arguments["min_price"]) if "max_price" in arguments: query += " AND price <= ?" params.append(arguments["max_price"]) if has_tag_filter: query += " AND tags LIKE ?" params.append(f"%{arguments['tag']}%") query += " 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) )]
  • Registration of the 'query_products' tool in the list_tools() function, including name, description, and input schema.
    Tool( name="query_products", description="Query product master data. Search by product code, name, department, price range, or tags.", inputSchema={ "type": "object", "properties": { "plu_code": { "type": "string", "description": "Product PLU code. Optional." }, "product_name": { "type": "string", "description": "Product name to search (partial match). Optional." }, "department_id": { "type": "number", "description": "Department ID. Optional." }, "min_price": { "type": "number", "description": "Minimum price. Optional." }, "max_price": { "type": "number", "description": "Maximum price. Optional." }, "tag": { "type": "string", "description": "Search products by tag (uses extended product table). Optional." }, "include_tags": { "type": "boolean", "description": "Include tag information in results. Default: false." }, "limit": { "type": "number", "description": "Maximum number of results. Default: 100." } } } ),
  • Input schema defining parameters for the 'query_products' tool.
    inputSchema={ "type": "object", "properties": { "plu_code": { "type": "string", "description": "Product PLU code. Optional." }, "product_name": { "type": "string", "description": "Product name to search (partial match). Optional." }, "department_id": { "type": "number", "description": "Department ID. Optional." }, "min_price": { "type": "number", "description": "Minimum price. Optional." }, "max_price": { "type": "number", "description": "Maximum price. Optional." }, "tag": { "type": "string", "description": "Search products by tag (uses extended product table). Optional." }, "include_tags": { "type": "boolean", "description": "Include tag information in results. Default: false." }, "limit": { "type": "number", "description": "Maximum number of results. Default: 100." } } }

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