Agent-ready stores
Every Mercatus Liber store is agent-ready by default. Any AI agent (ChatGPT, Claude, Gemini, a shopping assistant someone built) can find the store, browse it, answer questions about it, fill a cart and hand the person it’s helping a checkout link. The person confirms the address and pays on the store’s own checkout page.
It’s on unless the store turns it off. The code is
@mercatus-liber/agent-commerce; the design and its review are in the
agent-commerce epic .
What a store serves
| Path | What it is |
|---|---|
/mcp | A public MCP endpoint (Streamable HTTP, no sign-in) with shopper tools only |
/llms.txt | What the store sells, its policies, and how an agent shops it |
/.well-known/mcp.json | An MCP Server Card, so agents find the endpoint without connecting first |
/feed.jsonl | A product feed: every variant with its price, sale price and stock, one JSON object per line |
/.well-known/ucp | A UCP business profile pointing at the store’s checkout sessions |
/ucp/v1/checkout-sessions | UCP checkout sessions over REST (create, get, update, complete, cancel) |
/acp/checkout_sessions, /.well-known/acp.json | ACP checkout sessions, once the store has issued keys to an agent platform |
/cart/resume?id=… | Opens a cart an agent built in the buyer’s own browser |
Product pages also carry schema.org structured data built from the same view: a ProductGroup
with a Product per variant (color and size as variesBy), sale prices with the regular price as
a StrikethroughPrice, stock, the seller and the return policy.
On the shared demo these live under each store, e.g. /demo/print-shop/mcp.
The tools
| Tool | What it does |
|---|---|
get_store_info | What the store sells, where it ships, policies, notes for buyers, how checkout works |
search_products | Search by words, or list products |
get_product | One product: description, images, each option’s values, and variants with skuId, price and availability. Big products return 50 variants at a time; options (e.g. {"color":"Black","size":"M"}) narrows to the one the buyer wants |
add_to_cart | Add a variant; starts a cart when there’s no cartId |
get_cart, update_cart_item, remove_cart_item | Read and edit the cart. With previewCheckout, the subtotal is what checkout charges and savings says how much of the sale it already includes |
start_checkout | Creates the order and returns the store’s checkout link for the buyer. A discount code that doesn’t apply is refused, not silently dropped |
get_order_status | Status and items of an order, with the order id and the checkout email |
A store that supplies the matching hook also gets these. A tool is listed only when its hook is there, so agents never see a tool the store can’t answer:
| Tool | Hook | What it does |
|---|---|---|
list_categories | catalog.listCategories | Categories and product lines, with ids and pages. With catalog.listProductIdsInCategory, search_products takes a category |
check_discount_code | checkout.previewCheckout | Whether a code applies to the cart and what it saves. Tries the code as typed, then upper-cased, and returns the exact code to pass on |
estimate_shipping | checkout.estimateShipping | Shipping options and prices for the cart to a country and postal code. For a country the store ships to but agent checkout doesn’t cover (outside shipsTo), it quotes the site’s price and sends the buyer to the cart link |
get_customization_options, price_customization | customization | What a buyer can personalize on a made-to-order product, and its price. add_to_cart then takes slug and customization |
Admin tools (products, content, stock, lines) are never on this endpoint. Operators get those
from ai-interface’s server, which runs only where the operator starts it.
How a purchase works
- The agent calls
get_store_info, thensearch_productsandget_product. - It adds variants with
add_to_cartand keeps thecartId. - It calls
start_checkoutwith the buyer’s email (and name and discount code, if it has them). - It gives the buyer the
checkoutUrl. The buyer confirms the address and pays there. - Later,
get_order_statuswith the order id and email shows where the order is.
The agent never sees card details. The order goes through the same checkout, stock, webhooks and abandoned-checkout recovery as one placed by a person clicking through the site.
UCP checkout sessions
Agents that speak the Universal Commerce Protocol (version 2026-08-25) find
the store’s profile at /.well-known/ucp and create checkout sessions at
/ucp/v1/checkout-sessions:
- A session is a cart. Its line items are variant ids (
item.id, theskuIdfromget_product) and go through the same guard rails as the MCP tools. - Totals are integers in minor units:
subtotal, a negativediscountwhen a code indiscounts.codesapplies, andtotal. Shipping and tax come on the store’s checkout page. - The store takes payment on its own page, so there are no payment handlers and a session never
reaches
ready_for_complete. A valid session isrequires_escalation, withcontinue_urlset to where the buyer finishes: the payment page when the request includesbuyer.email, otherwise the store page that opens the agent’s cart (urls.resumeCart).completeanswers the same way. PUTreplaces the session’s lines, andcancelempties the cart.- A repeated
Idempotency-Keywith the same body replays the first response. The same key with a different body gets a 409. The default store is in memory, so on serverless this is best effort per instance; passidempotencyfor a shared one. - What this doesn’t do yet: the UCP MCP binding and catalog capabilities (the shopper MCP
endpoint covers browsing), fetching and checking the platform’s
UCP-Agentprofile, and signed requests.
// app/.well-known/ucp/route.ts
return Response.json(ucpProfile({ endpoint: "https://shop.example/ucp/v1" }));
// app/ucp/v1/[...path]/route.ts
return handleUcpRequest(request, await agentDeps(), { basePath: "/ucp/v1", env: process.env, allow });Turn UCP off alone with agentAccess: { ucp: false }, and ACP with { acp: false }.
ACP checkout sessions
The Agentic Commerce Protocol (API version 2026-04-17) is
built the same way as UCP, at /acp/checkout_sessions, with its discovery document at
/.well-known/acp.json. Two things make it different:
- It needs keys. ACP agents authenticate with an
Authorization: Bearerkey the store issues to the agent platform, so ACP is off (404) until the store passesapiKeys. The reference storefront reads them fromACP_API_KEYS(comma-separated). It also needsAPI-Version, and anIdempotency-Keyon every POST (422 for the same key with a different body). - Completing a purchase in the agent needs delegated payment, which no store has turned on.
Until then a valid session is
requires_escalation,capabilities.payment.handlersis empty, andcontinue_urlis where the buyer pays: the payment page withbuyer.email, otherwise the page that opens the agent’s cart.completesays so with anintervention_requiredmessage.
Totals follow ACP’s conventions: positive amounts with display_text, the code’s savings as a
discount line, and the currency in lower case. Line items are accepted as line_items or as
items (the spec’s schema and its examples disagree). The product feed (above) is the other half
of selling through ChatGPT; its rows say is_eligible_checkout: false until delegated payment is on.
Agents in the buyer’s browser (WebMCP)
WebMCP lets a page offer tools to an agent
running in the browser. Storefront pages register the same shopper tools through
document.modelContext.registerTool (or navigator.modelContext on older trial builds), and
each tool runs by calling the store’s own MCP endpoint, so the answers and rules are identical.
The entry point is browser-only and pulls in no MCP SDK:
"use client";
import { useEffect } from "react";
import { registerWebMcpTools } from "@mercatus-liber/agent-commerce/webmcp";
export function WebMcpTools({ endpoint }: { endpoint: string }) {
useEffect(() => {
const controller = new AbortController();
void registerWebMcpTools({ endpoint, signal: controller.signal });
return () => controller.abort();
}, [endpoint]);
return null;
}It does nothing in browsers without WebMCP, or when agent access is off. As of late 2026 WebMCP
is a W3C Community Group draft, in origin trials in Chrome and Edge, with a testing flag at
chrome://flags/#enable-webmcp-testing.
Turning it off
- Everything: set
AGENT_ACCESS=offin the store’s environment. On Vercel, redeploy for an environment change to apply. - In code: pass
agentAccess: false(or{ mcp: false }to keep onlyllms.txt).
Guard rails
- Only active products in the store’s own catalog are visible, even when one database holds several stores.
- At most 10 of one item and 20 lines per cart through an agent (configurable).
- The success and cancel pages are the store’s, never the agent’s. The cart is the checkout’s retry key, and a checkout key can’t fetch another cart’s order.
- Order status needs the checkout email and returns status and items only: no address, phone or payment link. A wrong email and an unknown order get the same answer.
- Unpaid orders release their stock (by the payment provider’s session expiry, or after an hour on adapters that never report expiry).
- A per-client rate limit. Its default counter is in memory, so on serverless it’s a brake per
instance rather than a hard cap. For a real one, pass a shared store:
@mercatus-liber/adapter-postgreshascreatePostgresRateLimitStore(pool)(andcreatePostgresIdempotencyStore(pool)for UCP and ACP replays), which keep the counts in the store’s own database. The reference storefront uses them whenever it has Postgres. - A cart id works like a password: whoever holds it can change the cart. The page behind
urls.resumeCartshould give the buyer their own copy of the agent’s cart (the reference storefront does), so once they take over, nobody else holding the id can change what they’re about to pay for. Refuse ids whose cart is empty or already paid for;checkout.listOrdersForCart(cartId)answers that without reading every order. - A store whose carts don’t survive between requests (in-memory carts on serverless) is browse-only for agents, and says so.
Store-specific pieces
Each store describes itself and can add its own tools:
store.policies: shipping, returns and contact text, in the store’s own words.store.notes: short, true things an agent should tell a buyer, e.g. “3D-printed items start printing Dec 1.” They appear inget_store_info,llms.txtand the server’s instructions.catalog.salePrice(sku): the price a shopper pays now without a code, so agents quote sale prices (with the regular price beside them) instead of list prices.checkout.previewCheckout: when given, cart totals come from checkout’s own pricing, so the agent’s subtotal matches what checkout charges.catalog.availableUnits(skuId): units in stock, ornullfor made-to-order items, which then never read as sold out.customization: made-to-order products (engraving, colors, measurements).describe(product)returns the fields a buyer fills in (choices with price changes, text with a length limit, numbers with a range and unit), orsiteOnly: truewhen a person has to finish it on the product page (an upload, say).priceandaddToCartvalidate and price on the store’s server, the same path its product page uses, so an agent never sets a price. ThrowAgentInputErrorwith a message the agent can pass on when a choice is wrong. Each personalized line is its own cart line, andget_cartshows itspersonalization.- Stores on
@mercatus-liber/customizationdon’t writecustomizationby hand:customizationAgentHooks({ source, priceLine, addLine, defaultSkuId, defaultSelection, currency })turns its finishes, colored regions, options, art styles and measured settings into agent fields (finish,color:<region>,option:<id>,artStyle,name,param:<id>). Anything the buyer leaves out takes the store’s defaults, the package’s own messages (“crown: plaid isn’t offered”) reach the agent, and a choice priced by hand is refused with a pointer to the product page. extraTools: the store’s own shopper-safe tools (an engraving preview, a made-to-order queue date). They’re public like the rest, and a name that clashes with a built-in tool is refused.
Product feed and structured data
import { buildProductFeed, productFeedJsonl, productJsonLd, createCatalogView } from "@mercatus-liber/agent-commerce";
// app/feed.jsonl/route.ts
const rows = await buildProductFeed(await agentDeps(), { acceptsReturns: true, returnDays: 30 });
return new Response(productFeedJsonl(rows), { headers: { "content-type": "application/jsonl" } });
// a product page
const deps = await agentDeps();
const product = await createCatalogView(deps).toAgentProduct(catalogProduct);
<JsonLd data={productJsonLd(product, deps.store, { rating })} />The feed follows OpenAI’s product feed format :
one row per variant, grouped with group_id and variant_dict, money as "30.25 USD", and a
sale_price when a sale is on. Rows from a demo store (sandbox) say is_eligible_search: false,
so a test store never shows up as a real place to buy. is_eligible_checkout stays false: agent
checkout here is a hosted link, not an in-chat checkout protocol. Set urls.feed and llms.txt
lists the feed.
Adding it to a store
// app/mcp/route.ts (Next.js)
import { handleAgentMcpRequest, createRateLimiter } from "@mercatus-liber/agent-commerce";
const allow = createRateLimiter({ perMinute: 60 });
async function handle(request: Request) {
return handleAgentMcpRequest(request, await agentDeps(), { env: process.env, allow });
}
export { handle as GET, handle as POST, handle as DELETE, handle as OPTIONS };Or serve every agent path from one handler, in any server that speaks Request/Response:
import { createAgentRoutes } from "@mercatus-liber/agent-commerce";
export const agentRoutes = createAgentRoutes(agentDeps, { env: process.env, allow });
// /mcp, /llms.txt, /.well-known/mcp.json, /feed.jsonl, /.well-known/ucp, /ucp/v1/*,
// and ACP when you pass acpApiKeys. Returns null for any other path.
const response = (await agentRoutes(request)) ?? (await yourOwnRoutes(request));New stores from create-mercatus-liber-store come with this already, in agent.ts.
agentDeps() returns an AgentCommerceDeps: the store profile, its absolute URLs, and its
catalog, search, cart and checkout services. The real subsystem services fit as they are.
Serve storeLlmsTxt(...) at /llms.txt and storeMcpServerCard(...) at
/.well-known/mcp.json. The reference storefront’s
lib/agent-commerce.ts
is a complete example.
A real store: shop.mdostal.com
The Dragon Shop is a live Mercatus Liber store with real payments, long-lived carts in Postgres, print-on-demand apparel and made-to-order 3D prints. It was the first store wired up, and these are the store-specific choices it made:
| Need | What the shop did |
|---|---|
| Its own checkout path (shipping rates, free-shipping promo, Stripe) | Wrapped its existing checkout in the checkout interface, so agent orders go through the same code as the site’s |
| Retry safety | Keys checkout on checkoutKey(cartId, ["agent", country, coupon, ...lines]) |
| Hidden products | isInStore is “active and not internal”, the same rule the site uses |
| US-only agent checkout | shipsTo: ["US"] plus a note sending other countries to the site’s cart |
| Personalized 3D prints | add_to_cart refuses them with a pointer to the product page; a note says when printing starts |
| Sale prices | salePrice returns the price after the store’s automatic sale, so an agent quotes $30.25 and not the $55 list price |
| Made-to-order stock | availableUnits returns null for printed-on-demand items, so they never read as sold out |
| Policies | Taken from the site’s own policy page |
What it looks like to an agent, checked on the live store:
get_product {"slug":"dt-hoodie"}
-> optionValues: design (25), color (2), size (5), back (4); 50 of 560 variants, with a note
get_product {"slug":"dt-hoodie","options":{"design":"R2","color":"Black","size":"M","back":"none"}}
-> 1 variant, $30.25 (regular $55.00)
add_to_cart x2 -> subtotal $60.50, savings $49.50 (already in the subtotal)
start_checkout -> a Stripe checkout link; Stripe's total is $60.50 (free US shipping over $50)Dogfooding it found three framework fixes before anyone else hit them: a changed cart reused the old checkout, agents quoted list prices, and a 560-variant product was about 100k tokens. Sample health checks the shop’s agent endpoint along with the demo stores.
Try it
npx @modelcontextprotocol/inspector
# Transport: Streamable HTTP
# URL: https://commerce.mdostal.com/demo/print-shop/mcpThe sample stores run in test mode, so no real payment is taken. Each keeps its carts with its catalog (Postgres for The Print Shop and Northline, Convex for Broadleaf), so agents can shop all three.
What’s next
- Agents paying without a page (delegated payment, e.g. Stripe’s Shared Payment Tokens) stays off until a store opts in. It would let UCP and ACP sessions complete inside the agent.
- The UCP MCP binding and catalog capabilities, and checking a platform’s
UCP-Agentprofile. - Shared limits for stores on other databases (Convex, MongoDB, SQLite): Postgres has them today.