Skip to content

feat(mcp): ads listings default to view=summary and the ads tree to depth=campaign for agents - #91

Merged
Gintm merged 1 commit into
developfrom
claude/mcp-ads-slim-views
Nov 12, 2026
Merged

Gintm merged 1 commit into
developfrom
claude/mcp-ads-slim-views

Conversation

@Gintm

@Gintm Gintm commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Why

zernio-dev/Schedule-Posts-API#8195 adds view=summary to GET /v1/ads and GET /v1/ads/ad-sets, and depth=campaign|adset|ad to GET /v1/ads/tree. On real prod rows: a 100-ad page goes 375K → 74K chars (typical) and 741K → 167K (biggest), and the biggest tree page (20 campaigns) 6.48M → 103K chars with depth=campaign. These three tools carry most of the MCP's returned chars, so the MCP should ask for the slim forms by default.

What

  • AGENT_VIEWS: listAds and listAdSets default view to summary.
  • New AGENT_DEPTHS: getAdTree defaults depth to campaign. The agent can still pass full / ad.
  • _with_agent_view now applies both through one helper; the tree description tells agents to pass adset with campaignId for one campaign's ad sets, or ad for everything.
  • No effect until the spec carries the params (it warns at generation, as today); the first regeneration after #8195 deploys picks them up. Checked by generating against the #8195 spec.

🤖 Generated with Claude Code

…epth=adset for agents

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Gintm

Gintm commented Nov 12, 2026

Copy link
Copy Markdown
Contributor Author

Review (code-review high --fix)

Finding Outcome
depth=adset default leaves ads[] empty for agents that walked the whole tree Intended: tool description says pass ad for everything, and adCount still counts the ads
Two maps (AGENT_VIEWS, AGENT_DEPTHS) instead of one table Skipped: one table would rewrite AGENT_VIEWS, which a parallel PR (posts) also edits; kept so that conflict is one line

QA

Check Result
tests/test_mcp_agent_views.py (analytics, listAds, listAdSets, getAdTree, missing params) 6 passed
Full suite 1771 passed, 14 skipped
ruff check clean (test file formatted; the generator was already outside ruff format on develop)
Generate against today's spec warns for listAds / listAdSets / getAdTree, generated tools unchanged
Generate against the Schedule-Posts-API#8195 spec list_ads and list_ad_sets get view="summary", get_ad_tree gets depth="adset", all four handlers forward the param
Post-deploy (pending, after #8195 deploys and the bot regenerates) call list_ads, list_ad_sets, get_ad_tree on mcp.zernio.com with the staff account and compare result sizes with view=full / depth=ad

Metrics (no database change here; sizes measured in #8195 on prod rows)

Tool Before (Sentry Nov 11) Expected
list_ads p95 651K, max 946K chars about -80% (100-ad page: 375K → 74K typical, 741K → 167K biggest)
list_ad_sets p95 1.37M, max 2M chars -35 to -60% where targeting is synced, about 0 where it is not
get_ad_tree p95 1.34M, max 2.7M chars about -88% (biggest page 4.19M → 0.50M)

Post-deploy comparison: same Sentry returned-chars query as the Nov 11 baseline, 24 h after the regeneration vs the 24 h before; control = get_analytics (unchanged by this PR), which should stay flat.

🤖 Generated with Claude Code

@Gintm
Gintm merged commit 3a6e23e into develop Nov 12, 2026
4 checks passed
@Gintm Gintm changed the title feat(mcp): ads listings default to view=summary and the ads tree to depth=adset for agents feat(mcp): ads listings default to view=summary and the ads tree to depth=campaign for agents Nov 12, 2026
@Gintm

Gintm commented Nov 12, 2026

Copy link
Copy Markdown
Contributor Author

Changed the tree default from adset to campaign after weighing sizes: at the MCP's 10 campaigns per page, adset still exceeds the 80K cap on big accounts (about 600K), campaign stays near 50K on the biggest one. The depth description now reads "Defaults to campaign here; pass adset with campaignId for one campaign's ad sets, or ad for everything." Generated against the Schedule-Posts-API#8195 spec, the tools compile; 1771 tests pass.

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.

1 participant