get_product
Retrieve complete product information by providing a variant ID, enabling autonomous purchasing decisions with real-time details.
Instructions
Get full details for a specific product by its Shopify variant ID.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| variant_id | Yes | Shopify variant ID of the product |
Implementation Reference
- main.py:275-302 (handler)The actual handler for the 'get_product' tool. It parses the request for product_id, calls Shopify API to fetch the product, and returns structured data including id, title, description, handle, URL, variants, and images.
# --- Tool: get_product --- @app.post("/tools/get_product") async def get_product(request: Request): body = await request.json() product_id = body.get("product_id") data = await shopify_get(f"products/{product_id}.json") p = data["product"] return { "id": str(p["id"]), "title": p["title"], "description": p.get("body_html", "").replace("<p>", "").replace("</p>", "\n").strip(), "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"]), "sku": v.get("sku", ""), "available": v.get("inventory_quantity", 1) > 0, } for v in p.get("variants", []) ], "images": [img["src"] for img in p.get("images", [])], } - main.py:78-88 (registration)Registration of 'get_product' in the MCP manifest (/.well-known/mcp.json) with input schema requiring product_id (string).
"name": "get_product", "description": "Get full details for a product including all variants and images.", "price": None, "inputSchema": { "type": "object", "properties": { "product_id": {"type": "string"}, }, "required": ["product_id"], }, }, - main.py:480-489 (registration)Alternative/second registration of 'get_product' in another MCP tool listing, with input schema expecting variant_id (integer).
"name": "get_product", "description": "Get full details for a specific product by its Shopify variant ID.", "inputSchema": { "type": "object", "properties": { "variant_id": {"type": "integer", "description": "Shopify variant ID of the product"} }, "required": ["variant_id"] } }, - main.py:574-580 (registration)Registration in the REST route mapping that forwards 'get_product' tool calls to the '/tools/get_product' endpoint.
rest_map = { "search_products": "/tools/search_products", "get_product": "/tools/get_product", "get_quote": "/tools/get_quote", "place_order": "/tools/place_order", "get_order_status": "/tools/get_order_status", } - main.py:172-176 (helper)Helper function 'shopify_get' used by the handler 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()