### RTK Setup Screen Usage Examples Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/realtime/realtimekit/ui-kit/api-reference/angular/rtk-setup-screen.mdx Examples demonstrating how to use the rtk-setup-screen component with and without properties. ```APIDOC ## RTK Setup Screen Usage Examples ### Basic Usage ```html ``` ### With Properties ```html ``` ``` -------------------------------- ### Full Setup DNS Response Example Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/support/troubleshooting/general-troubleshooting/troubleshooting-crawl-errors.mdx Example output from `dig +short SOA` for a domain using a Full setup on Cloudflare, showing Cloudflare nameservers. ```text josh.ns.cloudflare.com. dns.cloudflare.com. 2013050901 10000 2400 604800 3600 ``` -------------------------------- ### Install Dependencies and Start Development Server Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/realtime/realtimekit/quickstart.mdx Installs Vite globally and starts the application using npm. Ensure you have Node.js and npm installed. ```bash npm i -g vite && npm run dev ``` -------------------------------- ### Keyless SSL Key Server Setup Example Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/ssl/keyless-ssl/configuration/public-dns.mdx This example demonstrates a placeholder for setting up your Keyless SSL key server. Replace the example hostname with your actual key server hostname. ```html ``` -------------------------------- ### Install dependencies and start dev server Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/agents/getting-started/quick-start.mdx After creating a new project with the agents starter template, install dependencies and run the development server. ```bash cd agents-starter npm install npm run dev ``` -------------------------------- ### CNAME Setup DNS Response Example Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/support/troubleshooting/general-troubleshooting/troubleshooting-crawl-errors.mdx Example output from `dig +short SOA` for a domain using a Partial (CNAME) setup on Cloudflare. ```text example.com.cdn.cloudflare.net. ``` -------------------------------- ### Start the Qwik development server Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/pages/framework-guides/deploy-a-qwik-site.mdx After setting up the project and installing dependencies, run this command to start the local development server for your Qwik application. ```bash npm start ``` -------------------------------- ### Create and Run Cloudflare Agents Starter Project Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/changelog/agents/2025-03-18-npm-i-agents.mdx Provides commands to quickly install and run the `agents-starter` project, a real-time chat application example. It also guides users to modify `src/server.ts` and `src/client.tsx` to understand and utilize the Agents SDK. ```sh # Install it $ npm create cloudflare@latest agents-starter -- --template="cloudflare/agents-starter" # Run it $ npm run start ``` -------------------------------- ### Install Flagship SDK and OpenFeature Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/flagship/get-started.mdx Install the necessary packages for using the Flagship SDK with OpenFeature. This is a prerequisite for the following examples. ```bash npm install @cloudflare/flagship @openfeature/server-sdk ``` ```bash yarn add @cloudflare/flagship @openfeature/server-sdk ``` ```bash pnpm add @cloudflare/flagship @openfeature/server-sdk ``` ```bash bun add @cloudflare/flagship @openfeature/server-sdk ``` -------------------------------- ### RTK Participant Setup Component Usage Examples Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/realtime/realtimekit/ui-kit/api-reference/angular/rtk-participant-setup.mdx Examples demonstrating how to use the rtk-participant-setup component with different configurations. ```APIDOC ## RTK Participant Setup Component Usage Examples ### Basic Usage This example shows the minimal implementation of the `rtk-participant-setup` component. ```html ``` ### With Properties This example demonstrates how to bind properties to the `rtk-participant-setup` component for customization. ```html ``` #### Description - The `[isPreview]` property is set to `true` to indicate a preview mode. - The `[nameTagPosition]` property is set to one of the allowed string literals to position the name tag. - The `[participant]` property is bound to a `participant` object, which should be defined in the component's TypeScript file. ``` -------------------------------- ### Start Development Server for Previewing Edits Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/style-guide/contributions.mdx After installing pnpm, run this command to start the local development server. A link will be provided in the terminal to preview your changes in the browser. ```bash pnpm run dev ``` -------------------------------- ### Run Sphinx Quickstart Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/pages/framework-guides/deploy-a-sphinx-site.mdx Initiate the Sphinx project setup process. You will be prompted to answer configuration questions. ```sh sphinx-quickstart ``` -------------------------------- ### Clone Python Worker Examples Repository Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/workers/languages/python/index.mdx Clone the `python-workers-examples` repository to explore various Python Worker templates and examples. Navigate into a specific example directory, such as `01-hello`, to get started. ```bash git clone https://github.com/cloudflare/python-workers-examples cd python-workers-examples/01-hello ``` -------------------------------- ### Install cloudflared on Debian/Ubuntu Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/partials/cloudflare-one/tunnel/locally-managed/create-local-tunnel.mdx Install cloudflared on Debian and Ubuntu systems using the apt package manager. This involves adding the Cloudflare repository and then installing the package. ```shell curl -fsSL https://pkg.cloudflare.com/cloudflared.repo | sudo tee /etc/apt/sources.list.d/cloudflared.list sudo apt-get update && sudo apt-get install cloudflared ``` -------------------------------- ### Implement Correct Configuration Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/partials/style-guide/strong-in-props.mdx This example demonstrates the recommended way to configure project settings. Ensure you follow this pattern for optimal results. ```html {props.do} ``` -------------------------------- ### Install Codex CLI Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/agent-setup/codex.mdx Install the Codex CLI using npm. This command is for macOS and Linux. For Windows, use WSL2. Refer to the Codex CLI setup guide for alternative installation methods. ```bash npm install -g @openai/codex ``` -------------------------------- ### Example Startup Script Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/sandbox/configuration/dockerfile.mdx This bash script demonstrates starting background services like a Node.js app and Redis, ensuring Redis is ready before proceeding. ```bash #!/bin/bash # Start your services in the background node /workspace/my-app.js & # Start additional services redis-server --daemonize yes until redis-cli ping; do sleep 1; done ``` -------------------------------- ### Start Container with Options Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/durable-objects/api/container.mdx The `start` method boots a container. It accepts an optional `options` object to configure environment variables, the entrypoint command, and internet access. This method does not wait for the container to be fully ready. ```javascript this.ctx.container.start({ env: { FOO: "bar", }, enableInternet: false, entrypoint: ["node", "server.js"], }); ``` -------------------------------- ### Install cloudflared on RHEL/CentOS/Fedora Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/partials/cloudflare-one/tunnel/locally-managed/create-local-tunnel.mdx Install cloudflared on RHEL-based systems using the yum package manager. This involves adding Cloudflare's repository, updating package lists, and then installing cloudflared. ```shell curl -fsSl https://pkg.cloudflare.com/cloudflared.repo | sudo tee /etc/yum.repos.d/cloudflared.repo sudo yum update && sudo yum install cloudflared ``` -------------------------------- ### Install node-postgres Driver Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/partials/hyperdrive/use-node-postgres-to-make-query.mdx Install the `node-postgres` driver and its TypeScript types if you are using TypeScript. Ensure you are using version `8.16.3` or higher for Hyperdrive compatibility. ```bash npm install pg@>8.16.3 ``` ```bash npm install --save-dev @types/pg ``` -------------------------------- ### Install cloudflared on Arch Linux Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/partials/cloudflare-one/tunnel/locally-managed/create-local-tunnel.mdx Install cloudflared on Arch Linux using the pacman package manager. The package is available in the official community repository. ```shell pacman -Syu cloudflared ``` -------------------------------- ### Install cloudflared on macOS Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/partials/cloudflare-one/tunnel/locally-managed/create-local-tunnel.mdx Install cloudflared on macOS using the Homebrew package manager. Alternatively, download the latest Darwin amd64 release directly from the downloads page. ```shell brew install cloudflared ``` -------------------------------- ### Sphinx Quickstart Configuration Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/pages/framework-guides/deploy-a-sphinx-site.mdx Example answers for the sphinx-quickstart prompts. 'Y' for separate source and build directories is recommended. ```sh Separate source and build directories (y/n) [n]: Y Project name: Author name(s): Project release []: Project language [en]: ``` -------------------------------- ### Install cloudflared on Windows Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/partials/cloudflare-one/tunnel/locally-managed/create-local-tunnel.mdx Download the cloudflared executable for Windows, rename it, and verify the installation by checking the version in PowerShell. Ensure the executable is in your system's PATH or run it from its directory. ```powershell PS C:\Users\Administrator\Downloads\cloudflared-stable-windows-amd64> .\cloudflared.exe --version ``` -------------------------------- ### Create a new Worker project with C3 Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/learning-paths/workers/get-started/first-worker.mdx Use this command to initiate a new Worker project. It prompts for package installation and guides through setup. ```bash npx @cloudflare/create-cloudflare@latest first-worker ``` -------------------------------- ### Create and restore sandbox backups Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/changelog/agents/2026-02-23-sandbox-backup-restore-api.mdx Demonstrates how to initialize a sandbox, perform setup tasks, create a backup, and restore it in a future session. ```ts const sandbox = getSandbox(env.Sandbox, "my-sandbox"); // Make non-trivial changes to the file system await sandbox.gitCheckout(endUserRepo, { targetDir: "/workspace" }); await sandbox.exec("npm install", { cwd: "/workspace" }); // Create a point-in-time backup of the directory const backup = await sandbox.createBackup({ dir: "/workspace" }); // Store the handle for later use await env.KV.put(`backup:${userId}`, JSON.stringify(backup)); // ... in a future session... // Restore instead of re-cloning and reinstalling await sandbox.restoreBackup(backup); ``` -------------------------------- ### Get and Start Container Instances Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/containers/platform-details/scaling-and-routing.mdx Manually get and start specific container instances using their unique IDs. Note that getting a container does not automatically start it. ```typescript // get and start two container instances const containerOne = getContainer( env.MY_CONTAINER, idOne, ).startAndWaitForPorts(); const containerTwo = getContainer( env.MY_CONTAINER, idTwo, ).startAndWaitForPorts(); ``` -------------------------------- ### Quick start example Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/agents/api-reference/schedule-tasks.mdx Demonstrates how to schedule tasks using different modes: delayed, specific time, and recurring cron. ```APIDOC ## Quick start ```ts import { Agent } from "agents"; export class ReminderAgent extends Agent { async onRequest(request: Request) { const url = new URL(request.url); // Schedule in 30 seconds await this.schedule(30, "sendReminder", { message: "Check your email", }); // Schedule at specific time await this.schedule(new Date("2025-02-01T09:00:00Z"), "sendReminder", { message: "Monthly report due", }); // Schedule recurring (every day at 8am) await this.schedule("0 8 * * *", "dailyDigest", { userId: url.searchParams.get("userId"), }); return new Response("Scheduled!"); } async sendReminder(payload: { message: string }) { console.log(`Reminder: ${payload.message}`); // Send notification, email, etc. } async dailyDigest(payload: { userId: string }) { console.log(`Sending daily digest to ${payload.userId}`); // Generate and send digest } } ``` ``` -------------------------------- ### Initialize lib.rs Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/workers/tutorials/generate-youtube-thumbnails-with-workers-and-images.mdx Initial setup for the Worker's main entry point. ```rs use worker::*; mod utils; #[event(fetch)] pub async fn main(req: Request, env: Env, _ctx: worker::Context) -> Result { // Optionally, get more helpful error messages written to the console in the case of a panic. utils::set_panic_hook(); let router = Router::new(); router .get("/", |_, _| Response::ok("Hello from Workers!")) .run(req, env) .await } ``` -------------------------------- ### Build cloudflared from source Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/partials/cloudflare-one/tunnel/locally-managed/create-local-tunnel.mdx Build the latest version of cloudflared from its source code repository on GitHub. This involves cloning the repository, navigating into the directory, and using make and go install commands. ```shell git clone https://github.com/cloudflare/cloudflared.git cd cloudflared make cloudflared go install github.com/cloudflare/cloudflared/cmd/cloudflared ``` ```shell mv /root/cloudflared/cloudflared /usr/bin/cloudflared ``` -------------------------------- ### Example GET Request Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/style-guide/api-content-strategy/guidelines-for-curl-commands.mdx Example of a GET request to fetch firewall rules. Ensure the ZONE_ID and CLOUDFLARE_API_TOKEN placeholders are correctly set. ```bash curl https://api.cloudflare.com/client/v4/zones/$ZONE_ID/firewall/rules \ --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" ``` -------------------------------- ### Full Cloudflare D1 Comments API Example with TypeScript Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/d1/tutorials/build-a-comments-api.mdx A complete example of a Cloudflare Worker application that implements a comments API using Hono and D1. It includes endpoints for getting and posting comments, along with CORS support and the necessary Hono setup. ```typescript import { Hono } from "hono"; import { cors } from "hono/cors"; type Bindings = { DB: D1Database; }; const app = new Hono<{ Bindings: Bindings }>(); app.use("/api/*", cors()); app.get("/api/posts/:slug/comments", async (c) => { const { slug } = c.req.param(); const { results } = await c.env.DB.prepare( "SELECT * FROM comments WHERE post_slug = ?" ) .bind(slug) .run(); return c.json(results); }); app.post("/api/posts/:slug/comments", async (c) => { const { slug } = c.req.param(); const { author, body } = await c.req.json<{ author: string; body: string; }>(); if (!author) return c.text("Missing author value for new comment", 400); if (!body) return c.text("Missing body value for new comment", 400); const { success } = await c.env.DB.prepare( "INSERT INTO comments (author, body, post_slug) VALUES (?, ?, ?)" ) .bind(author, body, slug) .run(); if (success) { c.status(201); return c.text("Created"); } else { c.status(500); return c.text("Something went wrong"); } }); export default app; ``` -------------------------------- ### rtk-setup-screen with Properties Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/realtime/realtimekit/ui-kit/api-reference/angular/rtk-setup-screen.mdx This example demonstrates how to use the rtk-setup-screen component with specific properties like 'meeting' and 'size'. Ensure the 'meeting' object and 'size' are correctly bound. ```html ``` -------------------------------- ### Install Web Components Dependencies Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/partials/realtime/realtimekit/common/installation.mdx Install the required web packages or clone the starter template. ```bash npm i @cloudflare/realtimekit-web @cloudflare/realtimekit-ui ``` ```bash git clone https://github.com/cloudflare/realtimekit-web-examples.git cd realtimekit-web-examples/html-examples/examples/default-meeting-ui ``` -------------------------------- ### Start Local Development Server Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/workers/framework-guides/web-apps/more-web-frameworks/angular.mdx Run this command in your project directory to start a local server for previewing your project during development. ```bash npm run start ``` -------------------------------- ### Connect to Hyperdrive with Node.js Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/partials/hyperdrive/use-node-postgres-to-make-query.mdx Create a new `Client` instance from the `pg` library and pass your Hyperdrive `connectionString` from the environment variables. This example demonstrates connecting, performing a query, and handling potential errors. ```typescript // filepath: src/index.ts import { Client } from "pg"; export default { async fetch( request: Request, env: Env, ctx: ExecutionContext, ): Promise { // Create a new client instance for each request. Hyperdrive maintains the // underlying database connection pool, so creating a new client is fast. const client = new Client({ connectionString: env.HYPERDRIVE.connectionString, }); try { // Connect to the database await client.connect(); // Perform a simple query const result = await client.query("SELECT * FROM pg_tables"); return Response.json({ success: true, result: result.rows, }); } catch (error: any) { console.error("Database error:", error.message); return new Response("Internal error occurred", { status: 500 }); } }, }; ``` -------------------------------- ### Initialize Node.js Project Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/d1/tutorials/import-to-d1-with-rest-api.mdx Standard commands to create a new directory, navigate into it, and initialize a new Node.js project with npm. ```bash mkdir d1-import-tutorial cd d1-import-tutorial npm init -y ``` -------------------------------- ### Install and start HTTPD on Amazon Linux 2023 Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/ssl/origin-configuration/authenticated-origin-pull/aws-alb-integration.mdx Installs and starts the Apache HTTP Server (httpd) on an Amazon Linux 2023 instance. Ensure you have the necessary permissions to run these commands. ```bash sudo yum install -y httpd sudo systemctl start httpd ``` -------------------------------- ### Check Setup Screen Requirements Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/realtime/realtimekit/core/meeting-object-explained.mdx Determine if the setup screen should be displayed to the local user or if they should join the media room directly. ```kotlin meeting.localUser.shouldShowSetupScreen() // Check if setup screen should be shown ``` ```kotlin meeting.localUser.shouldJoinMediaRoom() // Check if local user should join media room ``` -------------------------------- ### Full Worker example using get() and getWithMetadata() Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/kv/api/read-key-value-pairs.mdx This example demonstrates reading single and multiple keys, with and without metadata, using `get()` and `getWithMetadata()`. It handles potential errors and formats the response. ```javascript export default { async fetch(request, env, ctx) { try { // Read single key, returns value or null const value = await env.NAMESPACE.get("first-key"); // Read multiple keys, returns Map of values const values = await env.NAMESPACE.get(["first-key", "second-key"]); // Read single key with metadata, returns value or null const valueWithMetadata = await env.NAMESPACE.getWithMetadata("first-key"); // Read multiple keys with metadata, returns Map of values const valuesWithMetadata = await env.NAMESPACE.getWithMetadata(["first-key", "second-key"]); return new Response({ value: value, values: Object.fromEntries(values), valueWithMetadata: valueWithMetadata, valuesWithMetadata: Object.fromEntries(valuesWithMetadata) }); } catch (e) { return new Response(e.message, { status: 500 }); } }, }; ``` -------------------------------- ### Navigate to the project directory Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/r2/api/workers/workers-api-usage.mdx Change into the newly created project directory to begin configuration. ```sh cd r2-worker ``` -------------------------------- ### Navigate to Project Directory Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/cloudflare-one/access-controls/ai-controls/secure-mcp-servers.mdx Change into the newly created project directory to begin configuration and deployment. ```sh cd mcp-server-cf-access ``` -------------------------------- ### Get specific custom provider response Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/ai-gateway/configuration/custom-providers.mdx Example JSON response structure for a successful get request. ```json { "success": true, "result": { "id": "550e8400-e29b-41d4-a716-446655440000", "account_id": "abc123def456", "account_tag": "my-account", "name": "My Custom Provider", "slug": "some-provider", "base_url": "https://api.myprovider.com", "description": "Custom AI provider for internal models", "enable": true, "beta": false, "logo": "Base64 encoded SVG logo", "link": "https://docs.myprovider.com", "curl_example": "curl -X POST https://api.myprovider.com/v1/chat ...", "js_example": "fetch('https://api.myprovider.com/v1/chat', {...})", "created_at": 1700000000, "modified_at": 1700000000 } } ``` -------------------------------- ### AppTheme Access and Setup Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/realtime/realtimekit/ui-kit/api-reference/ios/app-theme.mdx Demonstrates how to access the shared AppTheme instance and set up a custom theme. ```APIDOC ## AppTheme Singleton ### Description The application theme singleton that provides pre-configured appearance objects for UI components. ### Access Use `AppTheme.shared` to access the default appearances. ### Methods #### `setUp(theme: AppThemeProtocol)` - **Description**: Applies a custom theme conforming to `AppThemeProtocol`. - **Return Type**: `Void` ### Usage Examples #### Access default theme ```swift import RealtimeKitUI let theme = AppTheme.shared let titleAppearance = theme.meetingTitleAppearance let clockAppearance = theme.clockViewAppearance ``` #### Apply a custom theme ```swift import RealtimeKitUI class CustomTheme: AppThemeProtocol { // Implement required appearance properties } let customTheme = CustomTheme() AppTheme.shared.setUp(theme: customTheme) ``` ``` -------------------------------- ### Testing Durable Objects with Vitest Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/changelog/durable-objects/2025-12-15-rules-of-durable-objects.mdx This example demonstrates how to test Durable Objects using Vitest, including isolated storage, RPC method calls, and triggering alarms. It utilizes the `cloudflare:test` module for environment setup and execution. ```typescript import { env, runDurableObjectAlarm } from "cloudflare:test"; import { it, expect } from "vitest"; it("can test Durable Objects with isolated storage", async () => { const stub = env.COUNTER.getByName("test"); // Call RPC methods directly on the stub await stub.increment(); expect(await stub.getCount()).toBe(1); // Trigger alarms immediately without waiting await runDurableObjectAlarm(stub); }); ``` -------------------------------- ### Start local development server for Analog project Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/workers/framework-guides/web-apps/more-web-frameworks/analog.mdx Run this command in your project directory to start a local server for previewing your Analog application during development. ```bash npm run dev ``` -------------------------------- ### Sphinx Installation Output Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/pages/framework-guides/deploy-a-sphinx-site.mdx Example output indicating the successful installation of Sphinx and its dependencies, along with updates to Pipfile.lock. ```bash Installing sphinx... Adding sphinx to Pipfile's [packages]... ✔ Installation Succeeded Pipfile.lock not found, creating... Locking [dev-packages] dependencies... Locking [packages] dependencies... Building requirements... Resolving dependencies... ✔ Success! Updated Pipfile.lock (763aa3)! Installing dependencies from Pipfile.lock (763aa3)... 🐍 ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 0/0 — 00:00:00 To activate this project's virtualenv, run pipenv shell. Alternatively, run a command inside the virtualenv with pipenv run. ``` -------------------------------- ### Initialize and use x402Client in an Agent Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/agents/agentic-payments/x402/pay-from-agents-sdk.mdx This snippet demonstrates how to initialize the `x402Client` within an Agent's `onStart` method and use it to call tools. It shows how to establish an MCP connection, create an account from a private key, and wrap the MCP client with `withX402Client`. The `onToolCall` method illustrates how to invoke a tool, passing a payment confirmation callback or `null` for automatic payment. ```typescript import { Agent } from "agents"; import { withX402Client } from "agents/x402"; import { privateKeyToAccount } from "viem/accounts"; export class MyAgent extends Agent { // Your Agent definitions... await this.mcp.connect(`${this.env.WORKER_URL}/mcp`); const account = privateKeyToAccount(this.env.MY_PRIVATE_KEY); this.x402Client = withX402Client(this.mcp.mcpConnections[id].client, { network: "base-sepolia", account, }); } onPaymentRequired(paymentRequirements): Promise { // Your human-in-the-loop confirmation flow... } await this.x402Client.callTool(this.onPaymentRequired, { name: toolName, arguments: toolArgs, }); } } ``` -------------------------------- ### Install Cloudflare Vite Plugin and Wrangler Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/changelog/workers/2025-10-24-tanstack-start.mdx Installs the necessary packages for integrating the Cloudflare Vite plugin and Wrangler into an existing TanStack Start project. This is a prerequisite for migrating your project. ```bash npm install --save-dev @cloudflare/vite-plugin wrangler ``` -------------------------------- ### Initialize a new Hexo project Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/pages/framework-guides/deploy-a-hexo-site.mdx Create a new Hexo site and navigate into the project directory. This sets up the basic structure for your static site. ```sh hexo init my-hexo-site cd my-hexo-site ``` -------------------------------- ### Create a basic Agent with hello-world template Source: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/agents/guides/connect-mcp-client.mdx Use the `agents` CLI to create a new Agent project with the `hello-world` template. This sets up a minimal Agent structure. ```bash npm create cloudflare@latest my-mcp-client --template=cloudflare/ai/demos/hello-world ```