Agentic commerce plugin for Medusa v2 — adds UCP and ACP protocol support, enabling AI agents to browse, checkout, and pay at any Medusa storefront.
Make your Medusa v2 store shoppable by AI agents.
This plugin adds UCP and ACP protocol endpoints to your Medusa backend, so AI shopping agents can discover your products, create checkouts, and complete purchases — through standard HTTP APIs that require no frontend at all.
AI agents are becoming the next commerce channel. Just like merchants once added mobile apps alongside their websites, they'll soon need to serve autonomous agents that shop on behalf of consumers. But agents don't browse — they need structured APIs with standardized discovery, checkout flows, and payment settlement.
UCP (Universal Commerce Protocol) and ACP (Agentic Commerce Protocol) are the emerging open standards for this. This plugin implements both as native Medusa v2 modules, so your store speaks the language agents understand — in minutes, with no custom code and no frontend changes.
| Feature | Description |
|---|---|
| Dual protocol support | Both UCP and ACP endpoints from a single plugin |
| Product discovery | Full-text search and direct lookup for agents to browse your catalog |
| Checkout sessions | Create, update, complete, and cancel — with idempotency built in |
| Pluggable payments | Bring your own payment handler via the adapter interface |
| Order tracking | Agents can retrieve order status and details |
| Webhook notifications | Automatic agent callbacks on order placement |
| Protocol discovery | and for automatic capability detection |
| Product feed sync | Scheduled job to push your catalog to agent platforms |
npm install @financedistrict/medusa-plugin-agentic-commerce
import { defineConfig } from "@medusajs/framework/utils"export default defineConfig({// Register the plugin for route/workflow/subscriber auto-discoveryplugins: [{resolve: "@financedistrict/medusa-plugin-agentic-commerce",options: {},},],modules: [// Register the core service module with your configuration{key: "agenticCommerce",resolve: "@financedistrict/medusa-plugin-agentic-commerce/modules/agentic-commerce",options: {api_key: process.env.AGENTIC_COMMERCE_API_KEY,signatureKey: process.env.AGENTIC_COMMERCE_SIGNATURE_KEY,storefront_url: process.env.STOREFRONT_URL || "https://your-store.com",store_name: "Your Store Name",store_description: "What your store sells",// Reference payment handler adapter module keys (see Payment Handlers)payment_handler_adapters: ["prismPaymentHandler"],},},],})
# RequiredAGENTIC_COMMERCE_API_KEY=your-secret-api-key# OptionalAGENTIC_COMMERCE_SIGNATURE_KEY=your-hmac-secretSTOREFRONT_URL=https://your-store.comAGENTIC_STORE_NAME="Your Store"AGENTIC_STORE_DESCRIPTION="Premium widgets for humans and agents"
npx medusa develop
Your agent APIs are now live:
# Discoverycurl http://localhost:9000/.well-known/ucpcurl http://localhost:9000/.well-known/acp.json# Search products (UCP)curl -X POST http://localhost:9000/ucp/catalog/search \-H "UCP-Agent: my-agent/1.0" \-H "Request-Id: $(uuidgen)" \-H "Content-Type: application/json" \-d '{"query": "t-shirt", "limit": 10}'
UCP is designed for agent-to-merchant interactions. It uses a shopping-cart model where agents manage carts directly.
| Endpoint | Method | Description |
|---|---|---|
| GET | Protocol discovery and capabilities | |
| POST | Full-text product search | |
| POST | Direct product lookup by ID or handle | |
| POST | Create a new cart | |
| GET | Retrieve cart | |
| PUT | Update cart (add/remove items, set address) | |
| POST | Create checkout session from cart | |
| GET | Retrieve checkout session | |
| PUT | Update checkout session | |
| POST | Complete checkout and place order | |
| POST | Cancel checkout session | |
| GET | Retrieve order details |
Required headers: ,
ACP is designed for platform-to-merchant interactions. It uses a session-based model where the platform manages the checkout flow.
| Endpoint | Method | Description |
|---|---|---|
| GET | Protocol discovery and capabilities | |
| POST | Create checkout session | |
| GET | Retrieve checkout session | |
| POST | Update checkout session | |
| POST | Complete checkout | |
| POST | Cancel checkout session | |
| GET | Retrieve order | |
| GET | Retrieve product feed |
Required headers: ,
Payment is handled through a pluggable adapter system. Each adapter implements the interface and registers as a Medusa module.
For x402 stablecoin payments (USDC, FDUSD, etc.), use the companion package:
npm install @financedistrict/medusa-plugin-prism-payment
See @financedistrict/medusa-plugin-prism-payment for setup instructions.
Implement the interface:
import type {PaymentHandlerAdapter,CheckoutPrepareInput,} from "@financedistrict/medusa-plugin-agentic-commerce"export default class MyPaymentAdapter implements PaymentHandlerAdapter {readonly id = "my_payment_handler"readonly name = "My Payment"// Discovery — what to advertise in .well-known endpointsasync getUcpDiscoveryHandlers(): Promise<Record<string, unknown[]>> {return {"com.example.my_payment": [{id: "my-handler",version: "1.0.0",}],}}async getAcpDiscoveryHandlers(): Promise<unknown[]> {return [{id: "com.example.my_payment",name: "My Payment",version: "1.0.0",psp: "my-psp",requires_delegate_payment: false,instrument_schemas: [/* ... */],}]}// Checkout preparation — called when a checkout session is createdasync prepareCheckoutPayment(input: CheckoutPrepareInput) {// Call your payment gateway, return config for the agentreturn { id: "my-handler", version: "1.0.0", config: { /* ... */ } }}// Response formatting — include payment config in checkout responsesgetUcpCheckoutHandlers(cartMetadata?: Record<string, unknown>) {return { /* ... */ }}getAcpCheckoutHandlers(cartMetadata?: Record<string, unknown>) {return [/* ... */]}}
Register it as a Medusa module and reference it in :
// medusa-config.tsmodules: [{key: "myPaymentHandler",resolve: "./src/modules/my-payment-handler",options: { /* ... */ },},{key: "agenticCommerce",resolve: "@financedistrict/medusa-plugin-agentic-commerce/modules/agentic-commerce",options: {payment_handler_adapters: ["myPaymentHandler"],// ...},},]
Medusa v2 modules have isolated DI containers. The plugin resolves payment handler adapters from the request-scoped container () via middleware — not from the module's constructor. This ensures all modules are registered and accessible at request time.
The plugin provides four reusable workflows that orchestrate the checkout process:
| Workflow | Description |
|---|---|
| Validates cart, resolves region, prepares payment | |
| Handles item/address changes, re-prepares payment | |
| Completes payment, creates order | |
| Cancels session and releases resources |
Import them in your custom code:
import {createCheckoutSessionWorkflow,completeCheckoutSessionWorkflow,} from "@financedistrict/medusa-plugin-agentic-commerce/workflows"
| Option | Type | Default | Description |
|---|---|---|---|
| API key for ACP Bearer token authentication | |||
| HMAC-SHA256 key for request signing | |||
| Public URL of your storefront | |||
| Store name in protocol responses | |||
| Store description for discovery | |||
| Medusa payment provider ID | |||
| Module keys of payment handler adapters | |||
| UCP protocol version to advertise | |||
| ACP protocol version to advertise |
| Variable | Maps to |
|---|---|
import {// Service & moduleAgenticCommerceService,AgenticCommerceModule,AGENTIC_COMMERCE_MODULE,// Payment adapter interfacePaymentHandlerAdapter, // typeCheckoutPrepareInput, // typePaymentHandlerRegistry,// Error formattingformatAcpError,formatUcpError,// Address translationmedusaToAcpAddress,acpAddressToMedusa,medusaToUcpAddress,ucpAddressToMedusa,// Status mappingresolveAcpStatus,resolveUcpStatus,} from "@financedistrict/medusa-plugin-agentic-commerce"
Types and formatters are audited against the official protocol specifications:
This package follows semver. While pre-1.0:
The companion declares this package as a peer dependency with a range (e.g., ), so incompatible combinations are caught at install time.
MIT