search_products
Search the hat store catalog to find hats by name, description, and price. Use queries like 'accredited investor hat' to locate specific items available for purchase.
Instructions
Search for products in the hat store. Returns available hats with names, descriptions, and prices.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | No | Search query (e.g. 'accredited investor hat') |
Implementation Reference
- main.py:237-272 (handler)The main handler for the search_products tool. It's a FastAPI POST endpoint at /tools/search_products that accepts 'query' and 'limit' parameters, calls Shopify's products API with a title filter, and returns a simplified product list with id, title, handle, url, variants (id, title, price_usd, price_usdc, sku), and first image.
@app.post("/tools/search_products") async def search_products(request: Request): body = await request.json() query = body.get("query", "") limit = body.get("limit", 10) # Use full-text search if available, fall back to title filter params = {"limit": limit, "status": "active"} if query: params["title"] = query data = await shopify_get("products.json", params) products = data.get("products", []) return { "products": [ { "id": str(p["id"]), "title": p["title"], "handle": p["handle"], "url": f"https://shop.masonborda.com/products/{p['handle']}", "variants": [ { "id": str(v["id"]), "title": v["title"], "price_usd": float(v["price"]), "price_usdc": float(v["price"]), # 1:1 peg "sku": v.get("sku", ""), } for v in p.get("variants", []) ], "images": [img["src"] for img in p.get("images", [])[:1]], } for p in products ], "count": len(products), } - main.py:66-76 (schema)Input schema for search_products in the MCP manifest endpoint (/.well-known/mcp.json). Defines 'query' (string) and 'limit' (integer, default 10) as input properties.
"name": "search_products", "description": "Search products by keyword. Returns id, title, price in USD, variants.", "price": None, "inputSchema": { "type": "object", "properties": { "query": {"type": "string"}, "limit": {"type": "integer", "default": 10}, }, }, }, - main.py:469-478 (schema)Second input schema for search_products in the MCP protocol endpoint (/mcp tools/list). Defines 'query' (string) as input property.
"name": "search_products", "description": "Search for products in the hat store. Returns available hats with names, descriptions, and prices.", "inputSchema": { "type": "object", "properties": { "query": {"type": "string", "description": "Search query (e.g. 'accredited investor hat')"} }, "required": [] } }, - main.py:574-575 (registration)Registration of search_products in the MCP tools/call routing map, mapping it to the /tools/search_products REST endpoint.
rest_map = { "search_products": "/tools/search_products", - main.py:172-176 (helper)The shopify_get helper function used by search_products to make authenticated GET requests to the Shopify Admin API.
async def shopify_get(path: str, params: dict = {}): async with httpx.AsyncClient(timeout=15) as client: r = await client.get(f"{SHOPIFY_BASE}/{path}", headers=SHOPIFY_HEADERS, params=params) r.raise_for_status() return r.json()