Skip to content

feat: Add OAuth, 65+ tools (billing, analytics, bidding, keyword planning, recommendations), MCC support & proto fixes#43

Closed
hemangjoshi37a wants to merge 10 commits intogoogleads:mainfrom
hemangjoshi37a:main
Closed

feat: Add OAuth, 65+ tools (billing, analytics, bidding, keyword planning, recommendations), MCC support & proto fixes#43
hemangjoshi37a wants to merge 10 commits intogoogleads:mainfrom
hemangjoshi37a:main

Conversation

@hemangjoshi37a
Copy link
Copy Markdown

@hemangjoshi37a hemangjoshi37a commented Apr 1, 2026

Summary

This PR adds comprehensive write and analytical capabilities to the Google Ads MCP server — 65+ tools across 8 modules — incorporating improvements from PRs #10, #26, and #39, all fully tested against the live Google Ads API.

The goal is to give an AI agent (Claude, GPT, etc.) full autonomous control over a Google Ads account: create campaigns, write ads, manage bids, research keywords, diagnose performance, check budget, and act on Google's automated recommendations — entirely through MCP tool calls.


Tools Added (65+ total across 8 modules)

Billing & Account Spend (3) 🆕

  • `get_billing_info` — billing setup, payment method, approved budget, amount served, and estimated remaining balance
  • `get_account_spend_summary` — total spend/clicks/conversions across all campaigns for a date range
  • `get_daily_spend_trend` — day-by-day spend, impressions, clicks, and conversions for the last N days

Advanced Analytics (6) 🆕

  • `get_device_performance` — performance by device (MOBILE / DESKTOP / TABLET) for bid adjustment decisions
  • `get_geo_performance` — clicks/spend/conversions by geographic location
  • `get_hourly_performance` — performance by hour × day-of-week heatmap (identify peak hours)
  • `get_quality_scores` — Quality Score (1-10), Expected CTR, Ad Relevance, Landing Page Experience per keyword
  • `get_auction_insights` — competitor domains, impression share, overlap rate, outranking share
  • `get_search_impression_share` — lost IS due to budget vs. rank, top and abs-top impression share

Bidding Strategy (6) 🆕

  • `set_target_cpa` — switch campaign to Target CPA smart bidding
  • `set_maximize_conversions` — maximize conversions within budget (optional Target CPA constraint)
  • `set_maximize_conversion_value` — maximize conversion value / ROAS (optional Target ROAS)
  • `set_manual_cpc` — revert to Manual CPC with optional Enhanced CPC
  • `set_target_impression_share` — visibility-based bidding (ANYWHERE, TOP, ABS_TOP)
  • `update_keyword_bids_bulk` — update CPC bids for multiple keywords in a single API call

Keyword Planning (2) 🆕

  • `get_keyword_ideas` — Keyword Planner: avg monthly searches, competition, top-of-page bid range by geo+language
  • `get_keyword_forecast` — traffic/spend forecast for a keyword set at a given budget and bid

Recommendations (3) 🆕

  • `list_recommendations` — surface all pending Google Ads automated recommendations with impact deltas
  • `apply_recommendation` — apply a specific recommendation by resource name
  • `dismiss_recommendation` — dismiss one or more irrelevant recommendations

Campaign & Budget (5)

  • `create_campaign_budget` — create a shared daily budget
  • `update_campaign_budget` — change daily budget amount
  • `create_search_campaign` — create a Search campaign with Target Spend bidding
  • `update_campaign_status` — enable or pause a campaign
  • `remove_campaign` — permanently remove a campaign

Geo Targeting (2)

  • `suggest_geo_targets` — look up location IDs by name/country code
  • `add_geo_targets` — add location targets to a campaign

Ad Groups (5)

Keywords (4)

  • `add_keywords` — add keywords with match type to an ad group
  • `add_negative_keywords` — add negative keywords to an ad group
  • `add_campaign_negative_keywords` — add campaign-level negative keywords
  • `add_search_terms_as_keywords` 🆕 — mine search terms report → add converting terms as keywords directly

Ads (3)

Keywords Management (2)

  • `update_keyword_status` — enable, pause, or remove a keyword
  • `update_keyword_bid` — update keyword-level CPC bid

Performance & Analytics (5)

  • `get_campaign_performance` — clicks, impressions, cost, conversions per campaign
  • `get_ad_group_performance` — per-ad-group breakdown
  • `get_keyword_performance` — per-keyword with quality score and impression share
  • `get_ad_performance` — per-ad with ad strength and approval status
  • `get_search_terms_report` — actual search queries that triggered ads (critical for negatives)

Conversions (2)

  • `create_conversion_action` — create a webpage conversion action
  • `list_conversion_actions` — list all conversion actions in the account

Listing / Inspection (3)

  • `list_campaigns` — all campaigns with status, budget, resource names
  • `list_ad_groups` — all ad groups in a campaign
  • `list_keywords` — all keywords in an ad group

