Skip to content

fix: reduce token count of get_account_summaries#141

Open
ZLeventer wants to merge 1 commit intogoogleanalytics:mainfrom
ZLeventer:fix/reduce-account-summaries-tokens
Open

fix: reduce token count of get_account_summaries#141
ZLeventer wants to merge 1 commit intogoogleanalytics:mainfrom
ZLeventer:fix/reduce-account-summaries-tokens

Conversation

@ZLeventer
Copy link
Copy Markdown

Summary

Closes #69.

  • Strip redundant fields from get_account_summaries responses: removes name from account summaries (just "accountSummaries/ID", redundant with account), and removes name, parent, and property_type from property summaries (parent is implicit from the containing account, property_type is rarely needed, name is redundant with property).
  • Add optional query parameter (case-insensitive display-name search) so agencies with hundreds of accounts can filter server-side instead of consuming tokens on the full list.

Motivation

For agencies managing many GA4 accounts, get_account_summaries returns a large payload with several fields that are either redundant or rarely useful. This inflates token counts unnecessarily when the LLM processes the response. Stripping these fields and adding a search filter directly addresses the issue.

Changes

  • analytics_mcp/tools/admin/info.py: Added _strip_account_summary helper and query parameter to get_account_summaries; updated docstring.

Test plan

  • Verify get_account_summaries() (no args) returns results without name, parent, or property_type fields
  • Verify get_account_summaries(query="example") filters by display name correctly
  • Verify accounts matching by property name (not account name) only include the matching properties

…ics#69)

Strip redundant fields (name, parent, property_type) from account and
property summaries to cut token usage for agencies with many GA4
accounts. Add an optional `query` parameter for case-insensitive
display-name filtering so callers can narrow results without
post-processing the full list.
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.

Reduce the token count of get_account_summaries

1 participant