get-order
Retrieve a specific Shopify order by its ID to view details, track status, or process updates within 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 input schema (orderId: string) and inline handler that uses ShopifyClient.loadOrder to fetch and return the order as JSON.server.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)The handler function executes the tool logic: instantiates ShopifyClient, calls loadOrder with access token, shop domain, and orderId, returns formatted JSON response or error.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:351-353 (schema)Zod input schema for the tool: requires orderId as string.{ orderId: z.string().describe("ID of the order to retrieve"), },
- Core helper method loadOrder that performs a GET request to Shopify Admin API to retrieve the specific order by ID, optionally specifying fields.async 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; }