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
Navigate to the Cloudflare Dashboard and select your account.
Go to Workers & Pages.

Click Create and choose Worker.

Click the Hello World button and deploy it.

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.
In the Cloudflare Dashboard, navigate to your Worker (the proxy worker you just created).
Go to Settings > Bindings.
Click Add binding and select Service binding.
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
Click Save.
Note: The variable name
MCPis used in the worker code on lines whereenv.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:
In the Cloudflare Dashboard, go to Workers & Pages.
Under Overview, select your Proxy Worker that you created in above steps.
Navigate to Settings > Domains & Routes.
Click Add Route.
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
Confirm that API traffic data (requests and responses) are captured on the Akto dashboard under the respective API collection.
Check logs of your Worker for any initialization or forwarding messages.
Go back to the Akto Dashboard.
Navigate to API Collections > Hostname.
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:
akto-guardrails-executor - Hosts ML container for security scanning (prompt injection, toxicity, PII, etc.)
akto-ingest-guardrails - Core validation and traffic ingestion worker
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 wranglerAuthenticated:
wrangler loginCloudflare 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:
Configure service bindings:
Choose guardrails mode:
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:
Go to Akto Dashboard
Navigate to Agentic Security β Agentic Collections β Hostname
Verify traffic is being captured
Check Agentic Guardrails for threat detections (if using blocked/async mode)
Mode Comparison
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:
Service Binding: Verify
AKTO_GUARDRAILS_EXECUTORservice name matches your deployed executor workerEnable 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:
MCP Service Binding (REQUIRED): Replace
<YOUR_MCP_SERVER_NAME>with your actual MCP server worker nameGuardrails Service Bindings (REQUIRED): Both should point to your
akto-ingest-guardrailsworkerGuardrails Mode (REQUIRED): Choose
"async"(monitor only) or"blocked"(block threats)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:
In-app
intercomsupport β message us inside the Akto dashboard and someone will reply.Join our discord channel for community support.
Contact
[email protected]for email support.Reach us here.
Last updated
Was this helpful?