Safe Google Ads FastMCP Server
Provides tools for inspecting, optimizing, and managing Google Ads campaigns, ad groups, keywords, RSA ads, assets, negative keywords, and analytics with deterministic execution safeguards.
Provides tools for retrieving Google Cloud Logging logs and W3C distributed traces to monitor Google Ads API calls, latency breakdowns, and process health.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
π‘οΈ Safe Google Ads FastMCP Server
Enterprise-grade FastMCP server for the Google Ads API. Empowers autonomous AI agents (Claude Code, Antigravity, Cursor) to safely inspect, optimize, and manage live search campaigns with two-layer deterministic execution shields, 59 purpose-built tools, and W3C distributed tracing.
β‘ The Problem: Why Direct MCP Connection is a Hallucination
Most agent demos assume a naive architecture: LLM β Generic MCP β Production API.
In high-stakes enterprise domains like advertising, this pattern is dangerous:
Unbounded Financial Blast Radius: An unconstrained agent can step a bid by 5.00 EUR instead of 0.05 EUR, or mutate 5 campaigns simultaneously, burning monthly budgets in minutes.
Context Window Exhaustion: Exposing Google's 500+ raw gRPC methods bloats prompt context by 30,000+ tokens, inducing hallucinated arguments and non-deterministic tool picking.
The "AI Black Box" Fallacy: Over standard stdio transports, client-level OpenTelemetry context is dropped. When a tool call times out or fails, engineers have zero visibility into whether the delay came from local Python logic, DNS, or Google's upstream servers.
Googleβs official Google Ads MCP server is strictly read-only for this exact reason. To grant an autonomous agent write capabilities, you must insert an enforced deterministic boundary.
Related MCP server: mcp-google_ads
ποΈ High-Level Architecture
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β AI Agent Client (Claude Code / Antigravity / Cursor) β
βββββββββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
β 1. tools/call (JSON-RPC over stdio)
βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Safe Google Ads FastMCP Gateway Server (server.py) β
β β
β [ LAYER 1: Two-Layer Pydantic Execution Shield (shield/) ] β
β β’ Input boundary validation: Bounded bid ceilings (0.10 - 3.00 EUR) β
β β’ Fixed stepping increments (Β±0.05 EUR strictly enforced) β
β β’ Bad input is cut off early: returns REQUEST_REJECTED (0 API cost) β
β β
β [ PREFLIGHT GATEKEEPER (shield/preflight.py) ] β
β β’ Ad tools refuse execution until preflight_log_check passes β
β β’ Audits tool health, unlogged manual changes & process anomalies β
β β
β [ LAYER 2: W3C Distributed Tracing & gRPC Interceptor ] β
β β’ Generates autonomous session_id & W3C trace_id per execution β
β β’ Custom gRPC Client Interceptor captures upstream Google request_id β
β β’ Measures exact latency breakdown: Upstream API vs Local Code β
βββββββββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
β 2. Mutate / Query Stream (gRPC v24)
βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Google Ads API v24 (Google Cloud Infrastructure) β
β CampaignService β’ AdGroupService β’ AssetService β’ CriterionService β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββπ¬ Benchmark: Real-Time Latency & Tracing Breakdown
Below is a live distributed trace extracted via get_cloud_trace showing complete sub-millisecond execution observability for a single Smart Facade call (audit_campaign_4level_shield).
Notice how the single high-level tool coordinates 4 distinct upstream gRPC queries to Google Ads API while tracking exact network latency vs local execution overhead:
Parent Tool Span: tools/call audit_campaign_4level_shield [3378.7 ms]
βββ 1. GoogleAdsService/Search (Campaign Level) [1334.6 ms] ββββββββββββ
βββ 2. GoogleAdsService/Search (AdGroups & Bids) [ 375.4 ms] ββββ
βββ 3. GoogleAdsService/Search (RSAs & 15/4 Matrix) [ 838.0 ms] ββββββββ
βββ 4. GoogleAdsService/Search (Negative Keywords Shield) [ 397.3 ms] ββββSanitized Trace Payload (get_cloud_trace):
{
"trace_id": "a30661d140600f1b54cde6c3d1fc8cc1",
"total_ms": 3378.7,
"google_ads_api_calls": 4,
"google_ads_api_ms": 2945.3,
"own_code_ms": 433.4,
"latency_breakdown": {
"network_grpc_wait": "87.2%",
"local_fastmcp_shield": "12.8%"
},
"spans": [
{
"span_id": "9f42e8ddf09f0132",
"parent_span_id": null,
"name": "tools/call audit_campaign_4level_shield",
"duration_ms": 3378.7,
"labels": {
"tool": "audit_campaign_4level_shield",
"action_type": "READ",
"gcp.project_id": "safe-ads-prod",
"operator": "[REDACTED]",
"session_id": "20261019T141746Z-7acf",
"sla_status": "DEGRADED"
}
},
{
"span_id": "c13ea22dda5f6e88",
"parent_span_id": "9f42e8ddf09f0132",
"name": "GoogleAdsService/Search (Campaign Level)",
"duration_ms": 1334.6,
"labels": { "rpc.system": "grpc", "rpc.grpc.status_code": "0" }
},
{
"span_id": "ce45cd75502167c2",
"parent_span_id": "9f42e8ddf09f0132",
"name": "GoogleAdsService/Search (AdGroups & Bids)",
"duration_ms": 375.4,
"labels": { "rpc.system": "grpc", "rpc.grpc.status_code": "0" }
},
{
"span_id": "3aac0efda8cd5253",
"parent_span_id": "9f42e8ddf09f0132",
"name": "GoogleAdsService/Search (RSAs & 15/4 Matrix)",
"duration_ms": 838.0,
"labels": { "rpc.system": "grpc", "rpc.grpc.status_code": "0" }
},
{
"span_id": "47f195265a727044",
"parent_span_id": "9f42e8ddf09f0132",
"name": "GoogleAdsService/Search (Negative Keywords Shield)",
"duration_ms": 397.3,
"labels": { "rpc.system": "grpc", "rpc.grpc.status_code": "0" }
}
]
}π§° 59 Custom FastMCP Tools Catalog
The tools mirror Google Ads operational hierarchy, split into granular objects and transactional Smart Facades:
Operational Level | Key MCP Tools | Responsibilities |
π¦ Gate & Health |
| Mandatory pre-flight lock; anomaly & error spike audit. |
π’ Campaigns & Bids |
| Automated Search campaign creation with clean search networks, dayparting & criteria; CPC ceilings stepped strictly by |
π₯ Groups & Keywords |
| Hub & Spoke ad group deployment, positive exact/phrase keyword batches, cross-group collision fixer. Guarded status switch for a whole ad group (never the last enabled one, never a half-built one). |
βοΈ RSA Ads & Facades |
| Smart Facade: Enforces 15 headlines & 4 descriptions, Dynamic Keyword Insertion (DKI), in-place mutation via |
π§© Google Assets |
| Price extensions, Sitelinks, Callouts, Structured Snippets with Google approved headers, and asset performance labeling. Own-site images cropped to 1.91:1 / 1:1 and linked per ad group as |
π§Ή Negative Shields |
| E-commerce waste harvesting, multi-country negative keyword sets, and atomic shared negative list sync. |
π― Conversions & Tracking |
| Enhanced Conversions audit (Customer Data Terms, DMA compliance), Primary/Secondary goal steering for Smart Bidding, and hashed offline conversion upload. |
π³ Billing & Merchant Link |
| Official PDF invoices retrieval, Merchant Center product link audits, physical geo leakage discovery, and currency budget floors. Two-sided Shopping readiness (Ads + Merchant Center). |
π Analytics & GA4 |
| Keyword Planner discovery, Search Impression Share loss tracking, and spend vs GA4 dwell-time metrics. |
π Observability |
| Cloud Logging inspection, W3C trace breakdown, and process evals. |
π§ Autonomous Agent Skills & Playbooks (skills/)
While MCP tools provide the execution layer (the hands), these bundled Agent Skills provide the deterministic business playbook (the brain) for autonomous coding agents (Claude Code, Antigravity, Cursor):
Skill Name | SOP Path | Playbook Description |
π‘οΈ 4-Level Campaign Auditor | Standard procedure for running Preflight gate checks and diagnosing campaign quality scores (100/100). | |
πͺ Deterministic Bid Ladder | Stepping CPC bid ceilings strictly by | |
βοΈ 15/4 Golden RSA Writer | Enforces 15 headlines, 4 descriptions, Dynamic Keyword Insertion (DKI) pinned to Position 1, and atomic rotation. | |
π’ Hub & Spoke Ad Groups | Structuring consolidated Search campaigns into focused Hub & Spoke ad groups with dedicated category landings. | |
π― Conversion Tracking & Goals | Enhanced Conversions audit, steering Smart Bidding via Primary/Secondary goals, and offline conversion uploads. | |
π Search Terms & GA4 Miner | Cross-referencing ad spend with GA4 on-site engagement to harvest negative keywords and eliminate budget leaks. | |
π Shopping Campaigns | Feed-based Standard Shopping: readiness on both sides, deliberate product choice, dry run, creation always paused, verification. | |
πΌοΈ Image Assets | Own-site images per ad group: dry-run the crop, create once, link as | |
π Geo Targeting | Targeting overview, budget-leak audit, country on/off without ever leaving a campaign with no location. | |
ποΈ FastMCP Manager & Orchestrator | Master multi-level orchestrator: 5-stage lifecycle, 4 account invariants, tool extension protocol, and watchdog SOP rules. |
π Quickstart & Installation
1. Clone & Install
git clone https://github.com/Azhy34/safe-google-ads-mcp.git
cd safe-google-ads-mcp
pip install -r requirements.txt2. Configure Credentials (Zero-Leak)
Copy the template and provide your Google Ads developer tokens:
cp .env.example .env3. Set your business policy
The code carries no account, coupon, host or campaign name: those are data in a policy file (neutral defaults ship in config/policy.json).
Tools that need an identity or an allowed host refuse until you set it:
cp config/policy.json config/policy.local.json # git-ignored; edit it: accounts, URL rules, allowed hosts, ...See docs/POLICY.md for every key.
4. Test in Official MCP Inspector
You can inspect schemas and test tools interactively without spending LLM tokens:
npx @modelcontextprotocol/inspector --web --config .mcp.json5. Connect to Claude Code / Desktop
Add the server entry to your client configuration:
{
"mcpServers": {
"safe-google-ads-mcp": {
"command": "python",
"args": ["/path/to/safe-google-ads-mcp/server.py"],
"cwd": "/path/to/safe-google-ads-mcp"
}
}
}6. Run the offline test suite
python -m unittest discover -s testsThe suite uses a fictional advertiser (tests/policy_test.json) and never touches the network or your policy.
π’ Business Policy: one codebase, your rules
Everything that belongs to your business sits in config/policy.local.json (or the file named by MCP_POLICY_FILE): your
accounts, which hosts must carry a coupon and which must not, the words that never appear in your ads, the hosts your sitelinks
and images may use, your Shopping campaign prefix, the countries you deliver to. A rule broken in a request is refused by the
shield (REQUEST_REJECTED) before any call to Google. See docs/POLICY.md.
π Changelog
See CHANGELOG.md: 1.1.0 adds set_ad_group_status, set_campaign_location, create_image_asset,
create_shopping_campaign and check_shopping_readiness (59 tools), the policy layer and three skills.
π Live SDLC Orchestration in Jira
This framework was designed, decomposed, and built autonomously using our open-source Jira Cloud engine (jira-cloud-automation-shield):
Public Jira Epic:
[KAN-30] Safe Google Ads FastMCP Shield & Distributed Tracing FrameworkLive Kanban Board: Atlassian Cloud Kanban Board
Automated Audit Comments: Every task transition across
To DoβIn ProgressβDoneis stamped with correlationtrace_id.
π License
MIT License. Created by Mykhail Azhyshchev.
This server cannot be deployed
Maintenance
Related MCP Connectors
Upfixe is the autonomous PPC engine built for AI agents. With Upfixe's Model Context Protocol (MCP) server, your AI assistant can research keywords, draft responsive search ads, structure ad groups, publish campaigns, and pull cross-network analytics across both Google Ads and Microsoft Advertising (Bing Ads). Features enterprise-grade token encryption (AES-256-GCM) and strict safety guardrails (auto-paused deployments, daily budget caps, O&O syndication filters).
Run Google Ads and Meta Ads from ChatGPT or Claude: audit wasted spend, create and manage campaigns.
Manage Google Ads, Microsoft Ads and ChatGPT Ads safely: previewed, logged, revertible changes.
Hosted Google Ads MCP for Claude and ChatGPT. Preview every write. No developer token.
Related MCP Servers
- FlicenseAqualityDmaintenanceEnables AI agents to manage Google Ads campaigns (Search and UAC) through natural language, with read tools always available and guarded write operations for budgets, campaigns, ad groups, and keywords.3-
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to manage and analyze Google Ads campaigns through tools for listing campaigns, retrieving settings, performance metrics, ad groups, and running custom GAQL queries.454 npmMIT
- AlicenseNot gradedqualityCmaintenanceComplete Google Ads API v21 MCP server with 40+ fully implemented tools for campaign, ad group, keyword, extension, and portfolio bidding management, enabling AI assistants to create, optimize, and manage Google Ads campaigns through natural language commands.MIT

Marvento Ads MCPofficial
AlicenseBqualityBmaintenanceEnables AI agents to build and run Google Ads campaigns with write tools for campaigns, ad groups, ads, and assets, plus one-command VPS deployment for remote access.23Apache 2.0