Moltworker on Cloudflare: The Ultimate Guide to Self-Hosted AI Agents

Cloudflare released a game-changer: Moltworker. It’s the new, seamless version of Moltbot that lets you run your own personal AI agents (Moltbot) directly on Cloudflare’s global network.

The best part? No more keeping a Mac Mini running in your closet just to host your AI.

In this guide, you can learn the live deployment of Moltworker. It’s a bit "fiddly" in places, but I’ve mapped out every step from billing to security so you don't get stuck.

Watch Video Guide Here:

Before You Start: The Prerequisites

You’ll need to sort your Cloudflare billing first. Even though there are generous free tiers, the deployment will fail without these plans active:

  • Workers Paid Plan: $5/month.
  • R2 Subscription: $0 (Free tier covers 1M operations, but must be "purchased").
  • Anthropic API Key: To power the actual AI logic.

Phase 1: The One-Click Deploy

Start by heading to the Moltworker GitHub repository and clicking the Deploy to Cloudflare button.

  1. Connect GitHub: Authorize Cloudflare to create a private repository for your bot.
  2. Configure R2: Create a new R2 bucket (this is your bot’s "brain" where it stores data).
  3. API Keys: * Paste your Anthropic API Key.
    • Generate a Gateway Token. This acts as your password. (Pro tip: Use openssl rand -hex 32 in your terminal to create a secure one).
  4. Deploy: Click "Create and Deploy."

Note: If you see an error saying "R2 not enabled," double-check that you actually added the $0 R2 subscription in your Cloudflare dashboard.

Phase 2: Setting Up the Security Layer (Cloudflare Access)

Since your AI has access to your data, you don't want the whole internet talking to it. We use Cloudflare Access to lock it down.

  1. Enable Workers Dev: In your Worker settings under "Domains & Routes," ensure workers.dev is enabled.
  2. Zero Trust Dashboard: Go to your Cloudflare Zero Trust settings and purchase the Free Plan ($0).
  3. Add Your Email: Create an Access Policy that only allows your specific email address to view the application.
  4. Set the Secrets: You need to tell the Worker how to validate your login. You’ll need to add two environment variables to your Worker:
    • CF_ACCESS_AUD: Found in your Access Application settings.
    • CF_ACCESS_TEAM_DOMAIN: Your unique Zero Trust team URL (e.g., your-team.cloudflareaccess.com).

Phase 3: Configuring Persistent Storage (R2)

To make sure your bot remembers conversations across sessions, you need to link the R2 bucket properly using API tokens.

  1. Create R2 Token: In the R2 dashboard, create a token with "Read & Write" permissions for your specific bucket.
  2. Add the "Big Three" Secrets: Back in your Worker settings, add these variables:
    • R2_ACCESS_KEY_ID
    • R2_SECRET_ACCESS_KEY
    • CF_ACCOUNT_ID (Found on your main Cloudflare sidebar).

Phase 4: Pairing and Testing

Once everything is deployed, navigate to your Worker URL with your gateway token attached: https://your-worker.workers.dev/?token=YOUR_TOKEN.

  • First Run: The container might take 1–2 minutes to start.
  • Pairing: You’ll need to approve your device in the Admin UI. This ensures that even if someone has your URL, they can't chat without your explicit approval.
  • The "Credit" Trap: If the bot isn't responding, check your Anthropic account. If you have $0 credits, the bot will stay silent without giving a clear error.

Conclusion: Is it Worth the Setup?

Moltworker is a massive step forward for privacy-conscious AI users. While the initial setup has some UX hurdles especially around Zero Trust and R2 tokens the result is a permanent, self-hosted AI agent that you own entirely.

Navigating the Friction:

  • Setup Time: ~30 minutes if you follow this guide.
  • Complexity: Moderate (requires some CLI and dashboard jumping).
  • Result: High-performance, secure AI that costs less than a Netflix subscription.

If you want us to build custom AI tools for you, let’s talk

Have a question? Get in touch below

"AZKY has developed an AI training platform for us. I have really enjoyed working with AZKY due to their clear communication and positive attitude to take on challenges"

Dr Jon Turvey

Founder @ Simflow AI, NHS Doctor, UK

AZKY doesn't just try to build whatever you ask them to. They take time to understand your business objectives and propose changes based on what we might actually need. This way, they quickly became an integral part of our business.

Lauri Lahi

CEO- Emerhub, RecruitGo

"...team went above and beyond to be solutions oriented when partnering with us on what was essentially our first attempt at no code development..."

Jenny Cox

The Combination Rule

Have a product idea?

We have probably built something similar before, let us help you