⚡ FastUCP Guide — Build UCP Servers in Python
Complete tutorial for building UCP-compliant merchant servers with FastUCP — the FastAPI-based Python framework for AI commerce.
What is FastUCP?
FastUCP is a Python framework that makes building UCP-compliant merchant servers simple. Built on top of FastAPI, it handles all the protocol complexity so you can focus on your business logic.
🧱 Official Models
Built on Google's auto-generated Pydantic models for 100% protocol compliance.
🔍 Auto-Discovery
Automatically generates /.well-known/ucp manifest from your endpoints.
🛒 Builder Pattern
Use CheckoutBuilder to construct responses without manual JSON wrangling.
💳 Payment Presets
Easy integration with Google Pay, Apple Pay, and other payment handlers.
When to Use FastUCP
FastUCP is best suited for Python developers building custom UCP merchant servers. Here's how it compares to other approaches:
| Approach | Best For | Language |
|---|---|---|
| FastUCP | Python developers building custom UCP servers from scratch | Python |
| UCP Proxy (Shopify) | Adding UCP to existing WooCommerce or Wix stores | Go |
| Shopify Native | Shopify store owners (built-in, no coding) | N/A |
| Official UCP Python SDK | Low-level Python integration using official Google models | Python |
You want a batteries-included Python framework with FastAPI routing, auto-discovery, builder patterns, and payment presets — without wiring up the protocol details manually.
Installation
FastUCP requires Python 3.10 or higher. Install via pip or uv:
# Using pip pip install fastucp-python # Using uv (Recommended) uv add fastucp-python
Quick Start
Here's a minimal UCP merchant server that sells a single item:
# main.py
from fastucp import FastUCP
from fastucp.builders import CheckoutBuilder
from fastucp.types import CheckoutCreateRequest
# 1. Initialize the App
app = FastUCP(
title="My Store",
base_url="http://localhost:8000"
)
# 2. Define checkout endpoint
@app.checkout("/checkout-sessions")
def create_session(payload: CheckoutCreateRequest):
cart = CheckoutBuilder(app, session_id="session_123")
cart.add_item(
item_id="sku_001",
title="AI Commerce T-Shirt",
price=2500, # $25.00 in cents
quantity=1,
img_url="https://example.com/shirt.jpg"
)
return cart.build()
if __name__ == "__main__":
import uvicorn
uvicorn.run(app, host="127.0.0.1", port=8000)Run the server:
python main.py
Your server is now live with these endpoints:
| Endpoint | Description |
|---|---|
GET /.well-known/ucp | Auto-generated UCP discovery manifest |
POST /checkout-sessions | Create new checkout session |
🔍 Test Your FastUCP Server
Once your server is running, validate it using UCP Tools to ensure full compliance:
Validate Your FastUCP Server
Enter your server URL to check AI commerce readiness and UCP compliance.
Open Validator →What We Check
- Discovery Profile: Is
/.well-known/ucpaccessible and valid? - Capabilities: Are checkout, order, and fulfillment capabilities declared?
- Service Bindings: Are REST/MCP endpoints properly configured?
- Payment Handlers: Are payment methods correctly specified?
- Schema Compliance: Does the profile match UCP specification?
Use ngrok or a similar tool to expose your local server for testing: ngrok http 8000
Adding Capabilities
FastUCP automatically registers capabilities when you use decorators:
# Checkout capability (auto-registered)
@app.checkout("/checkout-sessions")
def create_checkout(payload):
...
# Update checkout
@app.update_checkout("/checkout-sessions/{id}")
def update_checkout(id: str, payload):
...
# Complete checkout → Order capability (auto-registered)
@app.complete_checkout("/checkout-sessions/{id}/complete")
def complete_checkout(id: str, payload):
...Each decorator automatically adds the corresponding capability to your /.well-known/ucp manifest.
Payment Handlers
FastUCP includes presets for common payment methods:
from fastucp.presets import GooglePay
app.add_payment_handler(
GooglePay(
merchant_id="your_merchant_id",
gateway="stripe",
gateway_merchant_id="your_stripe_id"
)
)This automatically adds the payment handler to your discovery profile.
Validation Tips
Always set base_url in your FastUCP constructor. This is used to generate absolute URLs in the discovery profile.
In production, ensure base_url matches your actual domain with HTTPS.
Checklist for UCP Compliance
- ✅ Set correct
base_urlfor your environment - ✅ Define at least one checkout endpoint using
@app.checkout() - ✅ Add payment handlers if accepting payments
- ✅ Test with UCP Tools validator before going live
- ✅ Use AI Agent Simulator to verify agent compatibility
🤖 Test with AI Agent Simulator
UCP Tools includes an AI Agent Simulator that tests how AI shopping agents will interact with your FastUCP server. It simulates the full discovery and checkout flow.
Run AI Agent Simulation
Test how AI agents will discover and use your UCP endpoints.
Open AI Simulator →UCPtools + FastUCP Workflow
FastUCP and UCPtools are complementary tools that cover the full UCP development lifecycle:
- Build your merchant server with FastUCP (Python/FastAPI)
- Validate your UCP profile with UCPtools Validator — 4-level validation with 20+ error codes and fix hints
- Simulate AI agent interactions with the UCPtools AI Agent Simulator
- Monitor ongoing compliance with UCPtools Dashboard — automated daily checks and alerts
FastUCP handles the server-side implementation. UCPtools handles validation, testing, and ongoing monitoring. Together they cover the complete UCP development workflow — from first line of code to production monitoring.
FastUCP FAQ
FastUCP is an open-source Python framework built on FastAPI for creating UCP-compliant merchant servers. It auto-generates the /.well-known/ucp discovery manifest, provides a CheckoutBuilder for constructing checkout responses, and includes payment handler presets for Google Pay and Apple Pay. It uses Google's official auto-generated Pydantic models for 100% protocol compliance.
Install FastUCP with pip: "pip install fastucp-python" or with uv: "uv add fastucp-python". It requires Python 3.10 or higher. The package is available on PyPI as fastucp-python.
FastUCP is a Python framework for building UCP merchant servers — it creates the endpoints that AI agents connect to. UCPtools is a validation and testing toolkit — it checks whether your UCP implementation is correct and simulates how AI agents interact with it. They are complementary: build with FastUCP, then validate and test with UCPtools.
No. FastUCP is one option for Python developers. You can also implement UCP manually in any language, use the official UCP Python SDK, use platform-native support (Shopify has built-in UCP), or use the UCP Proxy by Shopify for WooCommerce and Wix stores. FastUCP simplifies the process for Python developers who want a FastAPI-based approach.
Use UCPtools to validate your FastUCP server. Run your server locally, expose it with ngrok (ngrok http 8000), then enter the ngrok URL in the UCPtools validator at ucptools.dev. UCPtools runs 4 levels of validation: structural, rules, network, and SDK compliance — and provides specific error codes with fix hints for any issues found.
FastUCP is currently in alpha (v0.1.x) with 11 GitHub stars as of February 2026. It is suitable for development and testing but should be evaluated carefully before production use. For production UCP implementations, consider Shopify's native UCP support or the official UCP Proxy by Shopify, which supports WooCommerce and Wix.
