get_quote
Calculate shipping costs and USDC payment amount for a product, returning the wallet address to send payment.
Instructions
Get a shipping quote and USDC payment amount for a product. Returns the wallet address to send payment to.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| variant_id | Yes | Shopify variant ID | |
| shipping_name | Yes | Recipient full name | |
| shipping_address1 | Yes | Street address | |
| shipping_city | Yes | City | |
| shipping_state | Yes | State (2-letter code) | |
| shipping_zip | Yes | ZIP code | |
| shipping_country | No | Country code (default: US) |
Implementation Reference
- main.py:305-350 (handler)The main handler for the get_quote tool. It fetches the variant price from Shopify, calculates shipping (US=$5, international=$15), stores the quote in an in-memory dict with a 10-minute expiry, and returns the total USDC amount, payment wallet address, network, token, and instructions.
# --- Tool: get_quote --- @app.post("/tools/get_quote") async def get_quote(request: Request): body = await request.json() variant_id = body.get("variant_id") quantity = body.get("quantity", 1) address = body.get("shipping_address", {}) # Get variant price from Shopify data = await shopify_get(f"variants/{variant_id}.json") variant = data["variant"] unit_price = float(variant["price"]) subtotal = unit_price * quantity # Standard shipping estimate (US $5, international $15) country = address.get("country_code", "US") shipping = 5.0 if country == "US" else 15.0 total_usdc = round(subtotal + shipping, 2) quote_id = make_quote_id(variant_id, quantity) _quotes[quote_id] = { "variant_id": variant_id, "quantity": quantity, "total_usdc": total_usdc, "shipping_address": address, "expires_at": time.time() + 600, # 10 min "product_title": variant.get("title", ""), } return { "quote_id": quote_id, "product": variant.get("title", ""), "quantity": quantity, "subtotal_usdc": subtotal, "shipping_usdc": shipping, "total_usdc": total_usdc, "payment_wallet": PAYMENT_WALLET, "network": "base", "token": "USDC", "token_contract": USDC_CONTRACT, "instructions": ( f"Send exactly {total_usdc} USDC on Base network to {PAYMENT_WALLET}, " f"then call place_order with the transaction hash and this quote_id." ), "expires_in": "10 minutes", } - main.py:89-116 (schema)Input schema for get_quote in the MCP manifest. Requires variant_id (string), optional quantity (integer, default 1), and shipping_address object (name, address1, city, province, zip, country_code).
{ "name": "get_quote", "description": ( "Get a USDC price quote for a product + shipping. " "Returns total USDC amount to send, payment wallet address, and a quote_id. " "Quote is valid for 10 minutes." ), "price": None, "inputSchema": { "type": "object", "properties": { "variant_id": {"type": "string"}, "quantity": {"type": "integer", "default": 1}, "shipping_address": { "type": "object", "properties": { "name": {"type": "string"}, "address1": {"type": "string"}, "city": {"type": "string"}, "province": {"type": "string", "description": "State/province code e.g. CA"}, "zip": {"type": "string"}, "country_code": {"type": "string", "description": "ISO 2-letter e.g. US"}, }, "required": ["name", "address1", "city", "zip", "country_code"], }, }, "required": ["variant_id", "shipping_address"], }, - main.py:490-537 (registration)Registration of get_quote in the MCP_TOOLS list for the /mcp protocol endpoint. Maps the tool name to its description and flat input schema (variant_id, shipping_name, shipping_address1, etc.).
{ "name": "get_quote", "description": "Get a shipping quote and USDC payment amount for a product. Returns the wallet address to send payment to.", "inputSchema": { "type": "object", "properties": { "variant_id": {"type": "integer", "description": "Shopify variant ID"}, "shipping_name": {"type": "string", "description": "Recipient full name"}, "shipping_address1": {"type": "string", "description": "Street address"}, "shipping_city": {"type": "string", "description": "City"}, "shipping_state": {"type": "string", "description": "State (2-letter code)"}, "shipping_zip": {"type": "string", "description": "ZIP code"}, "shipping_country": {"type": "string", "description": "Country code (default: US)"} }, "required": ["variant_id", "shipping_name", "shipping_address1", "shipping_city", "shipping_state", "shipping_zip"] } }, { "name": "place_order", "description": "Place an order after sending USDC payment on Base. Verifies the on-chain transaction and creates the order.", "inputSchema": { "type": "object", "properties": { "quote_id": {"type": "string", "description": "Quote ID from get_quote"}, "tx_hash": {"type": "string", "description": "Transaction hash of USDC payment on Base"}, "variant_id": {"type": "integer", "description": "Shopify variant ID"}, "shipping_name": {"type": "string"}, "shipping_address1": {"type": "string"}, "shipping_city": {"type": "string"}, "shipping_state": {"type": "string"}, "shipping_zip": {"type": "string"}, "shipping_country": {"type": "string"} }, "required": ["quote_id", "tx_hash", "variant_id", "shipping_name", "shipping_address1", "shipping_city", "shipping_state", "shipping_zip"] } }, { "name": "get_order_status", "description": "Check the status of a placed order by order ID.", "inputSchema": { "type": "object", "properties": { "order_id": {"type": "string", "description": "Order ID returned from place_order"} }, "required": ["order_id"] } } ] - main.py:574-580 (registration)Routing registration mapping the tool name 'get_quote' to the REST endpoint '/tools/get_quote' in the MCP protocol handler.
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:229-233 (helper)In-memory quote store (_quotes dict) and make_quote_id helper used by get_quote to generate unique quote IDs.
# In-memory quote store (replace with Redis in production) _quotes = {} def make_quote_id(variant_id: str, quantity: int) -> str: return f"q_{variant_id}_{quantity}_{int(time.time())}"