首页 AI Claude Code Guardrails for Google Ads (2026): Read-Only Mode, Permission Rules, Hooks and Human Approval

Claude Code Guardrails for Google Ads (2026): Read-Only Mode, Permission Rules, Hooks and Human Approval

Lock down Claude on Google Ads: read-only tools_config.yaml, permission rules, PreToolUse hooks, Agent SDK approval gates and quota limits.

Last updated: 16 November 2026. Google Ads API (v26.2), Anthropic and OpenAI documentation checked that day.

Letting an AI agent anywhere near an ad account with a credit line needs more than good prompts. The good news: Google’s open-source Google Ads MCP server was designed with safety in mind, and Claude Code adds its own permission system, hooks and an SDK approval callback. Stack them and you get an agent that is genuinely useful but cannot spend money on its own.

The seven layers

LayerWhere it livesWhat it stopsStrength
1 Account accessGoogle Ads user roles / manager accountClaude seeing accounts it should notHard
2 Cloud access levelGoogle Cloud project (Test / Explorer / …)Production calls from a test projectHard
3 Server tool settools_config.yaml namespacesWrite tools even being registeredHard
4 Client permissions.claude/settings.json allow / ask / denyUnapproved tool callsStrong
5 HooksPreToolUse command hookCalls outside a customer allowlist; adds audit logStrong
6 Propose & confirmBuilt into MCP write toolsCommitting anything not reviewedWorkflow
7 HumanMedia buyerSpend decisionsFinal
Seven guardrail layers for Claude on Google Ads

Layer 2: the Cloud project decides production access

Developer tokens were sunset on 9 September 2026. API access levels now belong to the Google Cloud project that owns your OAuth client or service account (Google’s FAQ). Enabling the API grants Test access, which only works on test accounts. Production needs Explorer (up to 2,880 operations per day on production accounts) or higher (access levels). A useful pattern: keep a separate Test-level project for development, so a mis-configured dev agent physically cannot touch live accounts.

Layer 3: switch write tools off at the server

The server reads a tools_config.yaml. When namespaces is non-empty, any category you leave out is disabled, and Google documents a strictly read-only setup by setting labels and assets to false. Point GOOGLE_ADS_MCP_TOOLS_CONFIG at your file:

# tools_config.yaml - strictly read-only deployment
# (point GOOGLE_ADS_MCP_TOOLS_CONFIG at this file)
namespaces:
  customers: true
  search: true
  metadata: true
  labels: false
  assets: false

Layer 4: Claude Code permission rules

Since v0.0.6 tools carry namespace prefixes, so the Claude Code names look like mcp__google-ads__search_search. Allow reads, ask for writes, deny what you never want (Claude Code permissions):

// .claude/settings.json - reads allowed, asset/label writes always asked
{
  "permissions": {
    "allow": [
      "mcp__google-ads__customers_list_accessible_customers",
      "mcp__google-ads__search_search",
      "mcp__google-ads__metadata_get_resource_metadata"
    ],
    "ask": [
      "mcp__google-ads__assets_create_asset",
      "mcp__google-ads__labels_manage_labels",
      "mcp__google-ads__labels_manage_label_associations"
    ],
    "deny": [
      "mcp__google-ads__assets_upload_video_asset"
    ]
  }
}

Layer 5: a PreToolUse hook as allowlist and audit log

Hooks run your own script before a tool call and can deny it (hooks reference). This one logs every Google Ads call and blocks any customer ID that is not on your allowlist:

// .claude/settings.json (excerpt) - log every Google Ads MCP call
{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "mcp__google-ads__.*",
        "hooks": [{ "type": "command", "command": ".claude/hooks/ads-audit.py" }]
      }
    ]
  }
}
#!/usr/bin/env python3
# .claude/hooks/ads-audit.py - append an audit line; block commits outside the allowlist
import json, sys, time
ALLOW = set(open(".claude/customer_allowlist.txt").read().split())
ev = json.load(sys.stdin)
inp = ev.get("tool_input", {})
with open(".claude/ads-audit.log", "a") as f:
    f.write(json.dumps({"t": time.time(), "tool": ev.get("tool_name"), "input": inp}) + "\n")
cid = str(inp.get("customer_id", ""))
if cid and cid not in ALLOW:
    print(json.dumps({"hookSpecificOutput": {
        "hookEventName": "PreToolUse",
        "permissionDecision": "deny",
        "permissionDecisionReason": f"customer {cid} is not on the allowlist"}}))
sys.exit(0)

Layer 6: approvals in your own app with the Agent SDK

If you embed Claude in an internal tool, the Agent SDK’s can_use_tool callback is your approval gate (Agent SDK Python reference). The example below lets reads and propose-mode calls through, but asks a human before any commit. Do not also list gated tools in allowed_tools, because pre-approved tools skip the callback.

# agent.py - Claude Agent SDK: Google Ads MCP with a human approval gate
import asyncio, os
from claude_agent_sdk import ClaudeSDKClient, ClaudeAgentOptions
from claude_agent_sdk.types import PermissionResultAllow, PermissionResultDeny

READ = {"mcp__google-ads__customers_list_accessible_customers",
        "mcp__google-ads__search_search",
        "mcp__google-ads__metadata_get_resource_metadata"}

async def gate(tool_name, tool_input, context):
    if tool_name in READ:
        return PermissionResultAllow(updated_input=tool_input)
    if tool_name.startswith("mcp__google-ads__") and tool_input.get("validate_only", True):
        return PermissionResultAllow(updated_input=tool_input)      # propose step only
    if tool_name.startswith("mcp__google-ads__"):
        print("\nCommit requested:", tool_name, tool_input)
        if input("Approve commit? [y/N] ").strip().lower() == "y":
            return PermissionResultAllow(updated_input=tool_input)
    return PermissionResultDeny(message="Not approved")

