Skip to main content
Glama

Add to cart

add_to_cart

Adds a catalog product to the shopper's cart and returns the updated cart, handling quantity, size, and fabric defaults.

Instructions

Add a catalog product to the user's cart and return the updated cart. good_id comes from a search_products or get_product result; size must be one of get_product's sizes — omit it to use the shopper's saved default from get_user_prefs. Omit fabric to take the first one offered in that size. qty (default 1) is added: if the same product, size and fabric is already in the cart, that line grows (capped at 99) instead of a new line appearing. An unknown good_id or unavailable size returns an error listing the available sizes, and the cart stays unchanged. For an AI-generated print use add_custom_to_cart; to change a line already in the cart, update_cart_item.

Input Schema

NameRequiredDescriptionDefault
qtyNoQuantity to add (default 1, max 99).
sizeNoSize label; must be one of the product's available sizes. Optional when a default size is saved.
fabricNoFabric label from get_product, if the product offers a choice.
good_idYesNumeric product id from search_products/get_product.

Output Schema

NameRequiredDescriptionDefault
errorNoPresent instead of a cart when the call failed (bad index, unavailable size, ...).
itemsNoCart lines in index order — this index is what update_cart_item takes.
currencyNo
subtotalNoSum of price x qty over all lines, USD.
checkout_urlNoCart page URL for the human.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv1.2.0
    • changedInput schema / properties / size / description
      Previous value: -"Size label; must be one of the product's available sizes."New value: +"Size label; must be one of the product's available sizes. Optional when a default size is saved."
    • changedInput schema / required
      Previous value: -[
      -  "good_id",
      -  "size"
      -]New value: +[
      +  "good_id"
      +]
  2. Changed1 schema field changedv1.1.0
    • changedOutput schema / properties / items / description
      Previous value: -"Cart lines in index order — this index is what set_cart_quantity/cart_update/cart_remove take."New value: +"Cart lines in index order — this index is what update_cart_item takes."
  3. First observed

TDQS

A4.9/5.0
Behavior5/5

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

Annotations only declare readOnly=false, idempotent=false, destructive=false; the description adds real behavioral detail beyond that: merge semantics (same product/size/fabric grows the existing line, capped at 99), default resolution from saved prefs, and failure behavior (unknown good_id or unavailable size errors with the available sizes list and leaves the cart unchanged). This is exactly the context annotations can't carry.

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?

Front-loaded with the core action and return, then sources for each field, then the merge rule, then error behavior, then exclusions. Dense but every sentence carries actionable information with no filler.

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?

Output schema and annotations cover return shape and safety; the description fills in the remaining operational gaps (default resolution, merge/cap behavior, error outcomes, sibling routing). Nothing an agent needs to call it correctly is missing.

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 meaning the schema lacks: size omitted resolves to the shopper's saved default from get_user_prefs, and fabric omitted takes the first option offered in the chosen size, plus the qty merge/cap interaction.

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?

States a specific verb and resource ('add a catalog product to the user's cart') plus the return effect ('return the updated cart'). It explicitly distinguishes itself from add_custom_to_cart and update_cart_item, so the agent can route correctly without opening schemas.

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?

Gives explicit prerequisites for each value (good_id from search_products/get_product, size from get_product's sizes) and names the two alternatives by the condition that selects them: add_custom_to_cart for AI-generated prints, update_cart_item for changing an existing line.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.