How to limit an AI agent to specific domains, campaigns, sites and repositories
An API token or a Google sign-in usually reaches far more than one job needs: every zone in a Cloudflare account, every campaign in an ad account, every site in Search Console. Forbidden Rules let a workspace say "only these" — or "never these" — about domains, campaign ids, Search Console sites and GitHub repositories, for chosen platforms and chosen callers such as MCP keys. You write the rule in plain words, test it, then turn it on.
Why the access you granted is usually too wide
Platform permissions are built around accounts, not jobs. A Cloudflare token for one domain is often created for the whole account because that is faster; a Google sign-in reaches every property its user can see. An agent working on one client's site, or a coding assistant connected over MCP for one repository, then has access to everything else too.
There are two layers to narrow it. The first is the platform itself: limit a Cloudflare token to some zones, share only some properties with a user. The second is a Forbidden Rule in Agent Planners, which sits in front of every call whatever the token allows and can be different for different callers.
What a rule can name
| Platform | Resource | Example |
|---|---|---|
| Cloudflare | Domains (zones) — a domain covers its subdomains | example.com |
| Google Ads | Campaign ids (and ad group or ad ids) | a campaign id from the account |
| Search Console | Sites | https://www.example.com/ or sc-domain:example.com |
| GitHub | Repositories | owner/name |
Allow ONLY these, or Stop these
- Allow ONLY these: a call that touches anything outside the list is stopped — and so is a call that names no resource at all, because it cannot be shown to stay inside. An "only" list is tied to its platform, so other platforms are not affected.
- Stop these: only calls that touch a listed resource are stopped; everything else runs as before.
- Actions still apply: a rule that covers Make changes and Delete leaves reading open; add Read to stop reads too.
- Who: a rule can be limited to API keys and connected apps (what people mean by "MCP"), to schedules and loops, or to roles — so a team can work freely in the app while an external agent is kept to one domain.
Write it in plain words
- 1Open Forbidden Rules in the side nav and choose Describe it in words.
- 2Write the limit as you would say it: "MCP can only manage example.com on Cloudflare", "API keys may only change campaign 1234567890 in Google Ads", "the coding agent may only touch acme/website on GitHub".
- 3Review the draft: the platform, the accounts, Who (API keys and connected apps for "MCP"), the actions, and Domains & resources with Allow ONLY these and your list. The draft maps your words onto your real connections and saves nothing.
- 4Use Test this rule: it simulates a call against the form and says what would be blocked and why — for example that other.com is outside the allowed list.
- 5Save the rule. It is saved off; turn it on from the list.
What a refusal looks like
A blocked call sends nothing to the platform. It answers with the rule's name and the reason, for example "… is not allowed here — other.com is outside the allowed list (example.com)", and the agent reports it instead of trying another way. The same check runs in the app, on schedules, over MCP and the REST API, on raw API requests and on queued writes when a person approves them. Each rule shows how many calls it blocked in the last 7 days.
Tested end to end
- A rule drafted from "MCP can only manage <domain> on Cloudflare" was saved with its zone id looked up for real, then exercised through the same path an MCP client uses, against the real Cloudflare API.
- Refused: a DNS record on another domain (by name, and by zone id through the write gateway), a zone setting on another domain, a Worker deploy and a raw request to another zone.
- Allowed: a record on the allowed domain, created and deleted again, and reads, which the rule did not cover.
Limits to know
- A resource rule matches the resources a call names in the places it knows — domains and zone ids, campaign and ad ids, sites, repositories. With Allow ONLY these, a call it cannot place is stopped rather than allowed.
- A rule turned on reaches every server within about 20 seconds.
- A rule is a limit on top of the platform's own permissions, never a way to add one: the agent can still do no more than the token or sign-in allows.
Frequently asked questions
- Can I stop an AI agent from touching other domains on Cloudflare?
- Yes. A Forbidden Rule on Cloudflare with Allow ONLY these and your domains stops any call outside them — and any call that names no domain — before it is sent.
- Can I limit only MCP clients and leave my team free?
- Yes. Limit the rule's Who to API keys and connected apps; people working in the app are not affected.
- Does a domain rule also cover subdomains?
- Yes. example.com covers www.example.com and shop.example.com.
- Which resources can a rule name besides domains?
- Google Ads campaign, ad group and ad ids, Search Console sites and GitHub repositories, among others the call carries in known places.