Metadata-Version: 2.4
Name: google-ads-mcp-server
Version: 0.2.0
Summary: Open-source Google Ads MCP server with audits, multi-currency reporting, and safety guardrails
Author: Fidel
License: MIT
Project-URL: Homepage, https://github.com/fidelp27/mcp-googleads
Project-URL: Repository, https://github.com/fidelp27/mcp-googleads
Project-URL: Issues, https://github.com/fidelp27/mcp-googleads/issues
Project-URL: Documentation, https://github.com/fidelp27/mcp-googleads#readme
Project-URL: Changelog, https://github.com/fidelp27/mcp-googleads/blob/main/CHANGELOG.md
Keywords: mcp,google ads,automation,analytics,reporting
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Internet :: WWW/HTTP :: Indexing/Search
Classifier: Topic :: Office/Business :: Financial
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: filelock>=3.12
Requires-Dist: google-auth>=2.25.2
Requires-Dist: google-auth-oauthlib>=1.2.1
Requires-Dist: mcp[cli]<2,>=1.12.0
Requires-Dist: pydantic>=2.0
Requires-Dist: python-dotenv>=1.0.0
Requires-Dist: requests>=2.31.0
Requires-Dist: tzdata>=2024.1; sys_platform == "win32"
Provides-Extra: remote
Requires-Dist: PyJWT[crypto]<3,>=2.10; extra == "remote"
Requires-Dist: cryptography>=42.0; extra == "remote"
Requires-Dist: httpx<1,>=0.27; extra == "remote"
Requires-Dist: starlette<1,>=0.27; extra == "remote"
Requires-Dist: uvicorn<1,>=0.31; extra == "remote"
Provides-Extra: dev
Requires-Dist: pytest>=8.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.23; extra == "dev"
Requires-Dist: setuptools>=61.0; extra == "dev"
Requires-Dist: wheel; extra == "dev"
Dynamic: license-file

# Google Ads MCP Server (`google-ads-mcp-server`)

> **Español:** Ver la [guía rápida y ejemplos por rol en español](docs/es/README.md) y la [guía de conexión](docs/connect.md).

An open-source, **read-only-by-default** **Model Context Protocol (MCP)** server for auditing, reporting, diagnosing, and safely managing Google Ads accounts from desktop and CLI AI apps (**Claude Desktop, Claude Code, Codex, Antigravity, Gemini CLI, Cherry Studio / Cline / Cursor / VS Code with DeepSeek, Kimi, OpenAI, Anthropic, or Gemini**).

Built to complement Google's official MCP server with **142 structured tools** (74 read/diagnostic/analytics tools + 68 opt-in guarded write/governance tools), **10 modular domains**, **5 one-word presets**, **editable Markdown + TOML analysis profiles**, **account-timezone & truncation-safe analytics**, **multi-currency & multi-MCC orchestration**, and **human-in-the-loop write guardrails**.

---

## Table of Contents

