Skip to main content
Glama

doordash_add_to_cart

Add menu items to your DoorDash cart for restaurants using item names or convenience store products using item IDs, with options for customizing quantities and selections.

Instructions

Add an item to your DoorDash cart. For restaurants, pass item_name. For convenience stores, pass item_id directly.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
store_idYesDoorDash store ID
item_nameYesItem name (used for restaurant menu lookup)
item_idNoItem ID for convenience store items
quantityNoQuantity (default 1)
optionsNoJSON array of selected options. Flat: [{"id":"123","name":"Chicken"}]. Nested (for items like burritos where toppings go inside the filling): [{"id":"123","name":"Chicken","children":[{"id":"456","name":"Brown Rice"},{"id":"789","name":"Sour Cream"}]}]
unit_priceNoPrice in cents (for convenience store items)
cart_idNoCart ID to add to
external_user_idNoExternal user ID for group order guest session (e.g. Slack user ID). Must call doordash_join_group_order first.

Implementation Reference

  • Handler implementation for doordash_add_to_cart, which handles both restaurant and convenience store add-to-cart logic.
    server.registerTool(
      "doordash_add_to_cart",
      {
        description:
          "Add an item to your DoorDash cart. For restaurants, pass item_name. For convenience stores, pass item_id directly.",
        inputSchema: {
          store_id: z.string().describe("DoorDash store ID"),
          item_name: z
            .string()
            .describe("Item name (used for restaurant menu lookup)"),
          item_id: z
            .string()
            .optional()
            .describe("Item ID for convenience store items"),
          quantity: z
            .number()
            .optional()
            .default(1)
            .describe("Quantity (default 1)"),
          options: z
            .string()
            .optional()
            .describe(
              'JSON array of selected options. Flat: [{"id":"123","name":"Chicken"}]. Nested (for items like burritos where toppings go inside the filling): [{"id":"123","name":"Chicken","children":[{"id":"456","name":"Brown Rice"},{"id":"789","name":"Sour Cream"}]}]',
            ),
          unit_price: z
            .number()
            .optional()
            .describe("Price in cents (for convenience store items)"),
          cart_id: z.string().optional().describe("Cart ID to add to"),
          external_user_id: z
            .string()
            .optional()
            .describe(
              "External user ID for group order guest session (e.g. Slack user ID). Must call doordash_join_group_order first.",
            ),
        },
      },
      ({
        store_id,
        item_name,
        item_id,
        quantity,
        options,
        unit_price,
        cart_id,
        external_user_id,
      }) =>
        wrap(async () => {
          const guest = external_user_id
            ? api.guests.getSession(external_user_id)
            : undefined;
          if (external_user_id && !guest) {
            return err(
              `No guest session for user "${external_user_id}". Call doordash_join_group_order first.`,
            );
          }
          const cartApi = guest?.cart ?? api.cart;
          let resolvedId = item_id ?? "";
          let resolvedName = item_name;
          let resolvedPrice = unit_price ?? 0;
          let menuId = "";
          let nestedOpts = "[]";
    
          if (!resolvedId) {
            // Restaurant flow: look up item from menu
            const menu = await api.menu.getStoreMenu(store_id);
            let found: any = null;
            const nameLower = item_name.toLowerCase();
    
            // Prefer exact match, then substring match
            for (const cat of menu.categories) {
              for (const item of cat.items) {
                if (item.name.toLowerCase() === nameLower) {
                  found = item;
                  break;
                }
              }
              if (found) break;
            }
            if (!found) {
              for (const cat of menu.categories) {
                for (const item of cat.items) {
                  if (item.name.toLowerCase().includes(nameLower)) {
                    found = item;
                    break;
                  }
                }
                if (found) break;
              }
            }
    
            if (!found) {
              const names = menu.categories
                .flatMap((c) => c.items.map((i) => i.name))
                .slice(0, 10);
              return err(
                `Item "${item_name}" not found. Try: ${names.join(", ")}`,
              );
            }
    
            resolvedId = found.id;
            resolvedName = found.name;
            resolvedPrice = found.quickAddPrice;
            menuId = menu.menuId;
            nestedOpts = found.quickAddNestedOptions;
          }
    
          if (options) {
            nestedOpts = JSON.stringify(
              JSON.parse(options).map((o: any) => buildNestedOption(o)),
            );
          }
    
          const result = await cartApi.addToCart({
            storeId: store_id,
            itemId: resolvedId,
            itemName: resolvedName,
            menuId,
            quantity,
            nestedOptions: nestedOpts,
            unitPrice: resolvedPrice,
            cartId: cart_id,
            isGroupGuest: !!guest,
          });
    
          const subtotal = `$${(result.subtotal / 100).toFixed(2)}`;
          const qtyNote =
            result.itemQuantity > quantity
              ? ` (cart now has ${result.itemQuantity}x total)`
              : "";
          return ok(
            `Added ${quantity}x **${resolvedName}**${qtyNote}. Subtotal: ${subtotal}. Cart ID: ${result.cartId}`,
          );
        }),
    );
Behavior2/5

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

With no annotations provided, the description carries full burden but only discloses the basic operation. It fails to explain cart creation behavior (cart_id is optional in schema), group order workflows, idempotency, or error conditions.

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 two-sentence structure is perfectly efficient—first stating purpose, second providing the critical restaurant/convenience store distinction. No redundancy or filler content.

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

Completeness3/5

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

For an 8-parameter tool with complex JSON options structures and group order support (external_user_id), the description covers the store-type dichotomy but omits group order usage patterns and cart lifecycle management details.

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?

Despite 100% schema coverage, the description adds crucial semantic context about the mutually exclusive usage patterns for item_name vs item_id based on store type. This conditional logic is not obvious from the schema alone.

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 core action ('Add an item') and resource ('DoorDash cart'). It adds domain-specific context distinguishing restaurant vs convenience store flows, though it doesn't explicitly differentiate from sibling tools like 'doordash_modify_cart'.

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

Usage Guidelines3/5

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

It provides conditional parameter guidance (item_name for restaurants, item_id for convenience stores), which helps with correct invocation. However, it lacks guidance on when to use this tool versus 'doordash_modify_cart' or prerequisites like requiring an active cart session.

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/ashah360/doordash-mcp'

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