Skip to main content
Glama
amir-bengherbi

Shopify MCP Server

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
NameRequiredDescriptionDefault
orderIdYesID 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.loadOrder
    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);
        }
      }
    );
  • Core handler implementation: loadOrder method performs REST API call to Shopify Admin API to fetch single order by ID
    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;
    }
  • 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 tool
    export 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 request
    private 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(",");
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool retrieves an order but fails to describe key behaviors: whether it's a read-only operation, what happens if the order ID is invalid (e.g., error handling), or any rate limits or authentication requirements. This leaves significant gaps in understanding how the tool behaves in practice.

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

Conciseness5/5

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

The description is extremely concise and front-loaded, consisting of a single, clear sentence that directly states the tool's purpose. There is no wasted verbiage, and it efficiently communicates the core functionality without unnecessary elaboration.

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?

Given the lack of annotations and output schema, the description is incomplete for a retrieval tool. It doesn't explain what is returned (e.g., order details, error formats) or address behavioral aspects like error conditions. While the purpose is clear, the overall context for effective tool use is insufficient.

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

Parameters3/5

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

The schema description coverage is 100%, with the single parameter 'orderId' fully documented in the schema as 'ID of the order to retrieve'. The description adds no additional semantic context beyond implying the parameter is required for retrieval, so it meets the baseline score without compensating for or enhancing the schema information.

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 action ('Get') and resource ('a single order by ID'), making the purpose immediately understandable. It distinguishes this from sibling tools like 'get-orders' (plural) by specifying retrieval of a single order, though it doesn't explicitly contrast with other sibling tools beyond this implicit differentiation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'get-orders' or other retrieval tools. It lacks context about prerequisites, such as needing an existing order ID, and offers no explicit when-not-to-use or alternative recommendations, leaving usage decisions to inference.

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/amir-bengherbi/shopify-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server