Building Agentic Commerce #1: Multi-Protocol Checkout — MCP + x402 + ACP in One Flow
One agent, three protocols, one checkout. Here's how MCP, x402 stablecoin payments, and ACP work together to let AI agents buy products — with code examples you can run today.
Executive summary
First post in the 'Building Agentic Commerce' series. A developer guide to multi-protocol checkout: how MCP tools, x402 stablecoin settlement, and ACP discovery work together in a single agent purchasing flow.
Published
2026-04-05
12 min
Author
Integration Architecture Team
Implementation architects
The integration architecture team focuses on practical rollout patterns for stores adopting MCP-compatible commerce surfaces.
View profileCategory
developer-guide
When an AI agent decides to buy a product, it doesn't care which payment protocol the merchant uses. It cares about: can I discover products, add them to a cart, and pay? The complexity of protocol routing, signature verification, and settlement should be invisible. This is the problem we solved with multi-protocol checkout — and in this post, we'll show you exactly how it works, with code you can run against our demo store today.
This is Part 1 of the 'Building Agentic Commerce' series. Each post covers one foundational concept with working code examples. Part 2 covers agent discovery via NLWeb and llms.txt. Part 3 covers trust scores.
The Problem: Three Protocols, One Agent
Today's agentic commerce ecosystem has multiple payment protocols, each optimized for different scenarios. MCP (Model Context Protocol) provides the tool interface — search, cart, checkout. x402 enables stablecoin payments on-chain (USDC on Base, Ethereum, Solana). ACP (Agentic Commerce Protocol) defines how agents discover merchant capabilities and negotiate payment methods. An agent shopping across merchants will encounter all three. If each requires a different integration, agent developers face a fragmentation nightmare.
The Architecture: Protocol Bridge
AgenticMCPStores uses a Protocol Bridge that normalizes every incoming request to a unified AgentPaymentIntent, regardless of which protocol the agent speaks. The bridge detects the protocol from HTTP headers (X-Protocol: X402, X-Protocol: ACP) or request body shape, routes to the appropriate inbound adapter, and returns a protocol-specific response. Merchants configure which protocols they support — the agent never needs to know the details.
How Protocol Detection Works
The protocol detector middleware runs on every checkout request and assigns a confidence score. X-Protocol header gets 1.0 confidence. Body shape detection (presence of 'cartId' for ACP, 'network' for x402) gets 0.9. If no protocol is detected, the request falls through to standard MCP checkout. This means existing MCP agents work without any changes — protocol awareness is additive, not breaking.
Flow 1: MCP Checkout (The Default Path)
The simplest checkout flow uses MCP tools directly. An agent calls four tools in sequence: search_products to find items, create_cart to build a cart, preview_checkout to see totals and shipping, and complete_checkout to finalize the purchase. Every tool is idempotent — safe to retry on network failures.
MCP Checkout: Step by Step
- 1search_products({ query: 'wireless headphones', limit: 5 }) — returns ranked results with trust-weighted scoring. No auth required.
- 2create_cart({ items: [{ product_id: 'prod-123', quantity: 1 }] }) — returns cart_id (UUID). Requires OAuth Bearer token.
- 3preview_checkout({ cart_id: '550e8400-...' }) — returns total, tax, shipping options. Sets session to READY_FOR_PAYMENT.
- 4complete_checkout({ checkout_session_id: '550e8400-...', idempotency_key: 'req-abc-123' }) — finalizes purchase. Returns order_id and total_charged.
Always generate a unique idempotency_key per payment attempt. If the network drops after complete_checkout succeeds, retrying with the same key returns the existing order instead of creating a duplicate charge.
Flow 2: x402 Stablecoin Checkout (USDC on Base/Ethereum/Solana)
x402 adds a payment layer for agents that hold cryptocurrency. Instead of a credit card token, the agent pays on-chain in USDC and submits proof of payment. The flow starts the same as MCP (search, cart, preview) but diverges at the payment step. When the agent sends X-Protocol: X402, the server responds with HTTP 402 Payment Required — a standard HTTP status code that was literally designed for this use case decades ago and is finally being used as intended.
x402 Payment: The Three-Step Dance
- 1Step 1: Agent POSTs to /api/v1/agent/checkout with X-Protocol: X402 header. Server responds 402 with payment details: amount in USDC wei, merchant wallet address, network (Base/Ethereum/Solana/Polygon/Arbitrum), and a 5-minute timeout.
- 2Step 2: Agent executes on-chain USDC transfer to the merchant's wallet address. This happens entirely outside AgenticMCPStores — it's a standard blockchain transaction.
- 3Step 3: Agent POSTs proof of payment to /api/v1/agent/checkout/x402/verify with the transaction signature. Server verifies via the merchant's facilitator, settles with exponential backoff (5 retries, 5s-40s delays), and returns 202 Accepted.
Settlement is asynchronous: the server returns 202 immediately and processes the settlement in the background. Orders that aren't verified within 30 minutes auto-expire. The entire payment verification is BOLA-protected — agents can only settle orders they created.
Flow 3: ACP Discovery + Protocol Negotiation
ACP doesn't replace MCP or x402 — it sits above them as a discovery and negotiation layer. An agent fetches GET /.well-known/acp.json (public, no auth, cached 1 hour) and learns what the platform supports: which payment handlers are available (Stripe, x402, PayPal, UCP), which transports work (REST, MCP), and what capabilities the platform offers (cart persistence, agent session resume, display context negotiation).
ACP Discovery Response (What Agents See)
The ACP discovery endpoint returns a JSON contract specifying: spec_version '2026-01-30', supported transports (REST and MCP), four payment handlers (Stripe for USD/EUR, x402 for USDC, PayPal for USD/EUR, UCP for USD/EUR), and capability negotiation options including webview and headless display contexts, cart persistence, and agent session resume. Authentication follows OAuth 2.1 with RFC 9728 protected resource metadata.
With this information, a smart agent can make protocol decisions automatically: use x402 if it holds USDC, fall back to Stripe if it has a card token, or use UCP if the merchant supports Shopify's Universal Commerce Protocol. The agent never needs to hard-code protocol logic — it reads the ACP contract and adapts.
Putting It Together: Multi-Merchant, Multi-Protocol
The real power emerges with multi-merchant orders. When a cart contains items from different merchants, the Protocol Bridge splits the order into per-merchant intents and routes each independently via Promise.allSettled(). Merchant A might settle via Stripe while Merchant B settles via x402 — in the same checkout. One merchant's failure doesn't block others. Each gets its own ProcessedIntent with status, source/target protocol, and policy decision.
Try It: Demo Store Checkout
You can test the full MCP checkout flow right now against our demo store. The demo store at agenticmcpstores.com/demo-store has 18 products across multiple categories. Discovery tools (search_products, get_product_details, browse_categories) work without authentication. For checkout tools (create_cart, complete_checkout), use the Playground at agenticmcpstores.com/demo-store/playground which provides a built-in MCP client with pre-configured auth.
Security by Design
- 1UUID validation before any database query (SQL injection guard)
- 2Idempotency keys prevent double-charging on retries
- 3Payment tokens are NEVER logged or included in error messages
- 4x402 facilitator URLs are validated against private IP ranges (SSRF protection)
- 5BOLA protection: agents can only access orders they created (via agentKeyId)
- 6KYAI policy engine evaluates every checkout against merchant rules (ALLOW/FRICTION/REVIEW/BLOCK)
- 7OAuth 2.1 with PKCE for all mutating operations
What's Next in the Series
In Part 2, we'll cover how AI agents discover your store before they ever call an API — through NLWeb semantic search, llms.txt files, and the agent-card.json discovery protocol. In Part 3, we'll deep-dive into trust scores: the 8-component scoring system that determines how much autonomy an agent gets when shopping at your store.
Frequently asked questions
Do I need to implement all three protocols to use AgenticMCPStores?
No. MCP is the default and works out of the box. x402 and ACP are additive — merchants enable them in their protocol configuration. Agents that only speak MCP will always work. The Protocol Bridge handles routing automatically based on what each merchant supports.
What happens if an x402 payment fails after the agent sends USDC?
The settlement service retries with exponential backoff (5 attempts over ~75 seconds). If all retries fail, the order status moves to 'failed' and an OrderEvent is logged. The on-chain USDC transfer is separate from order settlement — refund handling depends on the facilitator configuration. In practice, facilitator verification failures are rare because the blockchain transaction is either valid or not.
Can an agent use different protocols for different items in the same cart?
Not within a single cart, but across merchants yes. The Protocol Bridge splits multi-merchant orders into per-merchant intents, and each merchant intent uses the merchant's configured protocol. So Merchant A might settle via Stripe while Merchant B settles via x402 in the same overall checkout.
What USDC networks are supported for x402 payments?
Base, Ethereum, Solana, Polygon, and Arbitrum. Each merchant configures their preferred network and wallet address. The agent sees the network requirement in the HTTP 402 response and submits payment on the correct chain.
Is the ACP spec standardized or proprietary?
ACP (Agentic Commerce Protocol) is an open specification (version 2026-01-30). The spec defines a discovery format, payment handler declarations, and capability negotiation. AgenticMCPStores implements the spec fully — the /.well-known/acp.json endpoint is public and follows the standard schema.
Sources and references
- Model Context Protocol Specification
Anthropic
- HTTP 402 Payment Required — x402 Protocol
x402 Protocol
- Agentic Commerce Protocol (ACP)
ACP Working Group
- RFC 9728 — OAuth 2.0 Protected Resource Metadata
IETF
- USDC on Base — Circle
Circle
Related articles
Agentic Commerce
ACP vs AP2 vs x402: Complete Guide to Agentic Payment Protocols
Three protocols are shaping how AI agents handle payments. ACP (Stripe/OpenAI) for fiat, AP2 (Google) for cart mandates, and x402 (Coinbase/Cloudflare) for USDC stablecoins. Here's when to use each.
Agentic Commerce
Zero-Click Commerce: When the Agent Buys Without the User Visiting Your Store
The majority of AI-assisted purchases in 2026 will never produce a click on your website. The agent compares, decides and executes. Your store doesn't need to be visited — it needs to be understood.
trust-compliance
Why eIDAS-Verified Merchant Identity Changes Everything for AI Commerce
AI agents need more than product data to transact — they need cryptographic proof that merchants are who they claim to be. Here's how eIDAS QTSP verification solves the trust gap in agentic commerce.