Connect Akto with Cloudflare Worker Proxy

Cloudflare is a global network security platform that provides CDN, DDoS protection, and API security services. Integrating Cloudflare with Akto enables automatic discovery of all APIs passing through your Cloudflare infrastructure, helping you maintain continuous visibility and protection of your edge-distributed APIs.

Deployment Options

Choose the deployment approach that fits your needs:

Option 1: Simple Traffic Mirroring (Basic Setup)

Use this if you:

  • Want to start quickly with minimal setup

  • Only need API discovery and monitoring

  • Don't need MCP-specific security features

  • Have a single worker to proxy

What you get:

  • Automatic API discovery

  • Request/response logging

  • Traffic monitoring in Akto dashboard

Setup: Follow Simple Traffic Mirroring Setup below.


Option 2: MCP Guardrails with Proxy (Advanced Security)

Use this if you:

  • Need to protect MCP (Model Context Protocol) servers

  • Want real-time threat detection and blocking

What you get:

  • Everything from Option 1, plus:

  • Real-time MCP security guardrails

  • Two operational modes: Async (monitoring) or Blocked (active protection)

Setup: Follow MCP Guardrails Proxy Setup below.


Simple Traffic Mirroring Setup

This is a basic setup that mirrors traffic from one Cloudflare Worker to Akto for API discovery and monitoring.

Important Note: This configuration works for proxying traffic to one worker only. The worker must have a service binding configured in the Cloudflare Worker Proxy with the variable name MCP. This binding is used to forward all incoming requests to your target worker.

Step 1: Deploy the Akto Data-Ingestion Service

Before configuring the Cloudflare Worker Traffic Connector, you need to deploy the Akto Data-Ingestion Service. Ensure that the service is running and accessible via a publicly available URL. Set up and configure Akto Traffic Processor. The steps are mentioned here. Ensure this instance is publicly accessible, as it will receive traffic logs from your Cloudflare Worker.


Step 2: Set Up Your Cloudflare Worker Script

  1. Navigate to the Cloudflare Dashboard and select your account.

  2. Go to Workers & Pages.

  3. Click Create and choose Worker.

  4. Click the Hello World button and deploy it.

  5. Click Edit code and replace the default script with your Worker code that proxies traffic and mirrors it to Akto using service binding.

Important Notes while editing the Worker code

  • Replace <DATA_INGESTION_SERVICE> with the URL of the Akto Data-Ingestion Service you deployed in Step 1.

  • If you are using Cloudflare Service Binding to send traffic to your ingestion service hosted inside a Cloudflare container, use the following line instead of a public URL:


Step 3: Configure Service Binding (MCP)

After adding the worker code, you need to configure a service binding to connect this proxy worker to your target worker.

  1. In the Cloudflare Dashboard, navigate to your Worker (the proxy worker you just created).

  2. Go to Settings > Bindings.

  3. Click Add binding and select Service binding.

  4. Configure the binding with the following details:

    • Variable name: MCP (this must match the variable used in the worker code: env.MCP.fetch())

    • Service: Select the target worker you want to proxy traffic to

    • Environment: Choose the appropriate environment

  5. Click Save.

Note: The variable name MCP is used in the worker code on lines where env.MCP.fetch(request) is called. This service binding routes all incoming requests to your specified target worker while mirroring the traffic to Akto.


Step 4: Configure Worker Routing

If you'd like to route specific domains or paths through this Worker:

  1. In the Cloudflare Dashboard, go to Workers & Pages.

  2. Under Overview, select your Proxy Worker that you created in above steps.

  3. Navigate to Settings > Domains & Routes.

  4. Click Add Route.

  5. Select the appropriate zone (domain), and enter a route pattern such as:

This ensures all traffic matching the route is intercepted and mirrored to Akto.


Step 5: Verify the Setup

  1. Confirm that API traffic data (requests and responses) are captured on the Akto dashboard under the respective API collection.

  2. Check logs of your Worker for any initialization or forwarding messages.

  3. Go back to the Akto Dashboard.

  4. Navigate to API Collections > Hostname.

  5. You should start seeing the traffic from your Cloudflare Worker.


MCP Guardrails Proxy Setup

This advanced setup deploys a transparent proxy with MCP-specific security guardrails that can either monitor or actively block malicious traffic.

