Skip to main content
Glama

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

TableJSON Schema
NameRequiredDescriptionDefault
queryNoSearch 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},
            },
        },
    },
  • 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",
  • 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()
Behavior3/5

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

With no annotations, the description takes full burden. It states return format but lacks details like pagination, ordering, or behavior when query is empty. Adequate but not comprehensive.

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

Conciseness5/5

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

One sentence with no waste. Purpose is front-loaded. Highly concise while covering key action and output.

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

Completeness4/5

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

Given a simple tool with one optional parameter and no output schema, the description is mostly complete. However, it could mention whether all hats are returned on empty query or how results are ordered.

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?

Schema coverage is 100%, so the schema already documents the 'query' parameter. The description adds no extra meaning (e.g., search type, fuzzy matching). Baseline score of 3 is appropriate.

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

Purpose5/5

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

The description clearly states the action ('Search for products'), the specific domain ('hat store'), and the output fields ('names, descriptions, and prices'). It distinguishes from siblings like 'get_product' which implies single product retrieval.

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

Usage Guidelines3/5

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

The description implies usage when searching for hats but provides no explicit guidance on when to use this vs alternatives. No mention of prerequisites or exclusions.

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/masonicGIT/shop-mcp-server'

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