Skip to main content
Glama

Add to cart

add_to_cart

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. A matching set's good_id (get_product returns its parts) adds two lines per unit of qty, top then bottom, in one size and one fabric — up to 10 sets per call; each line carries set and keeps qty 1 (another costume = add the set again), each can be resized on its own with update_cart_item, and removing one leaves the other as an ordinary item. A set with a part off sale returns 'this set is not available right now' and adds nothing. For an AI-generated print use add_custom_to_cart; to change a line already in the cart, update_cart_item.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "good_id": "<good_id>"
    },
    "name": "add_to_cart"
  }
}

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. Changed1 schema field changed
    • addedOutput schema / properties / items / items / properties / set
      Added value: +{
      +  "description": "Only on a line of a matching set: the pair it belongs to (both lines share key) and which part it is.",
      +  "properties": {
      +    "key": {
      +      "type": "string"
      +    },
      +    "role": {
      +      "description": "top or bottom.",
      +      "type": "string"
      +    },
      +    "title": {
      +      "type": "string"
      +    }
      +  },
      +  "type": "object"
      +}
  2. Changed2 schema fields changed
    • 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"
      +]
  3. Changed1 schema field changed
    • 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."
  4. Changed5 schema fields changed
    • addedInput schema / properties / fabric / description
      Added value: +"Fabric label from get_product, if the product offers a choice."
    • addedInput schema / properties / good_id / description
      Added value: +"Numeric product id from search_products/get_product."
    • addedInput schema / properties / qty / description
      Added value: +"Quantity to add (default 1, max 99)."
    • addedInput schema / properties / size / description
      Added value: +"Size label; must be one of the product's available sizes."
    • changedOutput schema / (root)
      Previous value: -nullNew value: +{
      +  "properties": {
      +    "checkout_url": {
      +      "description": "Cart page URL for the human.",
      +      "type": "string"
      +    },
      +    "currency": {
      +      "type": "string"
      +    },
      +    "error": {
      +      "description": "Present instead of a cart when the call failed (bad index, unavailable size, ...).",
      +      "type": "string"
      +    },
      +    "items": {
      +      "description": "Cart lines in index order — this index is what set_cart_quantity/cart_update/cart_remove take.",
      +      "items": {
      +        "properties": {
      +          "code": {
      +            "type": "string"
      +          },
      +          "currency": {
      +            "type": "string"
      +          },
      +          "custom": {
      +            "description": "True when the line is a user-generated custom print.",
      +            "type": "boolean"
      +          },
      +          "fabric": {
      +            "type": "string"
      +          },
      +          "good_id": {
      +            "type": "integer"
      +          },
      +          "price": {
      +            "type": "number"
      +          },
      +          "product": {
      +            "type": "string"
      +          },
      +          "qty": {
      +            "type": "integer"
      +          },
      +          "size": {
      +            "type": "string"
      +          },
      +          "title": {
      +            "type": "string"
      +          }
      +        },
      +        "type": "object"
      +      },
      +      "type": "array"
      +    },
      +    "subtotal": {
      +      "description": "Sum of price x qty over all lines, USD.",
      +      "type": "number"
      +    }
      +  },
      +  "type": "object"
      +}
  5. First observed

TDQS

A4.9/5.0
Behavior5/5

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

Goes well beyond the annotations (readOnlyHint=false, idempotentHint=false, destructiveHint=false) by disclosing merge semantics (matching line grows, capped at 99), failure semantics (unknown good_id or unavailable size errors and leaves the cart unchanged), and set-specific behavior (two lines per qty, qty fixed at 1, 10 sets per call, part-off-sale rejection).

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?

Front-loaded with the core operation and tightly written, with no filler sentences. It is a single dense block, though, and the set-handling rules would scan better as a separate sentence or list rather than being folded into the same run-on passage.

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?

For a four-parameter mutation tool with an output schema, this covers the mutation model, error paths, defaults, and the unusual bundled-set case. An agent has everything needed to call it correctly, and return values are already covered by the output schema.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is already 100%, but the description adds real meaning: where good_id comes from, that size must match get_product's sizes, the fallback to get_user_prefs when omitted, fabric defaulting to the first offered, and that qty is additive rather than a set-value.

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?

Opens with a specific verb and resource ("Add a catalog product to the user's cart") plus the outcome ("return the updated cart"), and explicitly separates itself from add_custom_to_cart and update_cart_item.

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 routing rules: use add_custom_to_cart for AI-generated prints, update_cart_item to change an existing line, and omit size to inherit the saved default from get_user_prefs. Practical prerequisites (good_id from search_products/get_product, size from get_product) are stated inline.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources