Integrating UCP: Java & Spring Boot Starter
Enterprise commerce platforms overwhelmingly run on the JVM. To make existing Spring Boot storefronts and backend microservices immediately discoverable and operable by autonomous AI agents, we built UCP Java (dev.ucomprotocol:ucp-spring-boot-starter)—a Spring Boot 4 starter aligned with Universal Commerce Protocol specification 2026-08-25.
1. Adding the Spring Boot Starter
Published on Maven Central under dev.ucomprotocol:ucp-spring-boot-starter:0.2.0, the starter targets Java 17+ and Spring Boot 4.x (with 0.0.1 available for Spring Boot 3.x). Include spring-boot-starter-webmvc when you want automatic /.well-known/ucp HTTP discovery:
// build.gradle
dependencies {
implementation 'dev.ucomprotocol:ucp-spring-boot-starter:0.2.0'
implementation 'org.springframework.boot:spring-boot-starter-webmvc'
}
Or in Maven (pom.xml):
<dependency>
<groupId>dev.ucomprotocol</groupId>
<artifactId>ucp-spring-boot-starter</artifactId>
<version>0.2.0</version>
</dependency>
2. Unified Commerce SPI & Built-in Resilience
UCP Java decouples your business and agent-facing endpoints from vendor-specific APIs via the CommerceAdapter SPI and five capability sub-adapters—CatalogAdapter, CartAdapter, CheckoutAdapter, OrderAdapter, and CustomerAdapter—backed by clean POJOs (Product, Cart, Checkout, Order, and Customer).
Every registered CommerceAdapter bean is automatically decorated by ResilientCommerceAdapter with Resilience4j CircuitBreaker and Retry protection while preserving null capability semantics:
@Service
public class AgentCheckoutService {
private final CommerceAdapter commerceAdapter;
public AgentCheckoutService(CommerceAdapter commerceAdapter) {
this.commerceAdapter = commerceAdapter;
}
public Checkout purchaseSingleItem(String customerId, String productId, int qty) {
Cart cart = commerceAdapter.getCartAdapter().createCart(customerId);
cart = commerceAdapter.getCartAdapter().addToCart(cart.getId(), productId, qty);
Checkout session = commerceAdapter.getCheckoutAdapter().createCheckout(cart);
return commerceAdapter.getCheckoutAdapter().completeCheckout(session.getId());
}
}
3. Dynamic Discovery at /.well-known/ucp
When Spring Web MVC is present, UcpDiscoveryController automatically inspects your CommerceAdapter at runtime and exposes a UCP 2026-08-25 compliant discovery profile. Any sub-adapter that returns null is omitted from advertised capabilities, preventing AI agents from invoking unsupported operations.
Configure your advertised transport bindings in application.properties:
# Advertise REST, MCP, A2A, and Embedded OpenRPC transports
ucp.services.rest-endpoint=https://shop.example.com/ucp/v1
ucp.services.mcp-endpoint=https://shop.example.com/ucp/mcp
ucp.services.a2a-endpoint=https://shop.example.com/.well-known/agent-card.json
ucp.services.embedded-enabled=true
4. Testing Live with Any AI Agent
The repository ships with a complete, stateful reference storefront in examples/ucp-example implementing all 6 UCP capabilities (catalog.search, catalog.lookup, cart, checkout, order, and identity_linking) alongside a 16-tool MCP Streamable HTTP JSON-RPC server (/ucp/mcp), canonical REST endpoints (/ucp/v1/*), and an A2A Agent Card (/.well-known/agent-card.json).
# 1. Start the sample storefront locally on port 8082
./gradlew -p examples/ucp-example bootRun
# 2. Register the MCP server with Claude Code, Cursor, Gemini CLI, or Antigravity
claude mcp add --transport http ucp-store http://localhost:8082/ucp/mcp
Once connected, prompt any MCP or HTTP-capable AI agent in plain English:
- "Search the UCP store for coffee gear, create a cart for
cust-demo-01with a burr grinder and two ceramic espresso cup sets, complete checkout, and give me the confirmed order ID." - "Inspect
http://localhost:8082/.well-known/ucp, discover the merchant's capabilities and transport endpoints, and purchase a mechanical keyboard."
Next Steps
Explore the full User Guide, browse the API Reference and Javadocs at ucomprotocol.dev, or clone universal-commerce-protocol-java on GitHub to build your own UCP provider adapter.