A full-stack e-commerce checkout application demonstrating the integration of OpenAI Apps SDK with Model Context Protocol (MCP) servers. This project consists of a Python backend MCP server and a Node.js/TypeScript frontend UI application.
This application showcases how to build intelligent e-commerce experiences using:
- Model Context Protocol (MCP) β For LLM-server communication
- OpenAI Apps SDK β For rich UI components and widgets
- Conversational checkout β Natural language product search and purchase flow
checkout-sample-app/
βββ ch-openai-checkout-app/ # Backend MCP Server (Python)
βββ ch-openai-checkout-ui/ # Frontend UI Application (Node.js/TypeScript)
Language: Python
Framework: FastMCP + Uvicorn
Port: 8080
Description: A Python-based MCP server that implements e-commerce tools for:
- Product search and catalog browsing
- Shopping cart management (
add_to_cart, update quantities) - Checkout session creation
- Payment processing and order completion
The server maintains shopping cart state across conversation turns using _meta["widgetSessionId"] to keep the UI widget in sync with backend state.
Key Features:
- SSE (Server-Sent Events) endpoint for MCP protocol
- Structured JSON responses with embedded UI metadata
- Shopping cart state management
- Checkout session handling
Files:
shopping_cart_python/main.pyβ Main application entry pointshopping_cart_python/models.pyβ Data models for products, carts, and sessionsshopping_cart_python/requirements.txtβ Python dependenciesshopping_cart_python/Dockerfileβ Container configuration (Python 3.12)product_data.jsonβ Sample product catalogcheckout_session_data.jsonβ Checkout session templatescheckout_completion_data.jsonβ Order completion data
Language: TypeScript/React
Framework: Vite + Tailwind CSS
Port: 8088
Description: A modern web-based UI application that renders the shopping cart widget and interfaces with the Python MCP server. Built with Vite for fast development and production builds.
Key Features:
- Shopping cart widget with real-time state sync
- Responsive design using Tailwind CSS
- Dynamic widget rendering from OpenAI Apps SDK
- Product display and checkout interface
- Health check actuator endpoint
Files:
src/shopping-cart/β Shopping cart widget componentssrc/use-widget-state.tsβ State management hook for widgetssrc/use-openai-global.tsβ OpenAI SDK integrationvite.config.mtsβ Vite build configurationpackage.jsonβ Node.js dependenciespnpm-lock.yamlβ Dependency lock fileDockerfileβ Container configuration (Node 20 Alpine)
-
For Python Backend:
- Python 3.12+
- pip or poetry
- Docker (optional, for containerized setup)
-
For Node.js Frontend:
- Node.js 20+
- pnpm (recommended) or npm/yarn
- Docker (optional, for containerized setup)
Backend Setup (Python):
cd ch-openai-checkout-app
# Create virtual environment (optional but recommended)
python3.12 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r shopping_cart_python/requirements.txt
# Run the MCP server
python shopping_cart_python/main.py
# Server runs on http://localhost:8080Frontend Setup (Node.js):
cd ch-openai-checkout-ui
# Install dependencies
pnpm install
# or: npm install
# Development server (hot reload)
pnpm run dev
# or: npm run dev
# Accessible at http://localhost:8088
# Build for production
pnpm run build
# or: npm run build
# Preview production build
pnpm serveBuild Backend:
cd ch-openai-checkout-app
docker build -f shopping_cart_python/Dockerfile -t checkout-app-backend .
docker run -p 8080:8080 checkout-app-backendBuild Frontend:
cd ch-openai-checkout-ui
docker build -f Dockerfile -t checkout-app-ui .
docker run -p 8088:8088 checkout-app-ui- User Request β "I'd like to find a gift card"
- MCP Tool Call β
product_searchtool is triggered - Product Results β Search results returned with product catalog
- Add to Cart β User clicks add button in the shopping cart widget
- State Sync β Widget state updates via
_meta["widgetSessionId"] - Checkout β User clicks checkout to create a checkout session
- Payment β Card capture screen appears for tokenization
- Order Complete β Order confirmation is displayed
- Backend State: Cart maintained on the Python server
- Widget State: Synchronized via
window.openai.widgetState - Session Tracking:
widgetSessionIdkeeps widget and server aligned across conversation turns - Persistence: Checkout session ID enables multi-turn order tracking
GET /mcpβ Server-Sent Events (SSE) connection for MCP protocolPOST /mcp/messages?sessionId={sessionId}β Process MCP tool callsGET /actuator/healthβ Health check endpoint
/β Main shopping cart widget interface/actuator/healthβ Health check endpoint/assets/*β Static assets (CSS, JavaScript)
cd ch-openai-checkout-app
# Run with auto-reload
uvicorn shopping_cart_python.main:app --reload --host 0.0.0.0 --port 8080cd ch-openai-checkout-ui
# Start dev server with hot reload
pnpm run devWhen making changes to either service, follow conventions:
- Python: PEP 8 style guide, type hints recommended
- TypeScript: ESLint and Prettier configured, run
pnpm run lint
Backend (Python):
- FastMCP β MCP server framework
- Uvicorn β ASGI server
- Pydantic β Data validation
- Requests β HTTP client
Frontend (Node.js):
- React β UI framework
- TypeScript β Type safety
- Tailwind CSS β Utility-first CSS
- Vite β Build tool
- Pnpm β Package manager
APP_VERSION=1.0.0
HOST=0.0.0.0
PORT=8080VITE_API_URL=http://localhost:8088
VITE_PORT=8088Both services include Dockerfiles optimized for production:
- Backend:
python:3.12-slimβ Lightweight Python image - Frontend:
node:20-alpineβ Minimal Node.js image
For Kubernetes deployments, adapt the Docker images and expose services via Ingress.
MIT License β See LICENSE file for details
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
For issues, questions, or suggestions, please open a GitHub issue or contact the maintainers.