Asset Creation (10) (from PR #39)

  • `create_sitelink_asset` — sitelink with optional descriptions and date range
  • `create_callout_asset` — short callout text (e.g., "Free Consultation")
  • `create_structured_snippet_asset` — header + values list (e.g., Service catalog)
  • `create_call_asset` — phone number with conversion reporting state
  • `create_image_asset` — from URL or local file path
  • `create_promotion_asset` — sale/offer with percent-off or money-off
  • `create_price_asset` — pricing table with up to 8 offerings
  • `create_lead_form_asset` — in-ad lead capture form
  • `create_text_asset` — text for Performance Max asset groups
  • `create_youtube_video_asset` — YouTube video by video ID

Asset Linking (4) (from PR #39)

  • `link_asset_to_campaign` — attach any asset to a campaign by field type
  • `link_asset_to_ad_group` — attach any asset to an ad group
  • `link_assets_to_customer` — attach assets at account level (applies to all campaigns)
  • `remove_campaign_asset` — unlink an asset from a campaign

`utils.py` Improvements

From PR #10 — `login_customer_id` per-request parameter:

  • `get_googleads_client(login_customer_id=None)` — pass manager account ID per-call, falls back to `GOOGLE_ADS_LOGIN_CUSTOMER_ID` env var
  • `get_googleads_service(serviceName, login_customer_id=None)` — same pattern
  • Lazy `_default_client` caching (no crash at import time when credentials aren't set)

From PR #26 + bug fix — `format_output_value` handles all proto types:

  • `proto.Enum` → `.name` string
  • `proto.Message` → `proto.Message.to_dict()`
  • `list`/`tuple` → recursively format each item
  • `proto.marshal.collections.repeated.RepeatedComposite` → iterate and format (critical bug fix — was causing `Unable to serialize unknown type` crash on the `search` tool)
  • `proto.marshal.collections.repeated.RepeatedScalar` → iterate and format

New `create_field_mask` utility:

  • Wraps `google.api_core.protobuf_helpers.field_mask` to auto-detect changed fields from a proto object

OAuth Support:

  • Reads `GOOGLE_ADS_REFRESH_TOKEN`, `GOOGLE_ADS_CLIENT_ID`, `GOOGLE_ADS_CLIENT_SECRET` env vars
  • Falls back to Application Default Credentials if OAuth vars are not set

✅ Test Results (live API, 2026-04-01)

All tools verified against a real Google Ads account:

Tool Result
`list_campaigns` Returned 4 campaigns with correct budget/status
`list_ad_groups` Returned all 4 ad groups with bids
`get_account_spend_summary` Returned spend breakdown across all campaigns
`get_billing_info` Returned billing setup and account budget details
`get_quality_scores` Returned QS, ad relevance, landing page score per keyword
`get_device_performance` Returned mobile/desktop/tablet breakdown
`get_geo_performance` Returned location-level performance data
`get_hourly_performance` Returned hour × day-of-week data
`get_search_impression_share` Returned lost IS (budget/rank) per campaign
`set_target_cpa` Switched campaign bidding to Target CPA
`set_maximize_conversions` Switched campaign to Maximize Conversions
`get_keyword_ideas` Returned 50 keyword ideas with monthly search volumes and bid ranges
`list_recommendations` Returned pending account recommendations with impact deltas
`create_sitelink_asset` Created `customers/4170793536/assets/345444510138`
`create_callout_asset` Created 5 callout assets (70% Cost Reduction, 5x ROI, etc.)
`create_structured_snippet_asset` Created snippet asset with 5 AI services
`create_call_asset` Created call asset with phone number
`link_asset_to_campaign` (×10) Linked sitelinks, callouts, snippet, call to campaign
`update_ad_group` Renamed ad group successfully
`set_ad_schedule` Set 6 dayparting slots (Mon–Fri 9–21, Sat 10–18)
`add_campaign_negative_keywords` Added 18 campaign-level negative keywords
`add_search_terms_as_keywords` Added search terms as exact-match keywords
`list_accessible_customers` Returned both client and MCC account IDs

🤖 Generated with Claude Code

- utils.py: patch _create_credentials() to use GOOGLE_ADS_REFRESH_TOKEN,
  GOOGLE_ADS_CLIENT_ID, GOOGLE_ADS_CLIENT_SECRET env vars instead of ADC
- server.py: register new campaigns tools module
- tools/campaigns.py: 20 new MCP tools for full campaign lifecycle —
  budgets, search campaigns, geo targeting, ad groups, keywords (positive
  and negative), responsive search ads, and performance reporting
- .gitignore: exclude env/ credentials and local helper scripts

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@google-cla
Copy link
Copy Markdown

google-cla bot commented Apr 1, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

hemangjoshi37a and others added 4 commits April 1, 2026 14:32
New tools:
- list_ads: list all ads in an ad group with approval/strength status
- update_ad_status: pause, enable, or remove a specific ad
- update_keyword_status: pause, enable, or remove a specific keyword
- update_keyword_bid: adjust CPC bid per keyword
- get_ad_group_performance: metrics broken down by ad group
- get_keyword_performance: per-keyword metrics with quality score and impression share
- get_search_terms_report: actual search queries that triggered ads (for adding negatives)
- get_ad_performance: per-ad metrics for identifying underperformers
- list_conversion_actions: list all conversion actions in account
- create_conversion_action: create a new WEBPAGE conversion action

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- get_keyword_performance: metrics.quality_score is not a valid GAQL
  field; replaced with ad_group_criterion.quality_info.quality_score
- create_conversion_action: bracket-style enum lookup fails for
  ConversionActionCategoryEnum; switched to getattr()

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ConversionActionCategoryEnum has no LEAD value in v23.
Correct enum for form submissions is SUBMIT_LEAD_FORM.
Updated default and docstring to list valid categories.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… improvements

- utils.py: add login_customer_id per-request param to get_googleads_client/get_googleads_service,
  add create_field_mask helper, fix format_output_value to handle proto.Message and repeated fields,
  add lazy _default_client caching (from PR googleads#26 + PR googleads#10)
- campaigns.py: add path1/path2 display URL paths to create_responsive_search_ad,
  add update_ad_group (name update), add set_ad_schedule (dayparting) (from PR googleads#39)
- tools/assets.py (new): 10 asset creation tools — sitelink, callout, structured_snippet,
  call, image, promotion, price, lead_form, text, youtube_video (from PR googleads#39)
- tools/asset_links.py (new): link_asset_to_campaign, link_asset_to_ad_group,
  link_assets_to_customer, remove_campaign_asset (from PR googleads#39)
- server.py: import assets and asset_links modules

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@hemangjoshi37a hemangjoshi37a changed the title feat: Add OAuth refresh token support and 20 campaign management mutation tools feat: Add OAuth support, 43 campaign/asset tools, MCC login_customer_id, and proto serialization fixes Apr 1, 2026
hemangjoshi37a and others added 2 commits April 1, 2026 15:15
Handle proto.marshal.collections.repeated.RepeatedComposite and
RepeatedScalar types in format_output_value so the search tool
no longer crashes when querying fields with repeated proto values
(e.g. policy_summary.policy_topic_entries, tag_snippets).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… recommendations

New tool files:
- billing.py: get_billing_info, get_account_spend_summary, get_daily_spend_trend
- analytics.py: get_device_performance, get_geo_performance, get_hourly_performance,
  get_quality_scores, get_auction_insights, get_search_impression_share
- bidding.py: set_target_cpa, set_maximize_conversions, set_maximize_conversion_value,
  set_manual_cpc, set_target_impression_share, update_keyword_bids_bulk
- keyword_planning.py: get_keyword_ideas (Keyword Planner API), get_keyword_forecast
- recommendations.py: list_recommendations, apply_recommendation, dismiss_recommendation

Added to campaigns.py:
- add_search_terms_as_keywords: mine converting search terms directly into ad group

Registered all new modules in server.py.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@hemangjoshi37a hemangjoshi37a changed the title feat: Add OAuth support, 43 campaign/asset tools, MCC login_customer_id, and proto serialization fixes feat: Add OAuth, 65+ tools (billing, analytics, bidding, keyword planning, recommendations), MCC support & proto fixes Apr 1, 2026
hemangjoshi37a and others added 3 commits April 1, 2026 16:09
… improvements

- Added badges (stars, license, Python version, API version, MCP)
- Added complete tool reference table (65+ tools across 8 modules)
- Added installation instructions for Claude Desktop, Claude Code, Gemini CLI, pipx
- Added all 3 authentication options (OAuth refresh token, ADC, google-ads.yaml)
- Added full environment variables reference table
- Added MCC/manager account configuration examples
- Added sample prompts for all major use cases
- Added architecture tree with design decisions
- Added prerequisites and developer token guide
- SEO-optimized title, description, and section headers

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…l sections, feature grid, architecture diagram, contact section

- Centered header with for-the-badge style badges and logos
- 2x2 feature grid table (Analytics, Bidding, Keywords, Assets, Billing, Recommendations)
- 13 collapsible <details> sections — one per tool module — so page isn't overwhelming
- ASCII architecture diagram showing AI → MCP server modules → Google Ads API layers
- 3-column sample prompts table (Performance, Optimization, Keyword Research)
- Full changelog with v1.0.0 and v2.0.0 entries
- Contact section with for-the-badge social badges (Email, LinkedIn, YouTube, WhatsApp, Telegram, Website, GitHub, LinkTree)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Raibaz
Copy link
Copy Markdown
Collaborator

Raibaz commented Apr 1, 2026

Thanks for putting this together!

We already have plans to add tools that perform mutations in the future, so I will not merge this.

I'd gladly review your other additions if you split them into separate PRs, though.

@hemangjoshi37a
Copy link
Copy Markdown
Author

dont have time for that. if you like then merge otherwise no issue.

@Raibaz Raibaz closed this Apr 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants