Skip to content

Fix repeated field serialization, add Keyword Planner tool, and add update instructions#48

Open
srapisarld1 wants to merge 2 commits intogoogleads:mainfrom
srapisarld1:fix-repeated-field-serialization
Open

Fix repeated field serialization, add Keyword Planner tool, and add update instructions#48
srapisarld1 wants to merge 2 commits intogoogleads:mainfrom
srapisarld1:fix-repeated-field-serialization

Conversation

@srapisarld1
Copy link
Copy Markdown

@srapisarld1 srapisarld1 commented Apr 2, 2026

Summary

  • Fix format_output_value() to handle repeated and message protobuf field types that previously caused "Unable to serialize unknown type: RepeatedScalarContainer" errors when querying fields like ad.final_urls, ad.responsive_search_ad.headlines, or any protobuf Message field
  • Add Keyword Planner tool (generate_keyword_ideas) — wraps the KeywordPlanIdeaService to generate keyword ideas with search volume, competition data, and bid estimates. Supports seed keywords and/or page URL, language/geo targeting, and configurable result limits
  • Add update instructions to README so users know how to pull in new changes

Test plan

  • Added unit tests for repeated scalar, repeated composite, protobuf message, empty repeated, and primitive pass-through cases
  • Manual verification: query ad_group_ad.ad.final_urls via the MCP search tool and confirm it returns a JSON list instead of erroring
  • Manual verification: call generate_keyword_ideas with seed keywords and confirm results include search volume and competition data

🤖 Generated with Claude Code

format_output_value() only handled proto.Enum types, causing
"Unable to serialize unknown type: RepeatedScalarContainer" errors
when querying fields like ad.final_urls, ad.responsive_search_ad.headlines,
or any protobuf Message field.

Added handling for:
- RepeatedScalarContainer (e.g. final_urls) → list
- RepeatedCompositeContainer (e.g. headlines) → list of dicts
- protobuf Message types (e.g. Money) → dict via MessageToDict

Also added update instructions to README.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@google-cla
Copy link
Copy Markdown

google-cla Bot commented Apr 2, 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.

Adds a new MCP tool that wraps the Google Ads KeywordPlanIdeaService to
generate keyword ideas with search volume, competition data, and bid
estimates. Supports seed keywords and/or page URL, language and geo
targeting, and configurable result limits.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@srapisarld1 srapisarld1 changed the title Fix serialization of repeated and message protobuf fields Fix repeated field serialization, add Keyword Planner tool, and add update instructions Apr 2, 2026
@Raibaz
Copy link
Copy Markdown
Collaborator

Raibaz commented Apr 20, 2026

I already fixed repeated field serialization and we won't adding support for keyword planning now, so I'd like to only merge the update instructions.

Can you please send another PR just with that, or update this one?

Thanks! 🙏

Copy link
Copy Markdown
Contributor

@ZLeventer ZLeventer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Keyword Planner tool addition is valuable — keyword research is one of the most common Google Ads workflows and having it in the MCP server makes the tool significantly more useful for SEO/SEM practitioners.

A few observations on the implementation:

  1. Seed validation — Good that it requires at least one of keywords or page_url. The keyword_and_url_seed branch for when both are provided is correct per the API spec.

  2. Geo and language defaults — US/English as defaults makes sense. The docstring listing common geo/language IDs is a nice touch for discoverability.

  3. Monthly volumes — Limiting to [-12:] is smart to keep response sizes reasonable.

  4. The limit parameter — Works but note that KeywordPlanIdeaService returns results server-side in batches. If pagination is needed for larger result sets, the page_token from the response would need to be handled. For a default of 50 this is fine.

The update instructions in README.md are also a useful addition — the "how do I update" question comes up constantly with MCP servers.

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.

3 participants