Skip to navigation

B2C Storefront

The B2C storefront MCP server supports both guest and authenticated shopping flows. AI agents can search your product catalog, build a cart, and generate a checkout link on behalf of any shopper. When paired with Storefront Session Sync, the agent operates in the shopper’s existing browser session — carrying their login state, cart, and personalized pricing.

Example prompts

  • “Find Nike running shoes size 10 that are under $120.”
  • “Show me the top 5 bestsellers in ‘Hoodies’.”
  • “What goes well with this jacket?”
  • “I’m ready to check out.”

Tools

Search the storefront product catalog by keyword. Supports cursor-based pagination for browsing large result sets.

InputTypeRequiredDescription
termstringYesSearch keyword. Must be at least 3 characters.
cursorstringNoPagination cursor from a previous response’s nextCursor field. Omit for the first page.
contextstringNoAdditional context about the request (demographics, mood, location) to help tailor results. Must not contain PII.

Returns a list of matching products including name, description, and available options. When nextCursor is null, there are no more results.

Fetch variants and images for a specific product by ID. Use this after search_products to retrieve the information needed before adding an item to the cart.

InputTypeRequiredDescription
idintegerYesProduct entity ID from search_products.
option_valuesarrayYes (when product has options)Option selections. Each entry requires optionEntityId and valueEntityId. If the product has options, prompt the shopper to choose before calling this tool.

Returns product images and available variants with SKUs.

Add a product to the cart. If no cart exists in the current session, one is created automatically.

InputTypeRequiredDescription
item.quantityintegerYesNumber of units to add.
item.productEntityIdintegerYesProduct entity ID.
item.variantEntityIdintegerNoVariant entity ID. Required when the product has variants.
item.selectedOptionsobjectNoOption selections for checkboxes, date fields, text fields, multiple choice, and number fields.

Returns the updated cart.

Change the quantity, variant, or options for an existing line item in the cart.

InputTypeRequiredDescription
line_item_idstringYesEntity ID of the cart line item to update.
item.quantityintegerYesUpdated quantity.
item.productEntityIdintegerYesProduct entity ID.
item.variantEntityIdintegerNoUpdated variant entity ID.
item.selectedOptionsobjectNoUpdated option selections.

Returns the updated cart.

Remove a line item completely from the cart. To reduce quantity without removing the item, use update_cart_item instead.

InputTypeRequiredDescription
item_idstringYesEntity ID of the cart line item to remove.

Returns the updated cart.

Generate a checkout URL for the cart in the current session. Requires a cart to exist.

No inputs required.

Returns checkoutURL — redirect the shopper to this URL to complete their purchase.

Typical flow

1

Search for products

Call search_products with a keyword to find matching items. Use cursor to paginate through large result sets.

2

Get product details

Call get_product_details with the product ID. If the product has options (size, color, etc.), prompt the shopper to choose before proceeding.

4

Add to cart

Call add_item_to_cart with the selected product, variant, and quantity. A cart is created automatically if one does not already exist.

5

Adjust the cart

Use update_cart_item to change quantities or variants, or remove_item_from_cart to remove items the shopper no longer wants.

6

Go to checkout

Call create_checkout_url and redirect the shopper to the returned URL to complete their purchase.

Typical flow — authenticated shopper

For storefronts using Storefront Session Sync, the agent can operate in the shopper’s existing logged-in session.

1

Sync the session

Before initializing the MCP connection, call generateSessionSyncToken from the Stencil storefront and pass the token to your agent. The agent includes it as X-Bc-Storefront-Sync-Token on the MCP initialize request. See Storefront Session Sync for the full flow.

2

Search and browse

Call search_products and get_product_details. For logged-in customers, results reflect customer-specific pricing and catalog availability configured via customer group access rules on the store.

3

Add to cart

Call add_item_to_cart. If this creates a new cart, the MCP server returns an X-Bc-Mcp-Stencil-Sync-Code header in the response. Forward this code to the browser and call applySessionSyncCode to keep the browser session in sync.

4

Adjust the cart

Use update_cart_item and remove_item_from_cart as needed.

5

Go to checkout

Call create_checkout_url. The returned URL is a plain <checkoutUrl>/checkout link — it doesn’t carry the session itself. Since the shopper’s browser already holds the authenticated cookies from the synced session, opening that URL in their browser lands them in checkout with their account, saved addresses, and any account-level pricing already applied.

Example

Here is search_products in action inside Claude, searching a sample store for products related to coffee.

Claude's response showing search_products was called with the term espresso
Claude calling search_products with the term 'espresso'
Expanded view showing the search_products request body and matching product results
Expanding the tool call to inspect the request and response