Skip to main content
Glama

update_cart

Modify item quantities in your shopping cart or remove products entirely by setting quantity to zero.

Instructions

Update the quantity of an item in the cart or remove it (set quantity to 0)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
productIdYesProduct ID to update
quantityYesNew quantity (set to 0 to remove from cart)

Implementation Reference

  • The handler for the 'update_cart' tool. It parses input parameters using UpdateCartSchema, calls drizly.updateCart() to perform the update, and returns a message indicating whether the product was updated or removed from the cart.
    case "update_cart": {
      const params = UpdateCartSchema.parse(args);
      const cart = drizly.updateCart(params.productId, params.quantity);
    
      const message =
        params.quantity === 0
          ? `Removed product ${params.productId} from cart`
          : `Updated product ${params.productId} quantity to ${params.quantity}`;
    
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify({ message, cart }, null, 2),
          },
        ],
      };
    }
  • Zod schema definition for the update_cart tool input parameters. Validates productId (string) and quantity (non-negative integer).
    const UpdateCartSchema = z.object({
      productId: z.string().describe("Product ID to update"),
      quantity: z.number().int().min(0).describe("New quantity (0 to remove)"),
    });
  • src/index.ts:198-215 (registration)
    Registration of the 'update_cart' tool with its name, description, and JSON Schema input specification defining productId and quantity properties.
    {
      name: "update_cart",
      description: "Update the quantity of an item in the cart or remove it (set quantity to 0)",
      inputSchema: {
        type: "object",
        properties: {
          productId: {
            type: "string",
            description: "Product ID to update",
          },
          quantity: {
            type: "number",
            description: "New quantity (set to 0 to remove from cart)",
          },
        },
        required: ["productId", "quantity"],
      },
    },
  • The updateCart method in the Drizly class that performs the actual cart update logic. Removes item if quantity is 0, otherwise updates the quantity and recalculates cart totals.
    updateCart(productId: string, quantity: number): DrizlyCart {
      if (quantity <= 0) {
        this.cart.items = this.cart.items.filter((i) => i.productId !== productId);
      } else {
        const item = this.cart.items.find((i) => i.productId === productId);
        if (item) {
          item.quantity = quantity;
        }
      }
    
      this.recalculateCart();
      return this.cart;
    }
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 updates or removes items, implying mutation, but does not cover permissions, side effects (e.g., cart totals update), error handling, or response format. This is inadequate for a mutation tool without annotation support.

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 a single, efficient sentence that directly states the tool's function without redundancy. It is front-loaded with the core action and includes necessary detail (quantity to 0 for removal) in a compact form.

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 mutation nature, lack of annotations, and no output schema, the description is insufficient. It does not explain what happens on success/failure, return values, or interactions with other cart operations, leaving significant gaps for agent understanding.

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%, so parameters are fully documented in the schema. The description adds minimal value by clarifying that quantity 0 means removal, which is already implied in the schema's description for 'quantity'. This meets the baseline for high schema coverage.

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 ('update the quantity of an item in the cart or remove it') and specifies the resource ('cart'), making the purpose unambiguous. However, it does not explicitly differentiate from sibling tools like 'add_to_cart' or 'get_cart', which would be needed for a score of 5.

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 'add_to_cart' (for initial addition) or 'get_cart' (for viewing). It mentions setting quantity to 0 for removal, but lacks context on prerequisites, error conditions, or typical use cases.

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/markswendsen-code/mcp-drizly'

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