get_order_status
Check the current delivery status of an order placed through The Investor Hat Store using the order ID returned after purchase.
Instructions
Check the status of a placed order by order ID.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| order_id | Yes | Order ID returned from place_order |
Implementation Reference
- main.py:432-463 (handler)The async handler function for get_order_status. It takes an order_id from the request body, fetches the order from Shopify via shopify_get, then queries Printful for tracking/shipping info, and returns order details including printful status and tracking data.
@app.post("/tools/get_order_status") async def get_order_status(request: Request): body = await request.json() order_id = body.get("order_id") data = await shopify_get(f"orders/{order_id}.json") order = data["order"] # Try Printful printful_data = None async with httpx.AsyncClient(timeout=10) as client: pf = await client.get(f"{PRINTFUL_BASE}/orders/@{order_id}", headers=PRINTFUL_HEADERS) if pf.status_code == 200: pf_result = pf.json().get("result", {}) shipments = pf_result.get("shipments", []) printful_data = { "status": pf_result.get("status"), "tracking": { "carrier": shipments[0].get("carrier") if shipments else None, "tracking_number": shipments[0].get("tracking_number") if shipments else None, "tracking_url": shipments[0].get("tracking_url") if shipments else None, } if shipments else None, } return { "order_id": str(order["id"]), "order_number": order.get("order_number"), "financial_status": order.get("financial_status"), "fulfillment_status": order.get("fulfillment_status") or "unfulfilled", "created_at": order.get("created_at"), "printful": printful_data, } - main.py:154-165 (schema)MCP manifest registration of get_order_status tool with its input schema requiring order_id (string).
{ "name": "get_order_status", "description": "Get order status and Printful tracking info by order ID.", "price": None, "inputSchema": { "type": "object", "properties": { "order_id": {"type": "string"}, }, "required": ["order_id"], }, }, - main.py:526-537 (registration)Registration in the MCP Tools list (used by the /mcp protocol endpoint) for get_order_status with input schema requiring order_id.
{ "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:567-580 (registration)Routing registration in the MCP tools/call handler that maps the tool name 'get_order_status' to the REST endpoint '/tools/get_order_status'.
elif method == "tools/call": tool_name = body.get("params", {}).get("name", "") tool_args = body.get("params", {}).get("arguments", {}) # Route to existing tool handlers from fastapi.testclient import TestClient # Forward to the REST 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-177 (helper)The shopify_get helper function used by the handler to fetch order data from Shopify 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()