Skip to main content

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.

Python License Status

🌟 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 CheckoutBuilder to write business logic, not boilerplate.
  • 🔍 Auto-Discovery: Automatically generates the /.well-known/ucp manifest 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-python

# Using uv (Recommended)
uv add fastucp-python

⚡️ 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

  1. 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.

  1. 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", ...)
)
  1. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastucp_python-0.1.1.tar.gz (28.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fastucp_python-0.1.1-py3-none-any.whl (96.5 kB view details)

Uploaded Python 3

File details

Details for the file fastucp_python-0.1.1.tar.gz.

File metadata

  • Download URL: fastucp_python-0.1.1.tar.gz
  • Upload date:
  • Size: 28.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.6

File hashes

Hashes for fastucp_python-0.1.1.tar.gz
Algorithm Hash digest
SHA256 6932e61f6d5909622343b19e9e23ff3e653313346f712cb71630872f191fcfb0
MD5 36851ff1f2a7aee8567e69a708191496
BLAKE2b-256 77341bff960cc0cd6e80739ca6487db6a378441bec469a062fefae880af8e5dd

See more details on using hashes here.

File details

Details for the file fastucp_python-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: fastucp_python-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 96.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.6

File hashes

Hashes for fastucp_python-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9f4fd3b88a533e5a5d89abb2f56fe2a6c5cd763639ed33fa6cb057697869bba4
MD5 46e106315943e0098bf33afe9ac00e73
BLAKE2b-256 510939ae832228f90a86eb51d415440c446af783bef6f23cd1dbbf4907821c68

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page