commerce-orchestrator-api
UCP/A2A/AP2/ACP/MCP-ready Rust middleware for agentic cart-to-checkout
An agent → orchestrator → merchant middleware layer: your AI agents (or any client) call the REST/A2A API; the orchestrator runs deterministic cart and checkout flows, delegates to your catalog, pricing, tax, geo, payment, and receipt backends. Deploy, configure six downstream URLs, and integrate — no fork required. The Commerce Orchestrator is a middleware API layer. Your clients call its REST API; the service runs deterministic cart and checkout flows and delegates to your catalog, pricing, tax, geo, payment, and receipt backends via configurable base URLs.
Summary extracted from the README.
Agentic Commerce Orchestrator
UCP/A2A/AP2/ACP/MCP-ready middleware for reliable cart-to-checkout in the age of AI agents — Rust, production-grade, open-source.
An agent → orchestrator → merchant middleware layer: your AI agents (or any client) call the REST/A2A API; the orchestrator runs deterministic cart and checkout flows, delegates to your catalog, pricing, tax, geo, payment, and receipt backends. Deploy, configure six downstream URLs, and integrate — no fork required.
Documentation
| Document | Description |
|---|---|
| Plug and deploy | End-to-end: downstream API contracts, env vars, local smoke test, staging deploy, validation checklist. |
| Consumer integration (REST API) | How to integrate: call the deployed HTTP service, no library dependency. |
| Consumption guide | Request/response shapes, auth, config reference, message signing, and next steps. |
| MCP binding | JSON-RPC transport, version negotiation, tool catalogue, resources, and error codes. |
| Deployment | Kubernetes manifests, migrations, env vars, secrets, health, HPA, observability, rollback. |
| Release checklist | Pre-release, acceptance, release, and post-release steps. |
| Security | Auth, PII handling, and vulnerability reporting. |
| Changelog | Version history and release notes. |
| Runbooks | Retries and outbox, dead-letter handling, reconciliation. |
| Consumer example | Template for wiring providers and running happy-path tests. |
| Standards conformance | Target protocol versions (UCP, A2A, AP2, ACP, MCP) and conformance matrix with acceptance criteria. |
Overview
The Commerce Orchestrator is a middleware API layer. Your clients call its REST API; the service runs deterministic cart and checkout flows and delegates to your catalog, pricing, tax, geo, payment, and receipt backends via configurable base URLs. No need to fork or patch—deploy, configure, and integrate.
Current Capabilities
- Cart and checkout: Create cart, add/update/remove items, apply adjustments, start checkout, execute checkout with idempotency and in-flight deduplication.
- Payment lifecycle: Capture, void, and refund on the facade and HTTP API; tenant-scoped and authz-protected.
- Reservations: In-memory reservation lifecycle (
reserve,finalize,release,sweep_expired). - Provider connectivity: Per-provider outbound auth (bearer, API key, OAuth2 client-credentials, mTLS), retries restricted to retryable statuses with
Retry-Afterand jitter, and a per-provider circuit breaker. - Reliability: Outbox, inbox, and dead-letter primitives with a background outbox processor that delivers webhooks and drains on shutdown; operational endpoints to process outbox, list/replay dead-letter, and run reconciliation.
- Auth and multi-tenancy: Bearer token auth, tenant and scope checks; idempotency and state scoped by tenant.
- Message signing: RFC 9421 HTTP Message Signatures with
Content-Digest(Ed25519 or ES256) for UCP request verification and response signing, withkid-based rotation; production refuses to start without real key material. - Observability: Request IDs, tracing, Prometheus metrics; health probes for liveness and readiness; a starter Grafana dashboard.
- Deployment: Docker image, Kubernetes manifests (Deployment, Service, migration Job, HPA, PDB, NetworkPolicy, ServiceMonitor, ConfigMap, Secret) on a PostgreSQL, multi-replica contract.
API Surface (REST + MCP + ACP)
| Area | Endpoints |
|---|---|
| Cart & checkout | POST /api/v1/cart/commands, POST /api/v1/checkout/execute |
| UCP shim | /api/v1/ucp/cart, /ucp/checkout, /ucp/catalog/*, /ucp/orders/:id, /ucp/payment-handlers |
| UCP fulfillment | POST /api/v1/ucp/cart/:id/fulfillment, POST /api/v1/ucp/checkout/:id/fulfillment — quote shipping/pickup options and select one |
| UCP embedded transport | POST /api/v1/ucp/checkout/:id/embedded-link — short-lived, signed handoff URL for merchant-hosted embedded checkout |
| ACP shim | /api/v1/acp/checkout_sessions, /api/v1/acp/carts, POST /api/v1/acp/delegate_payment (API-Version: 2026-04-17, Idempotency-Key required) |
| Orders | GET /api/v1/orders, GET /api/v1/orders/:id, POST /api/v1/a2a/orders |
| Catalog | GET /api/v1/catalog/items/:id |
| Payments | POST /api/v1/payments/capture, void, refund |
| Webhooks | POST /api/v1/webhooks, GET /api/v1/webhooks, DELETE /api/v1/webhooks/:id |
| A2A | GET /.well-known/agent-card.json, POST /api/v1/a2a/message:send (A2A 1.0 HTTP+JSON); envelope routes POST /api/v1/a2a/{checkout,cart,identity/link,orders} (A2A-Version: 1.0 or 0.3) |
| MCP | POST /api/v1/mcp/message (JSON-RPC 2.0; dual-era 2026-07-28 + legacy) — see MCP binding |
| Events | POST /api/v1/events/incoming (idempotent) |
| Operations | POST /api/v1/ops/outbox/process, GET /api/v1/ops/dead-letter, POST /api/v1/ops/dead-letter/replay, POST /api/v1/ops/reconciliation |
| Discovery | GET /.well-known/ucp, GET /.well-known/acp.json |
| Health | GET /health/live, GET /health/ready, GET /metrics |
Request/response shapes and error codes: Consumption guide.
Optional capabilities are advertised only when configured. Without PAYMENT_DELEGATION_BASE_URL or IDENTITY_LINK_BASE_URL, the matching endpoint returns 501 NOT_CONFIGURED and discovery does not claim it.
Quick Start
Run the mock happy path (no external services):
cargo run -p happy_path
Run the HTTP server locally (stub/mock mode):
cargo run -p orchestrator-server
Then call the API (see Consumption guide). For production, set ENV=production, PUBLIC_BASE_URL, DATABASE_URL, AUTH_BEARER_TOKEN, the signing key pair (UCP_SIGNING_KEY_ID, UCP_SIGNING_KEY), and all six *_BASE_URL variables; see Deployment.
Plug Your APIs
- Deploy the orchestrator (Docker/Kubernetes) and set the six downstream base URLs in config:
CATALOG_BASE_URL,PRICING_BASE_URL,TAX_BASE_URL,GEO_BASE_URL,PAYMENT_BASE_URL,RECEIPT_BASE_URL. - Implement or expose HTTP endpoints that match the provider contracts (see Consumption guide – Config reference and adapter expectations in the codebase).
- In production, set
AUTH_BEARER_TOKENand sendAuthorization: Bearer <token>from your clients. - Validate with health, a cart command, checkout execute, and payment lifecycle calls; use the runbooks for outbox, dead-letter, and reconciliation.
Full walkthrough: Plug and deploy, Consumer integration, and Deployment.
Deploy
- Kubernetes: Apply manifests under
deploy/kubernetes/(ConfigMap, Secret, Deployment, Service, migration Job, HPA, PDB, NetworkPolicy, ServiceMonitor). Durable state lives in PostgreSQL, so the manifests ship two replicas; run the migration Job before rolling a new image. Override image and set real secrets before use. - Docker: Build from repo root; see
Dockerfile. SetDATABASE_URLand point it at your PostgreSQL instance for production. - Monitoring:
GET /metricsexposes Prometheus text; importdeploy/grafana/orchestrator-dashboard.json.
Details: deploy/README.md.
Operate (Runbooks)
Security
- Production mode (
ENV=production) requiresPUBLIC_BASE_URL, a Bearer token, and signing key material (UCP_SIGNING_KEY_ID,UCP_SIGNING_KEY); the server refuses to start without them. Never log tokens or raw payment data. - Set
UCP_AGENT_JWKS(orUCP_AGENT_KEYS) to require and verify inbound RFC 9421 agent signatures on/api/v1; responses are signed with the active key and old keys stay verifiable bykidduring rotation. - Use redaction helpers for any logging of checkout/payment payloads.
- Report vulnerabilities privately; see SECURITY.md.
Release and Versioning
- CI (
.github/workflows/ci.yml): format, clippy, tests, release-gate. - Audit (
.github/workflows/audit.yml):cargo audit.
Both must pass before release. The CI pipeline also runs a Docker build and container smoke test (health probes). Version history: CHANGELOG.md. Before cutting a release, follow the Release checklist (tag commands, changelog, deploy notes).
Quality gates (local):
cargo fmt --all -- --check
cargo clippy --workspace --all-targets -- -D warnings
cargo test --workspace
cargo audit
Repository Layout
| Path | Purpose |
|---|---|
crates/orchestrator-core |
Domain contracts, validation, policy, state machine. |
crates/orchestrator-runtime |
Event store, idempotency, commit, orchestration runner, persistence. |
crates/provider-contracts |
Provider traits and DTO/error contracts. |
crates/provider-mocks |
Deterministic mock provider implementations. |
crates/orchestrator-observability |
Audit sink, tracing, metrics helpers. |
crates/orchestrator-api |
Stable facade API for cart commands and checkout. |
crates/orchestrator-http |
HTTP server and routes. |
crates/orchestrator-mcp |
MCP (Model Context Protocol) tool server for AI agent integration. |
crates/integration-adapters |
HTTP clients to catalog, pricing, tax, geo, payment, receipt. |
examples/happy_path |
Runnable end-to-end mock flow. |
examples/consumer_example |
Template for consumer apps (wire providers, run happy-path). |
deploy/ |
Kubernetes manifests and the starter Grafana dashboard. |
docs/ |
Integration, consumption, MCP binding, release checklist, runbooks. |
Standards Alignment
This service implements protocol-aligned behavior for agentic commerce:
- Discovery:
GET /.well-known/ucpserves a UCP2026-08-25business profile that validates against the official UCP JSON Schema — services, capabilities, payment handler registry, and thekeys[]JWK Set — with ACP/MCP/A2A/AP2 metadata under a top-levelorchestratormember;2026-04-08and older profiles stay reachable viasupported_versions. - REST: Cart, catalog, order, checkout, and payment endpoints match the consumption guide; auth and tenant isolation are enforced.
- A2A: A2A 1.0 Agent Card at
/.well-known/agent-card.jsonand the HTTP+JSONSendMessagebinding at/api/v1/a2a/message:send, carrying the same capability envelopes asPOST /api/v1/a2a/{checkout,cart,identity/link,orders}(which keepA2A-Version1.0/0.3negotiation), normalized to the same domain types and policy as REST. - AP2 0.2: Payment intent supports
ap2_consent_proofandpayment_handler_id. WithAP2_STRICT=1, checkout verifies closed mandates and optional open (HNP) mandates with amount/currency constraints; see SECURITY.md. - ACP 2026-04-17: Merchant-hosted checkout sessions, carts, and delegate payment under
/api/v1/acp/*(requireAPI-VersionandIdempotency-Keyheaders), plusGET /.well-known/acp.json. Delegate payment is advertised only when a PSP delegation adapter is configured. Feed API is out of scope. - MCP: Dual-era tool server — modern
2026-07-28(server/discover, per-request version meta) plus legacyinitializefor2024-11-05/2025-11-25. Discovery advertisesorchestrator.mcp_endpointand supported versions. Full contract: MCP binding.
Conformance is asserted by CI (discovery, A2A, AP2, ACP, and MCP tests). Target protocol versions and required/optional items are in the conformance matrix.
License
Dual-licensed under MIT or Apache-2.0. See LICENSE-MIT and LICENSE-APACHE.