Cloudflare AI Security Lab

Lab Guide

This guide documents the Seven Hills demo currently deployed on revolutionary-century.dgcf.ovh. The first phase uses Workers AI directly. AI Gateway and MCP are intentionally reserved for later phases.

Architecture

Browser | | HTTPS GET / and POST /api/* v Cloudflare Custom Domain | v Revolutionary Century Worker |-- serves the storefront HTML |-- validates and handles API requests | v Workers AI binding (env.AI) | v @cf/meta/llama-3.3-70b-instruct-fp8-fast

The Worker is deployed in the David Demo Account 2 account. The Custom Domain routes all paths on this hostname to the Worker.

There is no browser-to-model connection. The browser calls the Worker, and the Worker calls Workers AI. This keeps the AI binding and the system prompt on the server side.

Frontend

The storefront is the recovered Seven Hills demo. It includes the product grid, cart drawer, product details, checkout preview, Sofia chat, and Concierge tab.

API endpoints

EndpointMethodPurpose
/api/healthGETBasic health check and endpoint inventory.
/api/chatPOSTSofia shopping assistant. Accepts a message and cart items, then calls Workers AI.
/api/conciergePOSTEnterprise Concierge flow. Accepts customer metadata and a shopping prompt.
/api/checkout-previewPOSTCalculates cart lines, shipping, discount display, VAT-inclusive total, and a demo preview ID.
/api/ai-gateway/statusGETReports whether the optional AI Gateway configuration is present.
/api/ai-gateway/probePOSTOptional diagnostic probes for cache, burst, and spend behavior.
/api/mcp/statusGETReports the optional MCP portal connection state.
/api/mcp/probePOSTOptional MCP diagnostics. Not required for the current deployment.

Chat request example

POST /api/chat Content-Type: application/json {"message":"What products do you have?","cart":[]}

The response contains response. Product IDs in square brackets are used by the frontend to render product cards.

Worker configuration

NameTypeCurrent use
AIWorkers AI bindingActive. Direct inference for Chat and Concierge.
AI_GATEWAY_URLOptional variable/secretNot configured in phase 1. Enables the later AI Gateway path.
MCP_SERVER_URLOptional variable/secretNot configured in phase 1. Enables the later MCP portal path.
MCP_CLIENT_IDOptional secretReserved for future AI Gateway Access or MCP authentication.
MCP_CLIENT_SECRETOptional secretReserved for future AI Gateway Access or MCP authentication.

Important: Workers AI is a server-side binding. The browser never receives credentials for Workers AI.

Next phases

AI Gateway

Set AI_GATEWAY_URL and the required Access credentials, then route the OpenAI-compatible request through the gateway. This adds centralized logging, caching, rate controls, and policy enforcement.

MCP

Set MCP_SERVER_URL and its client credentials. The existing bundle contains guarded tool-calling logic for inventory and operations data. MCP results are validated before being shown to the model or user.

Security hardening

Before using this outside the lab, replace the embedded challenge prompt and promotional value. A prompt is not a security boundary, and anything bundled into Worker code should be treated as recoverable by an authorized code reader.