get-order
Retrieve a specific Shopify order by its unique ID using the 'get-order' tool. Simplify order management and access detailed order information directly from the Shopify Update MCP Server.
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:348-369 (registration)Registration of the 'get-order' MCP tool, including inline 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); } } );
- src/index.ts:354-368 (handler)Handler function for the 'get-order' tool: creates ShopifyClient instance, calls loadOrder with credentials and orderId, returns JSON stringified order or handles errorasync ({ 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); } }
- src/index.ts:351-353 (schema)Zod schema for 'get-order' tool input: requires orderId as string{ orderId: z.string().describe("ID of the order to retrieve"), },
- Core implementation of loading a single order via Shopify REST API GET request to /orders/{orderId}.json, using shopifyHTTPRequest helperasync 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; }
- TypeScript type definition for loadOrder query parameters used by the tool's underlying helperexport type ShopifyLoadOrderQueryParams = { orderId: string; fields?: string[]; };