Architecture Overview

The MCP Guardrails Proxy consists of three workers:

Workers:

  1. akto-guardrails-executor - Hosts ML container for security scanning (prompt injection, toxicity, PII, etc.)

  2. akto-ingest-guardrails - Core validation and traffic ingestion worker

  3. akto-cloudflare-proxy - Transparent proxy with async/blocked modes


Prerequisites

  • Node.js 18+ and npm

  • Docker with buildx (for container images)

  • Cloudflare account with Workers enabled

  • Wrangler CLI: npm install -g wrangler

  • Authenticated: wrangler login

  • Cloudflare account ID (found in your dashboard)


Deployment Steps

IMPORTANT: Deploy workers in this exact order due to service binding dependencies.

Step 1: Deploy akto-guardrails-executor

Step 2: Deploy akto-ingest-guardrails

wrangler.jsonc configuration:

Step 3: Deploy akto-cloudflare-proxy

wrangler.jsonc configuration:

  1. Configure service bindings:

  1. Choose guardrails mode:

  1. Configure routes (optional):

Note: Routes are optional. If not configured, use the workers.dev URL for testing.


Modes: Async vs Blocked

Async Mode (Monitoring)

Behavior:

  • βœ… All traffic passes through to your MCP server

  • βœ… Threats are detected and reported to Akto dashboard

  • βœ… Zero impact on latency

  • ❌ Malicious requests are NOT blocked

Use Case: Production monitoring, threat intelligence gathering, compliance auditing

Log Example:


Blocked Mode (Active Protection)

Behavior:

  • βœ… Requests validated before reaching MCP server

  • βœ… Malicious requests blocked with JSON-RPC error response (HTTP 200)

  • βœ… Threats reported to Akto dashboard

  • βœ… Traffic data ingested to Akto

  • ⚠️ Fail-open: If validation times out, traffic is allowed

Use Case: High-security environments, preventing prompt injection, protecting sensitive tools

Log Example (Success):

Log Example (Blocked):

Blocked Response Format (JSON-RPC 2.0 compliant):


Verification

After deployment, verify everything is working:

Verify in Akto Dashboard:

  1. Navigate to Agentic Security β†’ Agentic Collections β†’ Hostname

  2. Verify traffic is being captured

  3. Check Agentic Guardrails for threat detections (if using blocked/async mode)


Mode Comparison

Feature
Async Mode
Blocked Mode

Traffic Monitoring

βœ…

βœ…

Threat Detection

βœ…

βœ…

Threat Blocking

❌

βœ…

Original Payload Reporting

βœ…

βœ…

Fail-Open

βœ… Yes

βœ… Yes


Updating Existing Deployments

If you already have akto-guardrails-executor deployed and want to update the proxy and ingest-guardrails workers with the latest code, follow these steps:

Step 1: Get Latest Code


Step 2: Update akto-ingest-guardrails Worker

Navigate to the worker directory and install dependencies:

Review and configure wrangler.jsonc:

Key configuration updates:

  1. Service Binding: Verify AKTO_GUARDRAILS_EXECUTOR service name matches your deployed executor worker

  2. Enable Guardrails: Ensure ENABLE_MCP_GUARDRAILS: "true"

Set secrets (if not already configured):

Deploy the updated worker:


Step 3: Update akto-cloudflare-proxy Worker

Navigate to the worker directory and install dependencies:

Review and configure wrangler.jsonc:

Key configuration updates:

  1. MCP Service Binding (REQUIRED): Replace <YOUR_MCP_SERVER_NAME> with your actual MCP server worker name

  2. Guardrails Service Bindings (REQUIRED): Both should point to your akto-ingest-guardrails worker

  3. Guardrails Mode (REQUIRED): Choose "async" (monitor only) or "blocked" (block threats)

  4. Routes (OPTIONAL): Configure if you want automatic domain routing, otherwise use workers.dev URL

Deploy the updated worker:


Get Support for your Akto setup

There are multiple ways to request support from Akto. We are 24X7 available on the following:

  1. In-app intercom support β€” message us inside the Akto dashboard and someone will reply.

  2. Join our discord channel for community support.

  3. Contact [email protected] for email support.

  4. Reach us here.

Last updated

Was this helpful?