Skip to main content
Glama
smithery-ai

Shopify Update MCP Server

by smithery-ai

create-draft-order

Create draft orders in Shopify by specifying line items, customer email, and shipping address details to prepare orders for review and processing.

Instructions

Create a draft order

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
lineItemsYesLine items to add to the order
emailYesCustomer email
shippingAddressYesShipping address details
noteNoOptional note for the order

Implementation Reference

  • src/index.ts:432-482 (registration)
    MCP tool registration including input schema (Zod) and handler function that delegates to ShopifyClient.createDraftOrder
    server.tool(
      "create-draft-order",
      "Create a draft order",
      {
        lineItems: z
          .array(
            z.object({
              variantId: z.string(),
              quantity: z.number(),
            })
          )
          .describe("Line items to add to the order"),
        email: z.string().email().describe("Customer email"),
        shippingAddress: z
          .object({
            address1: z.string(),
            city: z.string(),
            province: z.string(),
            country: z.string(),
            zip: z.string(),
            firstName: z.string(),
            lastName: z.string(),
            countryCode: z.string(),
          })
          .describe("Shipping address details"),
        note: z.string().optional().describe("Optional note for the order"),
      },
      async ({ lineItems, email, shippingAddress, note }) => {
        const client = new ShopifyClient();
        try {
          const draftOrderData: CreateDraftOrderPayload = {
            lineItems,
            email,
            shippingAddress,
            billingAddress: shippingAddress, // Using same address for billing
            tags: "draft",
            note: note || "",
          };
          const draftOrder = await client.createDraftOrder(
            SHOPIFY_ACCESS_TOKEN,
            MYSHOPIFY_DOMAIN,
            draftOrderData
          );
          return {
            content: [{ type: "text", text: JSON.stringify(draftOrder, null, 2) }],
          };
        } catch (error) {
          return handleError("Failed to create draft order", error);
        }
      }
    );
  • Core handler implementation performing GraphQL mutation to create draft order in Shopify
    async createDraftOrder(
      accessToken: string,
      myshopifyDomain: string,
      draftOrderData: CreateDraftOrderPayload
    ): Promise<DraftOrderResponse> {
      const graphqlQuery = gql`
        mutation draftOrderCreate($input: DraftOrderInput!) {
          draftOrderCreate(input: $input) {
            draftOrder {
              id
              name
            }
            userErrors {
              field
              message
            }
          }
        }
      `;
    
      const res = await this.shopifyGraphqlRequest<{
        data: {
          draftOrderCreate: {
            draftOrder: {
              id: string;
              name: string;
            };
            userErrors: Array<{
              field: string[];
              message: string;
            }>;
          };
        };
      }>({
        url: `https://${myshopifyDomain}/admin/api/${this.SHOPIFY_API_VERSION}/graphql.json`,
        accessToken,
        query: graphqlQuery,
        variables: {
          input: draftOrderData,
        },
      });
    
      const draftOrder = res.data.data.draftOrderCreate.draftOrder;
      const userErrors = res.data.data.draftOrderCreate.userErrors;
    
      if (userErrors.length > 0) {
        throw getGraphqlShopifyUserError(userErrors, {
          myshopifyDomain,
          draftOrderData,
        });
      }
    
      return {
        draftOrderId: draftOrder.id,
        draftOrderName: draftOrder.name,
      };
    }
  • TypeScript type definition for the draft order payload used in the tool
    export type CreateDraftOrderPayload = {
      lineItems: Array<{
        variantId: string;
        quantity: number;
        appliedDiscount?: {
          title: string;
          value: number;
          valueType: "FIXED_AMOUNT" | "PERCENTAGE";
        };
      }>;
      shippingAddress: {
        address1: string;
        address2?: string;
        countryCode: string;
        firstName: string;
        lastName: string;
        zip: string;
        city: string;
        country: string;
        province?: string;
        provinceCode?: string;
        phone?: string;
      };
      billingAddress: {
        address1: string;
        address2?: string;
        countryCode: string;
        firstName: string;
        lastName: string;
        zip: string;
        city: string;
        country: string;
        province?: string;
        provinceCode?: string;
        phone?: string;
      };
      email: string;
      tags: string;
      note: string;
    };
  • Interface definition for the createDraftOrder method in ShopifyClientPort
    createDraftOrder(
      accessToken: string,
      shop: string,
      draftOrderData: CreateDraftOrderPayload,
      idempotencyKey: string
    ): Promise<DraftOrderResponse>;
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. 'Create a draft order' implies a write operation, but it doesn't specify if this requires authentication, what permissions are needed, whether it's idempotent, or what happens on failure. For a mutation tool with zero annotation coverage, this is a significant gap in safety and operational context.

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

Conciseness4/5

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

The description is a single, efficient sentence with no wasted words. It's front-loaded with the core action, making it easy to parse. However, it's overly concise to the point of under-specification, lacking necessary details for a mutation tool, which slightly reduces its effectiveness despite the clean structure.

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 tool's complexity (4 parameters with nested objects, no output schema, and no annotations), the description is incomplete. It doesn't explain what a draft order is, how it differs from a completed order, what the return value includes, or any error conditions. For a creation tool with significant input requirements, more context is needed to guide effective use.

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 input schema has 100% description coverage, with each parameter clearly documented (e.g., 'lineItems' as 'Line items to add to the order'). The description adds no additional meaning beyond the schema, such as explaining relationships between parameters or usage examples. Given the high schema coverage, a baseline score of 3 is appropriate as the schema does the heavy lifting.

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

Purpose3/5

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

The description 'Create a draft order' states the basic action (create) and resource (draft order), which is clear but vague. It doesn't specify what a draft order entails or how it differs from other order-related tools, though sibling tools like 'complete-draft-order' and 'get-order' exist. The purpose is understandable but lacks specificity about the scope or nature of the creation.

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. With sibling tools like 'complete-draft-order' and 'get-order', it's unclear if this is for initial order setup, if it should precede other actions, or what prerequisites exist. There's no mention of context, exclusions, or recommended workflows, leaving usage ambiguous.

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/smithery-ai/shopify-mcp-server-main-1'

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