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.

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.2.tar.gz (36.1 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.2-py3-none-any.whl (105.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fastucp_python-0.1.2.tar.gz
  • Upload date:
  • Size: 36.1 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.2.tar.gz
Algorithm Hash digest
SHA256 70d27f00777c9a29151953eb77be5bc6f904b6530aa7a5ad6cf35f79541457e1
MD5 7925f4c0810675be3590d43061e60c34
BLAKE2b-256 e1b8b401e4c93190bd31339f2a4643036ea71f016d8b0a39a0a5ee5e5684f89c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fastucp_python-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 105.4 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7fe140fc21e701d4ecaac5070759222acfaa62936555dca3bd8a9a328ef13542
MD5 68b9d3a89cc76a89ae96d64a517932ac
BLAKE2b-256 fc0fd83662a80bb5496df557dc656269ec10769db0f8acc0e186417c11ec6422

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