Table of contents

When you hand Codex a task to scaffold a Worker or write a DNS migration, you usually describe your Cloudflare setup in the prompt.
That description rarely matches the real account. The actual zone config, the existing DNS records, the KV namespaces, and the route bindings are details a summary skips.
So Codex generates a deploy script that assumes the wrong routes, a migration that misses records, or KV code that doesn't match the real namespace. The source of truth lives in your Cloudflare account, not in the few lines you wrote into the task.
To give Codex direct access to Cloudflare as it works through your coding tasks, we'll show you how to connect Cloudflare with Merge Agent Handler's Cloudflare MCP server.
Merge Agent Handler connects Codex to the Cloudflare API through the Merge CLI.
You install the CLI, authenticate once, and run a single setup command from your project root.
That command writes a Merge CLI section to your project's AGENTS.md file, which tells Codex when to call merge search-tools and merge execute-tool to reach Cloudflare.
Once connected, Merge handles API token storage and rotation on your behalf, so you never embed Cloudflare credentials in your repo or manage them per developer.
Related: How to use the Cloudflare MCP in Claude Code
Before getting started, you'll need the following:
pipx --version to confirm, or install via pip install pipx)If you want to connect Merge Agent Handler's Cloudflare MCP with internal or customer-facing agentic products, you can follow the steps in our docs.
Install the Merge CLI with pipx: pipx install merge-api
Verify the install: merge --version
Run the following to authenticate the CLI with your Merge Agent Handler account: merge login
This links the CLI to your Merge account and stores your session credentials locally.
From the root of the project where you want Codex to reach Cloudflare, run:
This writes a Merge CLI section to your project's AGENTS.md file so Codex knows to use the CLI when a task needs Cloudflare data. The command is idempotent, safe to re-run if you need to reset the configuration.
Commit the updated AGENTS.md so the configuration travels with the repo.
Related: A guide to integrating the Cloudflare MCP with Cursor
Create a Codex task that needs live Cloudflare data, for example: "Read the DNS records and route bindings for my primary zone, then scaffold a migration script that recreates them in a new zone and flags any proxied records."
The first time Codex invokes a Cloudflare tool, a Magic Link will appear to complete connector authentication.

Once authenticated, Codex can reach your Cloudflare account through Merge for every later task in this project.
{{this-blog-only-cta}}
In case you have more questions on setting up and using the Cloudflare MCP with Codex, we've addressed several more commonly-asked questions below.
With Cloudflare connected, Codex can:
You can build your own MCP server on top of the Cloudflare API. For one developer on one account, it's workable: create an API token, write the server, and wire it into Codex.
It gets harder once more than one person uses it or tasks run in CI. Each connected developer needs their own Cloudflare token, scoped correctly, with rotation handled, and there's no central record of what agents touched.
A self-hosted server doesn't solve that, since you still own the token management, the server, and the access scoping yourself. With no central audit log, a Codex task can read or change production infrastructure with no record of what happened.
Merge Agent Handler handles credential storage and rotation across every connected user. You can scope exactly which Cloudflare operations a Codex task can call, and every call is logged with identity, timestamp, and inputs.
For an agent that can modify DNS, Workers, and firewall rules on production traffic, scoped access plus full audit logging is the foundation you want in place first.
Cloudflare holds the zone config, DNS records, and KV state that edge-infrastructure code has to match exactly.
Codex tasks that scaffold Workers, write migrations, or generate monitoring need that ground truth to produce code that works against the real account.
The alternative is describing your setup in the prompt, and those descriptions are always incomplete. A missed proxied record, an assumed route, or a wrong namespace is enough to make Codex generate code that breaks against live infrastructure.
Connecting Cloudflare lets Codex read the actual resources when a task needs them.
Yes, Merge for Workforce is built to help engineering organizations provision, secure, and govern how employees connect AI tools like Codex to operational tools like Cloudflare.
Common patterns include:
Taken together, employees can use the Cloudflare MCP to scaffold Workers against real zone config, generate migrations grounded in actual DNS records, build monitoring tied to real analytics, and more, while IT keeps centralized control over which zones each agent can reach.
Use Merge Agent Handler’s 150+ connectors (including Cloudflare) to power reliable, secure, and powerful agents.