get-order
Retrieve specific order details by ID from a Shopify store to view, analyze, or process order information.
Instructions
Get a single order by ID
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| orderId | Yes | ID of the order to retrieve |
Implementation Reference
- src/index.ts:320-341 (registration)Registration of the 'get-order' MCP tool, including input schema (zod) and handler function that delegates to ShopifyClient.loadOrderserver.tool( "get-order", "Get a single order by ID", { orderId: z.string().describe("ID of the order to retrieve"), }, async ({ orderId }) => { const client = new ShopifyClient(); try { const order = await client.loadOrder( SHOPIFY_ACCESS_TOKEN, MYSHOPIFY_DOMAIN, { orderId } ); return { content: [{ type: "text", text: JSON.stringify(order, null, 2) }], }; } catch (error) { return handleError("Failed to retrieve order", error); } } );
- Core handler implementation: loadOrder method performs REST API call to Shopify Admin API to fetch single order by IDasync loadOrder( accessToken: string, shop: string, queryParams: ShopifyLoadOrderQueryParams ): Promise<ShopifyOrder> { const res = await this.shopifyHTTPRequest<{ order: ShopifyOrder }>({ method: "GET", url: `https://${shop}/admin/api/${this.SHOPIFY_API_VERSION}/orders/${queryParams.orderId}.json`, accessToken, params: { fields: this.getOrdersFields(queryParams.fields), }, }); return res.data.order; }
- src/index.ts:323-325 (schema)Input schema for get-order tool using Zod validation{ orderId: z.string().describe("ID of the order to retrieve"), },
- Type definition for the ShopifyOrder returned by the toolexport type ShopifyOrder = { id: string; createdAt: string; currencyCode: string; discountApplications: { nodes: Array<{ code: string | null; value: { amount: string | null; percentage: number | null; }; __typename: string; }>; }; displayFinancialStatus: string | null; name: string; totalPriceSet: { shopMoney: { amount: string; currencyCode: string }; presentmentMoney: { amount: string; currencyCode: string }; }; totalShippingPriceSet: { shopMoney: { amount: string; currencyCode: string }; presentmentMoney: { amount: string; currencyCode: string }; }; customer?: { id: string; email: string; firstName: string; lastName: string; phone: string; }; };
- Helper function getOrdersFields used to specify fields in the order API requestprivate getOrdersFields(fields?: string[]): string { const defaultFields = [ "id", "order_number", "total_price", "discount_codes", "currency", "financial_status", "total_shipping_price_set", "created_at", "customer", "email", ]; if (!fields) return defaultFields.join(","); return [...defaultFields, ...fields].join(","); }