options = ClaudeAgentOptions(
    mcp_servers={"google-ads": {"type": "stdio", "command": "pipx",
                 "args": ["run", "--spec", "google-ads-mcp==0.0.6", "google-ads-mcp"],
                 "env": {"GOOGLE_CLOUD_PROJECT": os.environ["GOOGLE_CLOUD_PROJECT"]}}},
    can_use_tool=gate,          # do not also list gated tools in allowed_tools
    strict_mcp_config=True,
)

async def main():
    async with ClaudeSDKClient(options=options) as client:
        await client.query("For customer 1234567890, propose 4 callout assets from "
                           "brief.md. Show change_items, then wait for approval.")
        async for msg in client.receive_response():
            print(msg)

asyncio.run(main())

Pick the narrowest mode per team

ModeWho uses itTools enabledTypical prompt
Read-onlyAnalysts, daily reportscustomers, search, metadata“Why did CPC rise last week?”
AssetsCopywriters+ assets (ask), labels (ask)“Propose 6 callouts for the UK campaign”
Builder (API scripts)EngineersNo MCP writes; Claude writes code“Write a validate_only script for paused campaigns”
Three Claude operating modes for Google Ads

Analysts get read-only. Copywriters get assets with ask. Engineers get no MCP writes at all: Claude writes Google Ads API scripts that run validate_only first and create campaigns PAUSED (see Claude × Google Ads API 自動建立廣告活動(Python) and Codex + Google Ads API Python campaign pipeline).

Watch the quota

Requests rejected with a GoogleAdsFailure still count against the daily operation quota (quotas). Cap retries in your hooks or scripts, and prefer one well-formed GAQL query over many small ones.

How PandaWM uses Claude, Codex and Google Ads accounts to speed up client ad delivery

This guide focuses on Claude, but in day-to-day client work PandaWM combines Claude, Codex and Google Ads accounts to help companies going global move faster through the repetitive loop of account and conversion setup → campaign builds → ad copy and assets → reports and search terms → budget and negative-keyword changes, so media buyers spend their time on strategy, bidding judgement and creative.

  • Ad accounts: the client’s own Google Ads account, or one opened compliantly through PandaWM’s account-opening service. The account belongs to the client and is never rented or shared; multi-account access goes through the client’s own manager account.
  • Claude: natural-language reporting (GAQL) through Google’s open-source Google Ads MCP server, impression-share and search-term diagnosis, RSA headline/description and asset drafts, and asset or label creation in propose-and-confirm mode.
  • Codex: writing and maintaining google-ads Python scripts (daily reports, search-term clean-up, paused campaign builds, validate_only pre-checks) that run in a sandbox, on a schedule or in CI.
  • Human sign-off: a media buyer approves enabling campaigns, budget increases and bid-strategy changes, and a person makes the final call on Google Ads policy and landing-page compliance.

This describes a service capability only. There are no prices or rebates here, and PandaWM is not an official partner of Google, Anthropic or OpenAI. See Google Ads account opening & management (PandaWM service page) for account opening and management.

FAQ

Is the propose-and-confirm checksum enough on its own?

No. Google says it prevents accidental parameter drift but does not replace access control. Combine it with read-only namespaces and client permissions.

Can Claude enable or pause campaigns through MCP?

No. The server cannot create, modify, pause or enable campaigns, ad groups, ads, budgets or bids.

Where should credentials live?

In ADC files, a service account key held by your secret manager, or Cloud Run secrets, never in prompts, repos or chat. See our Claude API key guide for the Anthropic side.

What about prompt injection from landing pages or reports?

Treat fetched content as untrusted; read-only mode and hooks limit the blast radius. More in Prompt injection explained: enterprise defense.

Compliance note: Use every workflow in this guide only on Google Ads accounts (including client accounts under a manager account) that your company owns or is formally authorised to manage, through Google’s official Google Ads API, Google’s open-source Google Ads MCP server or official tools such as Google Ads Editor. Follow the Google Ads API Terms and Conditions, API quotas and Google Ads policies, and keep a human review step before anything that can spend money. PandaWM does not sell, rent, share or transfer ad accounts, manager accounts or API credentials, does not help anyone bypass ad review, regional restrictions, identity verification or payment controls, and is not an official partner of Google, Anthropic or OpenAI. Claude and OpenAI services are only offered in their supported countries and regions; the account holder should be an entity legitimately established and operating in a supported region.

Related guides

Talk to PandaWM: Google Ads accounts + AI-assisted delivery

Tell us where your company is registered, your industry, target countries, landing page and expected monthly budget, and which part you want to automate first (reporting, search terms, assets or campaign builds). We pre-check eligibility and landing pages, help you open your own Google Ads account compliantly, and wire Claude / Codex into your workflow.

WhatsApp: +852 5904 8602Telegram: @PANDA0134WeChat: szcwh99

PandaWM WeChat QR code szcwh99

Official sources

All official pages checked on 2026-11-16. API versions, tool names and permission requirements change; the official pages prevail.

本文来自网络,不代表熊猫出海立场。转载请注明出处: https://www.pandawm.com/blog/claude-code-google-ads-guardrails-read-only-approval-en.html
上一篇
下一篇

作者: 熊猫出海编辑团队

熊猫出海(PandaWM)编辑团队,来自香港出海服务商熊猫出海,专注 Facebook、TikTok、Google 等海外广告开户与代投,以及 GEO/AI 搜索优化、多语言独立站建设。有Facebook白名单牌照户、TikTok加白户、Google G2认证户等核心资源 。

为您推荐

发表回复

联系我们

联系我们

工作时间:周一至周五,9:00-17:30,节假日休息

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

关注微博
返回顶部