Skip to main content
Glama

get_draft_order

Retrieve a single draft order with full details including status, customer, line items, invoice URL, and resulting order if completed. Use to inspect a draft before updating or completing it.

Instructions

Fetch a single draft order with full details: status, customer, line items (with quantity, title, and unit price), invoice URL, and the resulting real order if it's already been completed. Use to inspect a draft before calling update_draft_order or complete_draft_order. Returns a friendly text summary.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesDraft order GID, e.g. 'gid://shopify/DraftOrder/12345'. Get one from list_draft_orders.

Implementation Reference

  • src/server.ts:62-62 (registration)
    Registration of draft order tools (including 'get_draft_order') on the MCP server in buildContext().
    registerDraftOrderTools(s, shopify);
  • src/server.ts:18-18 (registration)
    Import of the registerDraftOrderTools function from src/tools/draft_orders.ts.
    import { registerDraftOrderTools } from "./tools/draft_orders.js";
  • Handler function for 'get_draft_order' tool — executes the GraphQL query, formats and returns a friendly text summary of the draft order.
    server.tool(
      "get_draft_order",
      "Fetch a single draft order with full details: status, customer, line items (with quantity, title, and unit price), invoice URL, and the resulting real order if it's already been completed. Use to inspect a draft before calling update_draft_order or complete_draft_order. Returns a friendly text summary.",
      getDraftOrderSchema,
      async (args) => {
        const data = await client.graphql<{ draftOrder: DraftOrder | null }>(
          GET_DRAFT_ORDER_QUERY,
          { id: args.id },
        );
        if (!data.draftOrder) {
          return {
            content: [
              { type: "text" as const, text: `Draft order not found: ${args.id}` },
            ],
          };
        }
        const d = data.draftOrder;
        const total = `${d.totalPriceSet.shopMoney.amount} ${d.totalPriceSet.shopMoney.currencyCode}`;
        const customer = d.customer
          ? `${d.customer.displayName ?? ""} <${d.customer.email ?? ""}>`
          : "(no customer)";
        const lineItemLines =
          d.lineItems?.edges.map(({ node }) => {
            const price = node.originalUnitPriceSet
              ? `@ ${node.originalUnitPriceSet.shopMoney.amount} ${node.originalUnitPriceSet.shopMoney.currencyCode}`
              : "";
            return `    - ${node.quantity}× ${node.title} ${price}`.trim();
          }) ?? [];
        return {
          content: [
            {
              type: "text" as const,
              text: [
                `${d.name} [${d.status}]`,
                `  ID: ${d.id}`,
                `  Total: ${total}`,
                `  Customer: ${customer}`,
                d.invoiceUrl ? `  Invoice: ${d.invoiceUrl}` : "",
                d.order ? `  Completed as order: ${d.order.name} (${d.order.id})` : "",
                "  Line items:",
                ...lineItemLines,
              ]
                .filter(Boolean)
                .join("\n"),
            },
          ],
        };
      },
    );
  • Input schema for 'get_draft_order' — accepts a single 'id' string (draft order GID).
    const getDraftOrderSchema = {
      id: z
        .string()
        .describe(
          "Draft order GID, e.g. 'gid://shopify/DraftOrder/12345'. Get one from list_draft_orders.",
        ),
    };
  • GraphQL query GET_DRAFT_ORDER_QUERY used by the handler to fetch draft order details.
    const GET_DRAFT_ORDER_QUERY = /* GraphQL */ `
      query GetDraftOrder($id: ID!) {
        draftOrder(id: $id) {
          id
          name
          status
          invoiceUrl
          totalPriceSet { shopMoney { amount currencyCode } }
          subtotalPriceSet { shopMoney { amount currencyCode } }
          customer { id displayName email }
          lineItems(first: 50) {
            edges {
              node {
                title
                quantity
                originalUnitPriceSet { shopMoney { amount currencyCode } }
                variant { id sku }
              }
            }
          }
          createdAt
          updatedAt
          completedAt
          order { id name }
        }
      }
    `;
Behavior4/5

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

No annotations provided, but description indicates read-only fetch returning detailed information. Lacks explicit mention of no side effects or error handling, but adequate for a get tool.

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?

Two tight sentences: first states purpose and output, second provides usage context. No redundancy or fluff.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Covers return details, parameter source, and usage recommendation. For a simple one-parameter tool, this is fully complete with no gaps.

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

Parameters4/5

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

Schema coverage 100%, description adds value by mentioning source for ID ('Get one from list_draft_orders'), which is helpful for the agent.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Clearly states it fetches a single draft order with full details (status, customer, line items, etc.). Differentiates from siblings by mentioning use before update_draft_order or complete_draft_order.

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

Usage Guidelines5/5

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

Explicitly says to use this tool to inspect a draft before calling update_draft_order or complete_draft_order, providing clear context for when to use it.

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/miller-joe/shopify-mcp'

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