1. [What This MCP Does (Overview)](#what-this-mcp-does-overview)
2. [Quickstart in 30 Seconds (`--demo`)](#quickstart-in-30-seconds---demo)
3. [Connect Real Accounts (`connect` + `doctor` + `register`)](#connect-real-accounts-connect--doctor--register)
4. [Modular Tool Catalog & Presets (`--preset` / `--modules`)](#modular-tool-catalog--presets---preset----modules)
5. [Complete Functionality & Tool Reference (All 142 Tools)](#complete-functionality--tool-reference-all-142-tools)
   - [Core Module (25 tools — loaded by default)](#1-core-module-25-tools--loaded-by-default)
   - [Diagnostics Module (5 tools)](#2-diagnostics-module-5-tools)
   - [Measurement Module (8 tools)](#3-measurement-module-8-tools)
   - [Search Module (16 tools)](#4-search-module-16-tools)
   - [Performance Max Module (8 tools)](#5-performance-max-module-8-tools)
   - [Shopping Module (6 tools)](#6-shopping-module-6-tools)
   - [Display Module (5 tools)](#7-display-module-5-tools)
   - [Demand Gen Module (5 tools)](#8-demand-gen-module-5-tools)
   - [MCC & Agency Governance Read Module (11 tools)](#9-mcc--agency-governance-read-module-11-tools)
   - [Operations Module (68 guarded write & governance tools — opt-in only)](#10-operations-module-68-guarded-write--governance-tools--opt-in-only)
6. [MCP Prompts & Resources](#mcp-prompts--resources)
7. [Customizable Analysis Profiles (Markdown + TOML)](#customizable-analysis-profiles-markdown--toml)
8. [CLI Commands & Scheduled Alerts](#cli-commands--scheduled-alerts)
9. [Data Accuracy, Truncation & Safety Architecture](#data-accuracy-truncation--safety-architecture)
10. [Client Compatibility & Self-Hosted HTTP](#client-compatibility--self-hosted-http)
11. [Development & Documentation](#development--documentation)

---

## What This MCP Does (Overview)

- **Zero-credential `--demo` sandbox:** Test the full read/reporting/audit workflow in 30 seconds against two synthetic accounts (`1111111111` EUR ecommerce in `Europe/Madrid` + `2222222222` USD B2B Leads in `America/New_York`) before touching Google Cloud.
- **Guided desktop onboarding & preflight (`connect`, `register`, `doctor`, `serve`):** Browser OAuth flow, direct & multi-account/MCC scoping (`--all-mcc-clients`), preset persistence (`--preset`, `--modules`), and actionable diagnostics (`doctor` / `doctor --offline` / `doctor --json`) that separate credential errors, Cloud project access-level limits, permission issues, and zero-data test accounts.
- **Compact modular tool surface:** Default `core` exposes **25 focused tools** (strictly validated against a multi-AI JSON Schema linter with no untyped `dict[str, Any]` parameters) so tool calling stays accurate and low-token across Claude, OpenAI, Gemini, DeepSeek, and Kimi.
- **360° operational diagnostics:**
  - **Delivery & policy:** Combines account status, `billing_setup`, `account_budget`, campaign serving reasons, impression share losses, and ad/asset/keyword disapprovals into `confirmed_causes`, `hypotheses`, and `insufficient_data`.
  - **Budget pacing:** Month-to-date spend, 7-day vs. MTD run rate, end-of-month projection, remaining budget, and required daily spend in the account's time zone.
  - **Channel depth:** Search (terms, n-gram clusters, Quality Score 3-component breakdown, RSA Ad Strength, Keyword Planner, Experiments, Auction Insights API + EN/ES UI CSV fallback), Performance Max (asset groups, v25 asset `primary_status`/approvals, signals, listing filters, per-campaign search themes with explicit sampling coverage, placements), Shopping (SKU/brand/category/product-group ROAS & wasted spend), Display & Demand Gen (placements, mobile-app waste, video view rate & quartile funnel `p25/p50/p75/p100`).
- **Conversion & offline measurement audits:** Maps conversion ownership (account vs. MCC), account/campaign/custom goals (`conversion_goal_campaign_config`), secondary actions promoted into custom goals, Smart Bidding alignment, double-counting risks, Enhanced Conversions prerequisites, honest primary-vs-all measurement scope (never false-positive Consent Mode claims), offline upload health without PII, and **Data Manager API** upgrade eligibility.
- **Trustworthy reporting & multi-currency/multi-MCC accuracy:** Account-timezone closed days (`complete_days_only=True`), `queried_at_utc`, `conversion_lag_warning`, interaction-date vs. `conversions_by_conversion_date` time series, separated per-currency agency totals, dynamic per-account `login-customer-id` routing, row caps (`GOOGLE_ADS_MAX_SEARCH_ROWS`) with `truncated` / `totals_are_partial`, and automatic downgrade of absence-based alerts to `insufficient_data` when backing queries are truncated.
- **Guarded write engine (opt-in only):** When `READ_ONLY_MODE=true` (the default, and always enforced in managed desktop profiles), all 68 write tools in `operations` are **omitted from `tools/list`**. When explicitly enabled (`READ_ONLY_MODE=false`), mutations enforce mandatory `dry_run=true` (`validateOnly=true`) previews with diffs, exact confirmation phrases, economic caps, optimistic locking (`state_verifier`), partial retry for multi-account batches (`mcc_bulk_apply`), PII-redacted append-only audit logs, and `revert_operation`.

---

## Quickstart in 30 Seconds (`--demo`)

```bash
pip install google-ads-mcp-server
# or from a local checkout:
# pip install -e ".[dev]"

# Register zero-credential demo mode in your desktop AI client:
google-ads-mcp-server register --client claude-desktop --demo
# Optional: include domain modules via --preset (e.g. leads, ecommerce, agency, full):
google-ads-mcp-server register --client generic --demo --preset ecommerce
```

Or run directly over `stdio`:

```bash
google-ads-mcp-server --transport stdio --demo --preset ecommerce
```

Example prompts to try immediately in demo mode:
- *"List my accessible accounts and build a multi-currency agency dashboard."*
- *"Load the `leads-audit` analysis profile and audit account `2222222222`."*
- *"Diagnose delivery issues, budget pacing, and wasted search terms on account `1111111111`."*
- *"Run `get_pmax_diagnostics` and `get_shopping_performance` on account `1111111111`."*

---

## Connect Real Accounts (`connect` + `doctor` + `register`)

1. Enable **Google Ads API** in a Google Cloud project and download a **Desktop app** OAuth client JSON ([detailed setup guide](docs/connect.md)).
2. Authorize in your browser, select account(s) and optional preset/modules, and run `doctor`:

```bash
# Direct account with default compact catalog (`core`, 25 tools)
google-ads-mcp-server connect --client claude-desktop --customer 1234567890 --oauth-client /path/to/client_secret.json

# Direct account with ecommerce modules (PMax, Shopping, Measurement, Diagnostics)
google-ads-mcp-server connect --client codex --customer 1234567890 --preset ecommerce --oauth-client /path/to/client_secret.json

# MCC account scoping all enabled child accounts
google-ads-mcp-server connect --client antigravity --manager 9999999999 --all-mcc-clients --preset agency --oauth-client /path/to/client_secret.json

# Reuse the saved profile in another client
google-ads-mcp-server register --client gemini-cli --preset leads

# Verify credentials, API access, currency/timezone, and recent data
google-ads-mcp-server doctor
```

Supported `--client` targets: `claude-desktop`, `claude-code`, `codex`, `antigravity`, `gemini-cli`, `generic` (outputs standard `{"mcpServers": ...}` JSON for Cursor, VS Code, Cherry Studio, Cline, Kimi CLI, etc.).

Managed profiles **always** launch with `READ_ONLY_MODE=true` and scope access strictly to the authorized customer IDs (plus manager ID if configured).

### Manual Claude Desktop config (fallback)

If you prefer to edit `claude_desktop_config.json` by hand instead of using `connect` / `register`, open it from Claude Desktop → *Settings → Developer → Edit Config* and paste a block like this under `mcpServers` (edit paths and IDs):

**Windows**

```json
{
  "mcpServers": {
    "google-ads": {
      "command": "uvx",
      "args": ["google-ads-mcp-server", "--transport", "stdio", "--preset", "core"],
      "env": {
        "GOOGLE_ADS_AUTH_TYPE": "oauth",
        "GOOGLE_ADS_CLIENT_ID": "YOUR_OAUTH_CLIENT_ID",
        "GOOGLE_ADS_CLIENT_SECRET": "YOUR_OAUTH_CLIENT_SECRET",
        "GOOGLE_ADS_TOKEN_PATH": "C:\\Users\\YOU\\.google-ads\\token.json",
        "GOOGLE_ADS_DEVELOPER_TOKEN": "YOUR_DEVELOPER_TOKEN",
        "GOOGLE_ADS_LOGIN_CUSTOMER_ID": "1234567890",
        "ALLOWED_CUSTOMER_IDS": "1234567890,0987654321",
        "READ_ONLY_MODE": "true",
        "OPERATOR_NAME": "you"
      }
    }
  }
}
```

**macOS / Linux**

```json
{
  "mcpServers": {
    "google-ads": {
      "command": "uvx",
      "args": ["google-ads-mcp-server", "--transport", "stdio", "--preset", "core"],
      "env": {
        "GOOGLE_ADS_AUTH_TYPE": "oauth",
        "GOOGLE_ADS_CLIENT_ID": "YOUR_OAUTH_CLIENT_ID",
        "GOOGLE_ADS_CLIENT_SECRET": "YOUR_OAUTH_CLIENT_SECRET",
        "GOOGLE_ADS_TOKEN_PATH": "/Users/you/.google-ads/token.json",
        "GOOGLE_ADS_DEVELOPER_TOKEN": "YOUR_DEVELOPER_TOKEN",
        "GOOGLE_ADS_LOGIN_CUSTOMER_ID": "1234567890",
        "ALLOWED_CUSTOMER_IDS": "1234567890,0987654321",
        "READ_ONLY_MODE": "true",
        "OPERATOR_NAME": "you"
      }
    }
  }
}
```

`uvx` auto-installs the package on first run (requires [`uv`](https://docs.astral.sh/uv/)). If you prefer pipx: replace `"command": "uvx"` with `"command": "google-ads-mcp-server"` and drop `google-ads-mcp-server` from `args`, after `pipx install google-ads-mcp-server`.

**Zero-credential demo** (no Google Cloud project needed):

```json
{
  "mcpServers": {
    "google-ads-demo": {
      "command": "uvx",
      "args": ["google-ads-mcp-server", "--transport", "stdio", "--demo", "--preset", "ecommerce"]
    }
  }
}
```

After editing, fully quit and reopen Claude Desktop so it picks up the new server.

---

## Modular Tool Catalog & Presets (`--preset` / `--modules`)

Instead of overwhelming LLMs with all 142 tools at once, only `core` (**25 tools**) loads by default. Activate domain modules with `--preset` or `--modules` (in `connect`, `register`, `serve`, CLI flags, or `GOOGLE_ADS_PRESET` / `GOOGLE_ADS_MODULES`):

| Preset | Active Modules | Active Tools (Read-Only) | Best For |
| --- | --- | :---: | --- |
| `core` *(default)* | `core` | 25 | Account overview, GAQL, trends, reports, waste, alerts, analysis profiles |
| `leads` | `core, diagnostics, measurement, search` | 54 | Search lead-gen audits, conversions, delivery, pacing, keywords, RSAs |
| `ecommerce` | `core, diagnostics, measurement, pmax, shopping` | 47 | PMax asset groups & placements, Shopping SKU/brand ROAS, pacing, tracking |
| `agency` | `core, diagnostics, measurement, search, pmax, mcc` | 71 | Multi-account MCC operations, multi-currency dashboards, weekly reviews |
| `full` | All read modules (+ `operations` **only** if `READ_ONLY_MODE=false`) | 74 *(142 when writes enabled)* | Full power-user read or read+write surface |

Fine-grained selection example:

```bash
google-ads-mcp-server --transport stdio --modules core,diagnostics,measurement,pmax
```

> **Hard safety invariant:** While `READ_ONLY_MODE=true` (default), all **68 tools** in `operations` are **completely excluded from `tools/list`** even when `--preset full` is passed.

---

## Complete Functionality & Tool Reference (All 142 Tools)

### 1. `core` Module (25 tools — loaded by default)

Account discovery, safe GAQL, core campaign/ad/creative read, time-series trends, reports, waste detection, alerts, and customizable analysis profiles.

| Tool | What It Does |
| --- | --- |
| `server_status` | Reports server readiness, auth mode, API version, guardrail posture (`read_only_mode`, scoped accounts), and active tool catalog/modules. |
| `list_accounts` | Lists accessible Google Ads customer IDs (or synthetic accounts in `--demo` mode). |
| `get_account_currency` | Retrieves account currency code and metadata. |
| `list_resources` | Queries `googleAdsFieldService` to list available Google Ads API resources for GAQL discovery. |
| `execute_gaql_query` | Runs a read-only GAQL query via the core server endpoint (formatted summary output). |
| `run_gaql` | Runs a read-only GAQL query via the agency engine with bounded row protection and structured JSON output. |
| `get_campaign_performance` | Campaign metrics (impressions, clicks, CTR, CPC, cost, conversions, value, CPA) over configurable windows. |
| `get_ad_performance` | Ad-level performance across campaigns and ad groups. |
| `get_ad_creatives` | Reads RSA headlines, descriptions, paths, final URLs, and approval/ad strength fields. |
| `get_image_assets` | Lists image assets with dimensions, URLs, and metadata. |
| `download_image_asset` | Downloads an image asset locally for visual inspection or review. |
| `get_asset_usage` | Shows which campaigns/ad groups reference image and creative assets. |
| `analyze_image_assets` | Analyzes image asset dimensions, aspect ratios, and performance. |
| `get_budget_utilization` | Compares daily spend against configured campaign budgets to spot budget-capped or underspending campaigns. |
| `get_bidding_strategies` | Lists portfolio and campaign bidding strategies, targets, and campaign counts. |
| `get_change_history` | Reads Google Ads `change_event` history (who changed what resource and when) for troubleshooting. |
| `get_performance_trends` | Account or campaign time series (`total`, `daily`, or `weekly`) in the account's time zone with `conversions` (interaction date) alongside `conversions_by_conversion_date`, `conversion_lag_warning`, and `totals_are_partial`. |
| `compare_periods` | Compares two explicit (`YYYY-MM-DD:YYYY-MM-DD`) or preset (`week`, `month`, `quarter`) periods in the account's time zone with absolute and percentage deltas. |
| `generate_client_report` | Generates an executive client report (`json`, `markdown`, or `html`) with typed `ReportBranding`, period-over-period deltas, top campaigns/keywords, wasted search terms, optional recommendations, and truncation metadata. |
| `generate_agency_dashboard` | Consolidates performance across multiple accounts **strictly separated by currency** (`managed_totals_by_currency`), surfacing alerts, pending approvals, and per-client truncation flags. |
| `detect_waste` | Flags non-converting search terms, low-CTR keywords, non-converting ad groups, and budget-limited campaigns in the account's time zone with `totals_are_partial`. |
| `check_alerts` | Evaluates spend, CTR, CPA, and waste thresholds from `config/alerts.json` (`defaults` + per-account overrides). |
| `generate_optimization_plan` | Produces a prioritized, **non-executing** list of suggested `dry_run=true` MCP actions backed by account evidence. |
| `list_analysis_profiles` | Lists built-in and user-defined Markdown + TOML analysis profiles (`leads-audit`, `ecommerce-audit`, `agency-weekly`, plus custom profiles). |
| `get_analysis_profile` | Returns a profile's full Markdown instructions, effective TOML parameters/thresholds, reproducibility header, and security notice. |

---

### 2. `diagnostics` Module (5 tools)

Included in `leads`, `ecommerce`, `agency`, and `full` presets.

| Tool | What It Does |
| --- | --- |
| `diagnose_delivery` | 360° root-cause diagnosis for zero/dropped impressions: inspects account status, `billing_setup`, `account_budget`, campaign `primary_status`/`primary_status_reasons`, budget/rank impression share losses, and ad/asset/keyword policy disapprovals — separating findings into `confirmed_causes`, `hypotheses`, and `insufficient_data` (downgrading absence-based billing conclusions when `billing_setup` is truncated). |
| `get_budget_pacing` | Computes complete-day MTD spend in the account's time zone, 7-day vs. MTD daily run rate, projected end-of-month spend, remaining budget, required daily spend, and status (`on_track`, `underspending`, `overspending`) against an explicit target, TOML profile target, or inferred active daily budgets. |
| `get_landing_page_performance` | Landing page URL metrics (`landing_page_view`) including mobile-friendly click rate (`mobile_friendly_clicks_percentage`) and `speed_score`. |
| `get_demographics_performance` | Performance breakdowns by `age`, `gender`, `income`, `parental_status`, or `all`. |
| `get_assets_and_calls_performance` | Extension/asset metrics and policy approvals (`campaign_asset`) plus aggregate call metrics (`call_view`, zero PII). |

---

### 3. `measurement` Module (8 tools)

Included in `leads`, `ecommerce`, `agency`, and `full` presets.

| Tool | What It Does |
| --- | --- |
| `audit_conversion_tracking` | Unified conversion audit crossing `customer.conversion_tracking_setting` (MCC vs. account ownership, Customer Data Terms, EC4L), `conversion_action`, `customer_conversion_goal`, `campaign_conversion_goal`, `custom_conversion_goal`, `conversion_goal_campaign_config` (v25), campaign bidding strategies, and per-action volume. Flags MCC centralization, secondary actions inside custom goals, multiple primaries in the same category, and Smart Bidding alignment (degrading absence-based alerts to `insufficient_data` on truncation/optional-query failure). |
| `get_offline_conversion_diagnostics` | Inspects `offline_conversion_upload_client_summary` and `offline_conversion_upload_conversion_action_summary` (sent, accepted, pending, failed, error codes — **zero PII**), distinguishes API ingestion from ad attribution, and flags legacy upload integrations eligible for **Data Manager API** upgrade. |
| `get_conversion_actions` | Lists conversion actions with category, origin, type, attribution model, counting type, default value, and `primary_for_goal`. |
| `get_conversion_performance` | Conversion volume, value, and cost per conversion segmented by conversion action. |
| `get_enhanced_conversions_status` | Checks customer-level Enhanced Conversions for Leads and Customer Data Terms acceptance status. |
| `check_consent_signal_coverage` | Reports primary-vs-all conversion scope ratios (`conversions / all_conversions`) honestly as a measurement-scope metric (explicitly noting that Google Ads API does not expose per-event Consent Mode signals). |
| `get_customer_match_list_stats` | Reads CRM-based `user_list` membership status, size for Search/Display, match rate range, and eligibility. |
| `get_offline_user_data_job_status` | Tracks async `offline_user_data_job` status and failure reasons for Customer Match uploads. |

---

### 4. `search` Module (16 tools)

Included in `leads`, `agency`, and `full` presets.

| Tool | What It Does |
| --- | --- |
| `get_search_terms_report` | Search queries (`search_term_view`) with status (`ADDED`/`EXCLUDED`/`NONE`), spend, clicks, conversions, and value. |
| `get_keyword_performance` | Keyword metrics (`keyword_view`) with match type, Quality Score, and all **3 Quality Score subcomponents** (`creative_quality_score`, `post_click_quality_score`, `search_predicted_ctr`). |
| `get_impression_share_losses` | Campaign Search Impression Share, exact-match IS, and IS lost to budget vs. rank. |
| `get_ad_strength_diagnostics` | Audits Responsive Search Ad strength (`POOR`/`AVERAGE`/`GOOD`/`EXCELLENT`), policy approvals, and pinning. |
| `get_auction_insights` | Queries API `auction_insight_*` metrics when permitted by the developer token / Cloud project. |
| `analyze_auction_insights_csv` | Parses Google Ads UI Auction Insights CSV exports (**English and Spanish**) into competitor rankings and high-pressure overlap alerts whenever the API restricts `auction_insight_*`. |
| `get_shared_sets` | Lists shared negative keyword lists and campaign attachments. |
| `analyze_search_terms_clusters` | Groups search terms into n-gram clusters with aggregate spend, clicks, CTR, conversions, and CPA. |
| `suggest_negatives_from_clusters` | Suggests candidate negative keywords from high-spend, zero-conversion search term clusters (read-only advisory). |
| `generate_keyword_ideas` | Uses Google Ads Keyword Planner to discover new keyword ideas with search volumes and competition. |
| `generate_keyword_historical_metrics` | Retrieves historical monthly search volume, competition, and top-of-page bid ranges for seed keywords. |
| `generate_keyword_forecast` | Forecasts clicks, impressions, cost, and conversions for a keyword plan. |
| `find_geo_target_constants` | Searches Google Ads `geo_target_constant` IDs by city, region, or country name. |
| `list_experiments` | Lists Search/Performance experiments and their status. |
| `get_experiment` | Retrieves configuration and arms (control vs. treatment) of an experiment. |
| `get_experiment_results` | Compares control vs. treatment arm metrics with lift/delta calculations. |

---

### 5. `pmax` Module (8 tools)

Included in `ecommerce`, `agency`, and `full` presets.

| Tool | What It Does |
| --- | --- |
| `get_pmax_diagnostics` | Full Performance Max audit: `asset_group` strength/metrics, `asset_group_asset` v25 `primary_status`/`primary_status_reasons`/approvals, `asset_group_signal` (audiences & search themes), `asset_group_listing_group_filter`, per-campaign `campaign_search_term_insight` (top 10 PMax campaigns), and `performance_max_placement_view` (mobile-app impression alerts). Explicitly reports `coverage_status` (`complete` / `empty` / `sampled` / `partial_error`), `truncated_queries`, `search_term_insights_coverage`, `placements_coverage`, and `sampling_warnings`. |
| `analyze_auction_insights_csv` | Parses Google Ads UI Auction Insights CSV exports (EN/ES). |
| `get_geo_performance` | Performance breakdown by geographic location. |
| `get_device_performance` | Performance breakdown by device (`MOBILE`, `DESKTOP`, `TABLET`, `CONNECTED_TV`). |
| `get_time_of_day_performance` | Performance breakdown by day of week and hour of day. |
| `get_audience_performance` | Performance breakdown across audience segments. |
| `list_recommendations` | Lists active Google Ads recommendations (read-only review). |
| `get_recommendation_detail` | Inspects impact estimates and parameters of a specific recommendation. |

---

### 6. `shopping` Module (6 tools)

Included in `ecommerce` and `full` presets.

| Tool | What It Does |
| --- | --- |
| `get_shopping_performance` | Shopping performance grouped by `product` (SKU), `brand`, `category` (`shopping_performance_view`), or `product_group` (`product_group_view`), returning blended ROAS, `top_winners`, `wasted_products` above `min_waste_spend`, wasted-spend share %, and `totals_are_partial`. |
| `analyze_auction_insights_csv` | Parses Shopping Auction Insights UI CSV exports (EN/ES). |
| `get_geo_performance` | Geographic performance breakdown. |
| `get_device_performance` | Device performance breakdown. |
| `list_recommendations` | Lists Shopping/account recommendations. |
| `get_recommendation_detail` | Inspects a recommendation in detail. |

---

### 7. `display` Module (5 tools)

Included in `full` preset (or via `--modules display`).

| Tool | What It Does |
| --- | --- |
| `get_placements_and_video_performance` | Audits `detail_placement_view` (surfacing zero-conversion and `MOBILE_APPLICATION` exclusion candidates) alongside campaign video view rate, average CPV, and quartile funnel (`p25/p50/p75/p100`). |
| `get_audience_performance` | Audience segment performance. |
| `get_geo_performance` | Geographic performance. |
| `get_device_performance` | Device performance. |
| `get_time_of_day_performance` | Day-of-week & hour-of-day performance. |

---

### 8. `demand-gen` Module (5 tools)

Included in `full` preset (or via `--modules demand-gen`).

| Tool | What It Does |
| --- | --- |
| `get_demand_gen_performance` | Demand Gen campaign & ad group performance summary. |
| `get_placements_and_video_performance` | Placement brand-safety audit + video view rate & quartile retention (`p25/p50/p75/p100`). |
| `get_audience_performance` | Audience segment performance. |
| `get_geo_performance` | Geographic performance. |
| `get_device_performance` | Device performance. |

---

### 9. `mcc` Module (11 tools)

Included in `agency` and `full` presets.

| Tool | What It Does |
| --- | --- |
| `list_client_accounts` | Discovers active non-manager child accounts under a Manager Account (MCC) and automatically registers dynamic per-account `login-customer-id` routing for the session. |
| `get_client_context` | Returns the active client context and configured client metadata. |
| `switch_context` | Switches the active client context for multi-account agency sessions. |
| `run_across_clients` | Runs a read-only GAQL query in parallel across multiple client accounts (respecting per-account MCC routing and `ALLOWED_CUSTOMER_IDS`). |
| `generate_agency_dashboard` | Multi-account consolidated dashboard separated by currency. |
| `get_audit_log` | Reads local append-only governance audit entries with filters (account, tool, status, date). |
| `get_pending_approvals` | Lists pending human-approval previews awaiting confirmation. |
| `list_expiring_approvals` | Highlights pending approvals nearing their TTL expiration. |
| `list_pending_client_approvals` | Lists approvals requiring explicit client sign-off when `REQUIRE_CLIENT_APPROVAL=true`. |
| `export_audit_log` | Exports filtered audit logs to JSON or CSV for compliance/client reporting. |
| `rotate_audit_log` | Archives older daily audit JSONL files into compressed zip archives per retention policy. |

---

### 10. `operations` Module (68 guarded write & governance tools — opt-in only)

**Hidden from `tools/list` whenever `READ_ONLY_MODE=true`.** Only exposed when `READ_ONLY_MODE=false` and `operations` (or `--preset full`) is enabled. Every mutation requires `dry_run=true` first (`approval_id` returned) before `dry_run=false`. See [Write Safety Guarantees by Family](docs/compatibility-matrix.md#5-write-safety-guarantees-by-family-operations-module) for exact `validateOnly`, `state_verifier`, and `revert_operation` coverage per family.

- **Campaigns & Budgets (13):** `create_campaign_budget`, `update_campaign_budget` *(optimistic locking + revert)*, `create_search_campaign`, `create_pmax_campaign`, `create_display_campaign`, `create_campaign_from_template`, `update_campaign`, `pause_campaign` *(optimistic locking + revert)*, `enable_campaign` *(optimistic locking + revert)*, `remove_campaign` *(optimistic locking)*, `update_campaign_geo_targets`, `update_campaign_schedule`, `copy_campaign`.
- **Ad Groups & Ads (11):** `create_ad_group`, `update_ad_group`, `pause_ad_group`, `enable_ad_group`, `remove_ad_group`, `create_responsive_search_ad`, `create_call_ad`, `update_ad`, `pause_ad`, `enable_ad`, `remove_ad`.
- **Keywords, Bids & Negatives (10):** `add_keywords_to_ad_group`, `update_keyword_bid` *(optimistic locking + revert)*, `pause_keyword` *(revert)*, `enable_keyword` *(revert)*, `remove_keyword`, `add_negative_keyword`, `add_negative_keywords_bulk`, `create_negative_keyword_list`, `attach_negative_keyword_list_to_campaign`, `add_account_negative_keywords` *(applies across Search, Shopping & PMax)*.
- **Audiences, Bid Modifiers & Customer Match (6):** `add_audience_to_ad_group`, `remove_audience_from_ad_group`, `update_bid_modifier`, `create_customer_match_list`, `add_customer_match_members` *(local SHA-256 hashing, zero raw PII in logs)*, `remove_customer_match_members`.
- **Assets, Extensions & Placements (8):** `create_sitelink_extension`, `create_callout_extension`, `create_structured_snippet_extension`, `create_call_extension`, `create_image_asset`, `link_asset_to_campaign`, `unlink_asset_from_campaign`, `exclude_placements` *(campaign or account level, websites & mobile apps, deduplicated up to 100)*.
- **PMax, Demand Gen, Experiments & Recommendations (8):** `create_pmax_asset_group`, `create_demand_gen_campaign`, `create_demand_gen_ad_group`, `create_experiment`, `schedule_experiment`, `end_experiment`, `apply_recommendation`, `dismiss_recommendation`.
- **Conversion Actions, Goals & Offline Uploads (8):** `create_conversion_action`, `update_conversion_action`, `pause_conversion_action`, `update_campaign_conversion_goal` *(optimistic locking + revert)*, `set_conversion_action_primary` *(optimistic locking + revert)*, `upload_click_conversions`, `upload_call_conversions`, `upload_conversion_adjustments`.
- **MCC Bulk & Write Governance (4):** `mcc_bulk_apply` *(multi-account guarded batch with per-item execution tracking & `retry_failed_from_approval_id` partial retry)*, `approve_operation`, `reject_operation`, `revert_operation`.

---

## MCP Prompts & Resources

Clients that support MCP Prompts and Resources automatically receive:

| Type | Identifier | Purpose |
| --- | --- | --- |
| **Prompt** | `analysis_profile_prompt` | Loads any Markdown + TOML analysis profile (`leads-audit`, `ecommerce-audit`, `agency-weekly`, or custom user profile) with reproducibility header and parameters. |
| **Prompt** | `google_ads_workflow` | Guided step-by-step Google Ads analysis workflow. |
| **Prompt** | `gaql_help` | GAQL query construction assistance and best practices. |
| **Prompt** | `monthly_client_review` | Structured monthly performance & optimization review prompt. |
| **Prompt** | `safe_campaign_change` | Guided `dry_run -> review diff -> approval_id -> execute` change workflow. |
| **Resource** | `agency://governance/status` | Live read-only snapshot of active guardrails, limits, and operator settings. |
| **Resource** | `gaql://reference` | Compact GAQL field & resource reference. |
| **Template** | `agency://docs/{domain}` | Embedded domain guides (campaigns, guardrails, reporting, offline conversions, Keyword Planner, etc.). |
| **Template** | `agency://tools/{tool_name}` | Tool-level usage documentation and safety notes. |

> **Multi-AI self-containment:** Critical workflows (analysis profiles, `dry_run` rules, currency/timezone metadata, truncation flags) are also exposed directly through tools so clients that ignore MCP Prompts/Resources work with zero loss of functionality.

---

## Customizable Analysis Profiles (Markdown + TOML)

Built-in profiles are packaged inside the wheel (`agency/builtin_profiles/` + `config/profiles/`) so they work even when installed via `pip`/`uvx` outside a git checkout:
- **`leads-audit`** (`.toml` + `.md`): Lead-gen Search audit covering conversion goals, primary vs. secondary separation, delivery, pacing, wasted search terms, and Quality Score.
- **`ecommerce-audit`** (`.toml` + `.md`): Ecommerce audit covering PMax asset groups/placements, Shopping SKU/brand ROAS & waste, conversion tracking, and budget pacing.
- **`agency-weekly`** (`.toml` + `.md`): Multi-account weekly executive review separated by currency with alerts and prioritized next actions.

**User customization:** Place `<profile-id>.toml` and/or `<profile-id>.md` in `GOOGLE_ADS_CONFIG_DIR/profiles/` to create custom profiles or override any built-in profile. TOML thresholds automatically merge over `alerts.json` defaults.

**Security boundary:** Profiles control analysis methodology, target KPIs, and report structure only. They **cannot** override `READ_ONLY_MODE`, `ALLOWED_CUSTOMER_IDS`, economic caps, or human approval requirements.

---

## CLI Commands & Scheduled Alerts

The lightweight CLI dispatcher (`google_ads_cli.py`) powers all subcommands without pre-importing the server or `.env` before managed profile initialization:

```bash
# 1. Start MCP server directly (stdio or streamable-http)
google-ads-mcp-server --transport stdio --demo --preset ecommerce
google-ads-mcp-server --transport streamable-http --host 127.0.0.1 --port 8000

# 2. Browser OAuth onboarding + client registration
google-ads-mcp-server connect --client claude-desktop --customer 1234567890 --preset leads

# 3. Register an existing profile or --demo in another desktop client
google-ads-mcp-server register --client codex --preset agency
google-ads-mcp-server register --client generic --demo

# 4. Preflight diagnostics (live or offline, human or JSON)
google-ads-mcp-server doctor
google-ads-mcp-server doctor --offline --json

# 5. Serve a managed profile directly (read-only enforced, uses saved or CLI preset)
google-ads-mcp-server --profile /path/to/profile.json serve --preset ecommerce

# 6. Scheduled alerts CLI (for cron, GitHub Actions, Slack/email scripts)
google-ads-mcp-server alerts --profile leads-audit --format markdown --fail-on-alerts
google-ads-mcp-server alerts --demo --profile leads-audit --format json
```

`alerts --fail-on-alerts` exits with code `2` whenever one or more threshold alerts fire.

---

## Data Accuracy, Truncation & Safety Architecture

- **Account time zone & closed days:** Reporting and diagnostic tools resolve date windows in each account's `customer.time_zone` (with `tzdata` on Windows) and exclude the current incomplete day by default (`complete_days_only=True`). Every response includes `currency_code`, `time_zone`, `queried_at_utc`, and `conversion_lag_warning` when the window ends within the last 3 days.
- **No silent truncation or false-positive absence alerts:** Bounded searches cap pagination at `GOOGLE_ADS_MAX_SEARCH_ROWS` (default `2000`) and propagate `truncated`, `totals_are_partial`, `truncated_queries`, `truncation_warning`, and `coverage_complete: false`. Absence-based alerts (`SMART_BIDDING_WITHOUT_EFFECTIVE_ACTIONS`, `PRIMARY_ACTION_NO_VOLUME`, `NO_RECENT_OFFLINE_UPLOADS`, `NO_APPROVED_BILLING_SETUP`) automatically downgrade to `insufficient_data` whenever their backing query is truncated (or an optional goal/summary query fails).
- **Strict multi-currency & multi-MCC isolation:** Agency dashboards never sum metrics across different currencies (`managed_totals_by_currency`), and dynamic `login-customer-id` routing lets one session switch cleanly between direct accounts and multiple MCCs (`RuntimeContext` + `GOOGLE_ADS_LOGIN_CUSTOMER_MAP` + `list_client_accounts`).
- **Loopback-only HTTP by default:** `streamable-http` defaults to `127.0.0.1` (including inside `Dockerfile`) and refuses to bind to non-loopback hosts (`0.0.0.0`, etc.) unless `MCP_HTTP_ALLOW_REMOTE=true` is explicitly set behind an authenticated HTTPS proxy.
- **PII & hygiene protection:** Audit logs redact sensitive payloads; offline conversion diagnostics and Customer Match never log raw PII; automated hygiene tests block tracked credentials or client data.

---

## Client Compatibility & Self-Hosted HTTP

- **Desktop `stdio` (primary v1.0 path):** Config generation and `stdio` MCP handshakes are automated for Claude Desktop, Claude Code, Codex, Antigravity, Gemini CLI, and generic desktop hosts (Cursor, VS Code, Cherry Studio, Cline, Kimi CLI). Desktop `.mcpb` bundling is **planned** (not yet built). See [Compatibility Matrix](docs/compatibility-matrix.md) for verified status per client, channel coverage, API boundaries, and per-family write guarantees.
- **Self-hosted Remote & Hosted Beta (`Streamable HTTP` + OAuth):**
  - Single-user self-hosted mode via `google-ads-mcp-server --transport streamable-http` (loopback-only unless `MCP_HTTP_ALLOW_REMOTE=true` behind an authenticated HTTPS proxy).
  - Multi-user OAuth gateway via `google-ads-mcp-server remote` supporting both static managed pilots (`MCP_REMOTE_WORKERS`) and **self-serve hosted onboarding** (`/connect` Google OAuth + PKCE, Fernet-encrypted SQLite profile store, lazy-spawning idle-evicting worker pool, per-user presets, and 1-click token revocation). See [Remote Pilot & Self-Serve Guide](docs/remote-pilot.md).

---

## Development & Documentation

- [Compatibility Matrix (AI Apps, Channels, API Limits, Write Guarantees)](docs/compatibility-matrix.md)
- [Guía rápida y playbooks por rol (Español)](docs/es/README.md) | [Guía de conexión (Español)](docs/connect.md)
- [Operational Design](DESIGN.md) | [Guardrails](docs/guardrails.md) | [Release Checklist](docs/release-checklist.md)
- [Roadmap v3 (Desktop Beta & Acceptance)](docs/roadmap-marketing-v3.md) | [Roadmap v2 & Technical Log](docs/roadmap-marketing-v2.md)

Run the full automated test suite:

```bash
pip install -e ".[dev]"
python -m pytest -q
```

## License

MIT. See [LICENSE](LICENSE).
