Skip to main content
Glama

place_order

Verify USDC payment on Base and create an order for hats from The Investor Hat Store using transaction hash and shipping details.

Instructions

Place an order after sending USDC payment on Base. Verifies the on-chain transaction and creates the order.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
quote_idYesQuote ID from get_quote
tx_hashYesTransaction hash of USDC payment on Base
variant_idYesShopify variant ID
shipping_nameYes
shipping_address1Yes
shipping_cityYes
shipping_stateYes
shipping_zipYes
shipping_countryNo

Implementation Reference

  • main.py:354-428 (handler)
    The `place_order` tool is implemented as a FastAPI route that handles order creation, including quote verification, on-chain payment verification, and order placement via Shopify API.
    @app.post("/tools/place_order")
    async def place_order(request: Request):
        body = await request.json()
        quote_id = body.get("quote_id")
        tx_hash = body.get("tx_hash")
        variant_id = body.get("variant_id")
        quantity = body.get("quantity", 1)
        address = body.get("shipping_address", {})
        email = body.get("email", "")
    
        # Validate quote
        quote = _quotes.get(quote_id)
        if not quote:
            raise HTTPException(400, "Quote not found. Call get_quote first.")
        if time.time() > quote["expires_at"]:
            raise HTTPException(400, "Quote expired. Call get_quote again.")
    
        expected_usdc = quote["total_usdc"]
    
        # Verify payment on Base
        verification = await verify_usdc_payment(tx_hash, expected_usdc, PAYMENT_WALLET)
        if not verification["verified"]:
            raise HTTPException(402, f"Payment not verified: {verification['reason']}")
    
        # Build Shopify order (already paid)
        name_parts = address.get("name", "Agent Buyer").split(" ", 1)
        order_payload = {
            "order": {
                "line_items": [{"variant_id": int(variant_id), "quantity": quantity}],
                "financial_status": "paid",
                "fulfillment_status": None,
                "send_receipt": bool(email),
                "send_fulfillment_receipt": True,
                "note": f"Paid via USDC on Base | tx: {tx_hash} | quote: {quote_id}",
                "shipping_address": {
                    "first_name": name_parts[0],
                    "last_name": name_parts[1] if len(name_parts) > 1 else "",
                    "address1": address.get("address1", ""),
                    "address2": address.get("address2", ""),
                    "city": address.get("city", ""),
                    "province": address.get("province", ""),
                    "zip": address.get("zip", ""),
                    "country_code": address.get("country_code", "US"),
                    "phone": address.get("phone", ""),
                },
                "transactions": [
                    {
                        "kind": "sale",
                        "status": "success",
                        "amount": str(expected_usdc),
                        "gateway": "USDC on Base",
                    }
                ],
            }
        }
        if email:
            order_payload["order"]["email"] = email
    
        result = await shopify_post("orders.json", order_payload)
        order = result["order"]
    
        # Remove used quote
        _quotes.pop(quote_id, None)
    
        return {
            "success": True,
            "order_id": str(order["id"]),
            "order_number": order.get("order_number"),
            "status": order.get("fulfillment_status") or "unfulfilled",
            "payment_verified": True,
            "tx_hash": tx_hash,
            "amount_paid_usdc": verification.get("amount_usdc", expected_usdc),
            "shipping_to": address.get("name"),
            "message": "Order created. Printful will produce and ship your item. Use get_order_status to track.",
        }
  • The `place_order` tool input schema is defined within the `MCP_TOOLS` list for protocol communication.
        "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"]
        }
    },
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions verification and creation steps, but lacks critical details: what permissions are needed, whether this is idempotent, what happens if verification fails, error conditions, or rate limits. For a transactional tool with significant consequences, this is inadequate.

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

Conciseness4/5

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

The description is brief (two sentences) and front-loaded with the main purpose. Every sentence contributes meaning, though it could be more structured with clearer separation of prerequisites and outcomes.

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

Completeness2/5

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

For a complex transactional tool with 9 parameters, no annotations, and no output schema, the description is insufficient. It doesn't explain the order creation process, what data is returned, error handling, or the relationship between payment verification and order creation. Critical context for proper tool usage is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is only 33% (3 of 9 parameters have descriptions). The description adds no parameter-specific information beyond what's implied by the tool's purpose. It doesn't explain the relationship between quote_id and variant_id, format requirements for tx_hash, or shipping field constraints. With low schema coverage, the description fails to compensate.

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

Purpose4/5

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

The description clearly states the tool's purpose with specific verbs ('place an order', 'verifies', 'creates') and identifies the resource (order). It distinguishes from siblings like get_order_status or get_quote by focusing on creation rather than retrieval. However, it doesn't explicitly differentiate from all siblings in the list.

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 context ('after sending USDC payment on Base') and references a prerequisite (quote from get_quote), but doesn't explicitly state when to use this tool versus alternatives like search_products or get_product. No explicit exclusions or comparisons with sibling tools are provided.

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