FastAPI based implementation of Universal Commerce Protocol
Project description
FastUCP ⚡️
The "FastAPI" for the Universal Commerce Protocol (UCP).
FastUCP is a high-performance, developer-friendly Python framework for building UCP-compliant Merchant Servers and Commerce Agents. It combines the strict compliance of Google's Official UCP SDK models with the intuitive developer experience of FastAPI.
🌟 Why FastUCP?
The Universal Commerce Protocol involves complex JSON schemas, rigorous validation rules, and deep object nesting. FastUCP abstracts this complexity away.
- 🧱 Official Models: Built directly on top of Google's auto-generated Pydantic models for 100% protocol compliance.
- 🚀 Developer Experience: No more manual JSON construction. Use our
CheckoutBuilderto write business logic, not boilerplate. - 🔍 Auto-Discovery: Automatically generates the
/.well-known/ucpmanifest based on your registered endpoints. - 🔌 Facade Pattern: Access all complex UCP types from a single, clean import:
fastucp.types.
📦 Installation
Requires Python 3.10+
# Using pip
pip install fastucp
# Using uv (Recommended)
uv add fastucp
⚡️ Quick Start
Here is a minimal Merchant Server ("Hello World") that sells a single item. FastUCP handles the manifest generation, endpoint routing, and protocol headers automatically.
# main.py
from fastucp import FastUCP
from fastucp.shortcuts import CheckoutBuilder
from fastucp.types import CheckoutCreateRequest
# 1. Initialize the App
app = FastUCP(
title="Hello World Store",
base_url="http://127.0.0.1:8000"
)
@app.checkout("/checkout-sessions")
def create_session(payload: CheckoutCreateRequest):
cart = CheckoutBuilder(app, session_id="demo_session_1")
cart.add_item(
item_id="sku_1",
title="Hello World T-Shirt",
price=2000,
quantity=1,
img_url="https://placehold.co/400"
)
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 and UCP Compliant!
Manifest: http://127.0.0.1:8000/.well-known/ucp Checkout: http://127.0.0.1:8000/checkout-sessions
🧩 Key Features
- The Builder Pattern Instead of dealing with nested Pydantic models like LineItemResponse(totals=[TotalResponse(...)]), you simply use:
cart.add_item(..., price=500, quantity=2)
FastUCP handles the calculations and structure for you.
- Payment Presets Easily integrate supported payment handlers without digging into schema details:
from fastucp.presets import GooglePay
app.add_payment_handler(
GooglePay(merchant_id="123", gateway="stripe", ...)
)
- AI Agent Ready (MCP) FastUCP servers are designed to be easily consumed by LLM Agents (Claude, Gemini, OpenAI) via the Model Context Protocol (MCP), bridging the gap between traditional e-commerce and AI Agents.
📄 License This project is licensed under the Apache 2.0 License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fastucp_python-0.1.0.tar.gz.
File metadata
- Download URL: fastucp_python-0.1.0.tar.gz
- Upload date:
- Size: 28.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2a17c45dc3da15a33afbc3a26f7e10aeeadc6178b6ec8acc4a07ac9f66809bc3
|
|
| MD5 |
e526907a2d527b62c9b3c6cfe5ffa250
|
|
| BLAKE2b-256 |
e3603bad50d5296a33d1265812f2d52a9382889b3bd74d13d70b7b9566e54e48
|
File details
Details for the file fastucp_python-0.1.0-py3-none-any.whl.
File metadata
- Download URL: fastucp_python-0.1.0-py3-none-any.whl
- Upload date:
- Size: 95.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
128c273d47c04c885e38a3a3f7babfa32f74a7cb2162ae9c64beb15b48d87a49
|
|
| MD5 |
71fc49d9873f8afd2cb940421d64ae8c
|
|
| BLAKE2b-256 |
05ea423fc85cf0cc55941938ecf7282cbf06c4f61147d0266770006d00c1a469
|