Skip to main content
Glama

list_draft_orders

Retrieve a paginated list of draft orders (quotes/carts) sorted by most recent update. Filter by status, customer, tag, or update time. Returns name, status, total price, customer name, and conversion status for each draft order.

Instructions

List draft orders (carts/quotes that haven't yet been completed into real orders), most recently updated first. Returns each draft's name (e.g. 'D1023'), status (OPEN/COMPLETED/INVOICE_SENT), total price, customer name, and whether it's already been converted to an order. Supports Shopify's draft-order query syntax for filtering by status, customer, tag, or update time. Cursor-paginated.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
firstNoPage size (1-100).
queryNoShopify draft order query syntax. Examples: 'status:OPEN' (not yet completed), 'status:COMPLETED', 'customer_id:1234567890', 'tag:wholesale', 'updated_at:>=2026-01-01'.
afterNoCursor from the previous page's pageInfo. Omit on the first call.

Implementation Reference

  • The handler function for the 'list_draft_orders' tool. Makes a GraphQL call using LIST_DRAFT_ORDERS_QUERY with pagination args (first, after, query), maps results to a text summary, and returns it as MCP content.
      async (args) => {
        const data = await client.graphql<{
          draftOrders: Connection<DraftOrder>;
        }>(LIST_DRAFT_ORDERS_QUERY, {
          first: args.first,
          after: args.after,
          query: args.query,
        });
        const lines = [
          `Found ${data.draftOrders.edges.length} draft order(s):`,
          ...data.draftOrders.edges.map(({ node }) => {
            const total = `${node.totalPriceSet.shopMoney.amount} ${node.totalPriceSet.shopMoney.currencyCode}`;
            const customer = node.customer?.displayName ?? "(no customer)";
            const completed = node.order
              ? ` → order ${node.order.name}`
              : "";
            return `  ${node.name} [${node.status}] ${total} — ${customer}${completed} — ${node.id}`;
          }),
        ];
        return { content: [{ type: "text" as const, text: lines.join("\n") }] };
      },
    );
  • Zod schema for list_draft_orders input: 'first' (page size 1-100, default 20), 'query' (optional Shopify query syntax), and 'after' (optional cursor for pagination).
    const listDraftOrdersSchema = {
      first: z
        .number()
        .int()
        .min(1)
        .max(100)
        .default(20)
        .describe("Page size (1-100)."),
      query: z
        .string()
        .optional()
        .describe(
          "Shopify draft order query syntax. Examples: 'status:OPEN' (not yet completed), 'status:COMPLETED', 'customer_id:1234567890', 'tag:wholesale', 'updated_at:>=2026-01-01'.",
        ),
      after: z
        .string()
        .optional()
        .describe("Cursor from the previous page's pageInfo. Omit on the first call."),
    };
  • Registration of 'list_draft_orders' via server.tool() in the registerDraftOrderTools function, with the name, description, schema, and handler.
    server.tool(
      "list_draft_orders",
      "List draft orders (carts/quotes that haven't yet been completed into real orders), most recently updated first. Returns each draft's name (e.g. 'D1023'), status (OPEN/COMPLETED/INVOICE_SENT), total price, customer name, and whether it's already been converted to an order. Supports Shopify's draft-order query syntax for filtering by status, customer, tag, or update time. Cursor-paginated.",
      listDraftOrdersSchema,
      async (args) => {
        const data = await client.graphql<{
          draftOrders: Connection<DraftOrder>;
        }>(LIST_DRAFT_ORDERS_QUERY, {
          first: args.first,
          after: args.after,
          query: args.query,
        });
        const lines = [
          `Found ${data.draftOrders.edges.length} draft order(s):`,
          ...data.draftOrders.edges.map(({ node }) => {
            const total = `${node.totalPriceSet.shopMoney.amount} ${node.totalPriceSet.shopMoney.currencyCode}`;
            const customer = node.customer?.displayName ?? "(no customer)";
            const completed = node.order
              ? ` → order ${node.order.name}`
              : "";
            return `  ${node.name} [${node.status}] ${total} — ${customer}${completed} — ${node.id}`;
          }),
        ];
        return { content: [{ type: "text" as const, text: lines.join("\n") }] };
      },
    );
  • src/server.ts:62-62 (registration)
    The top-level call to registerDraftOrderTools from the server setup, which registers all draft order tools including list_draft_orders.
    registerDraftOrderTools(s, shopify);
  • The GraphQL query used by list_draft_orders to fetch draft orders with pagination, sorted by UPDATED_AT descending.
    const LIST_DRAFT_ORDERS_QUERY = /* GraphQL */ `
      query ListDraftOrders($first: Int!, $after: String, $query: String) {
        draftOrders(first: $first, after: $after, query: $query, sortKey: UPDATED_AT, reverse: true) {
          edges {
            cursor
            node {
              id
              name
              status
              totalPriceSet { shopMoney { amount currencyCode } }
              customer { id displayName email }
              createdAt
              updatedAt
              completedAt
              order { id name }
            }
          }
          pageInfo { hasNextPage hasPreviousPage startCursor endCursor }
        }
      }
    `;
Behavior3/5

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

No annotations are provided, so the description must fully disclose behavioral traits. It mentions sorting, filtering, pagination, and return fields. However, it does not explicitly state that the operation is read-only (though implied) or mention any rate limits or side effects. Adequate but not exhaustive.

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 sentences: first defines purpose and output, second explains filtering and pagination. Every sentence earns its place. Information is front-loaded. No superfluous words.

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?

Given no output schema, the description sufficiently explains return fields (name, status, total price, customer name, conversion status). It covers filtering, pagination, and ordering. No missing context for a list tool of this complexity.

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 is 100%, so baseline is 3. The description adds value by explaining the query parameter format with examples (e.g., 'status:OPEN', 'customer_id:1234567890') and clarifying the 'after' parameter as a cursor from the previous page. This enriches understanding beyond the schema.

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?

The description clearly identifies the action ('List draft orders'), the resource ('draft orders, i.e., carts/quotes that haven't yet been completed into real orders'), and provides specific return fields. It distinguishes itself from sibling tools like get_draft_order (single) and complete_draft_order (action) by focusing on listing.

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

Usage Guidelines4/5

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

The description states the ordering ('most recently updated first'), supports filtering with query syntax and examples, and mentions cursor-based pagination. It does not explicitly contrast with alternatives, but the purpose is self-evident for listing vs. other operations.

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