Add draft_ad_group tool for creating ad groups in existing campaigns - #6
Merged
Merged
Conversation
Adds the ability to create additional ad groups within existing campaigns, closing the gap where only draft_campaign could create the initial ad group. The new tool follows the same two-step draft/confirm pattern with BROAD match safety checks, keyword validation, and atomic execution via GoogleAdsService.mutate(). https://claude.ai/code/session_01NNbaDSsxSFVeTEPgRWqVVM
…e, CPC bid Three new safety checks before creating an ad group: 1. Reject non-SEARCH campaigns (DISPLAY/SHOPPING) since ad group type is SEARCH_STANDARD 2. Warn if an ad group with the same name already exists (duplicate name confusion) 3. Warn if cpc_bid_micros is set on a Smart Bidding campaign (bid will be ignored) Also consolidates the broad match safety check into the same preflight function, reducing API calls by combining campaign info into a single GAQL query. https://claude.ai/code/session_01NNbaDSsxSFVeTEPgRWqVVM
- Renumber check comments sequentially (1, 2, 3, 4) and align docstring - Fix CLAUDE.md tool count: actual @mcp.tool registrations is 29, not 27 https://claude.ai/code/session_01NNbaDSsxSFVeTEPgRWqVVM
- Use `(kw.get("match_type") or "").upper()` to handle null/None match_type
from MCP/JSON callers instead of raising AttributeError
- Replace blanket `except Exception: pass` in preflight checks with a
warning so users know validations were skipped
- Add tests for null and missing match_type keys
https://claude.ai/code/session_01NNbaDSsxSFVeTEPgRWqVVM
kLOsk
added a commit
that referenced
this pull request
Mar 23, 2026
…CPC-cap support Rebased on main after merging PRs #2, #3, #6. Removed duplicate draft_ad_group (kept PR #6's version with preflight checks). Adds: - update_ad_group, draft_callouts, draft_structured_snippets, draft_image_assets - Campaign expansion settings (search_partners, display_network, max_cpc) - Structured error handling for developer token and OAuth issues - Shared _apply_campaign_assets helper replacing duplicated sitelink logic All 77 tests pass.
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a new
draft_ad_grouptool that creates ad groups within existing campaigns, following the same draft → preview → confirm_and_apply pattern asdraft_campaign.What it does:
Safety / preflight checks:
Bug fix (existing code):
match_typehandling across_validate_campaign,_validate_keywords, and_check_broad_match_safety—kw.get("match_type", "").upper()crashes when the value is explicitlyNone(common with MCP/JSON callers). Changed to(kw.get("match_type") or "").upper().Files changed:
src/adloop/ads/write.py— newdraft_ad_group,_validate_ad_group,_preflight_ad_group_checks,_apply_create_ad_group+ null match_type fixsrc/adloop/server.py— new MCP tool registration.claude/rules/adloop.md/.cursor/rules/adloop.mdc— orchestration docs for the new toolCLAUDE.md— updated tool counttests/test_draft_ad_group.py— 25 tests covering validation, preflight checks, and plan creation