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.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Safe Google Ads FastMCP Serveraudit my search campaign for wasted spend and suggest negative keywords"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
ο»Ώ# π‘οΈ 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, 38 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: Google Ads MCP
ποΈ 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" }
}
]
}π§° 38 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 |
| Campaign CPC ceilings stepped strictly by |
π₯ Groups & Keywords |
| Quality score audits, cross-campaign collision fixer. |
βοΈ RSA Ads & Facades |
| Smart Facade: Enforces 15 headlines & 4 descriptions, atomic rotation (pauses oldest ad atomically). |
π§© Google Assets |
| Price extensions, image assets, sitelinks, and performance labeling. |
π§Ή Negative Shields |
| E-commerce waste harvesting and multi-country negative keyword sets. |
π Analytics & GA4 |
| Keyword Planner discovery 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. | |
π Search Terms & GA4 Miner | Cross-referencing ad spend with GA4 on-site engagement to harvest negative keywords and eliminate budget leaks. |
π 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. Test in Official MCP Inspector
You can inspect schemas and test tools interactively without spending LLM tokens:
npx @modelcontextprotocol/inspector --web --config .mcp.json4. 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"
}
}
}π 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.
Google & Meta Ads management with 100+ tools. Audit, create, and optimize campaigns.
Open-source ad agent for LinkedIn Ads and Google Ads. Drafts campaigns, audiences and reports.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceProvides full Google Ads API v21 access with 40+ tools for creating, optimizing, and managing campaigns, ad groups, keywords, extensions, and bidding strategies through natural language commands.26MIT
- 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 gradedqualityBmaintenanceEnables 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.11 npmMIT
- AlicenseNot gradedqualityBmaintenanceComplete 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