diff --git a/scripts/generate_mcp_tools.py b/scripts/generate_mcp_tools.py index dc88900a..f238f759 100644 --- a/scripts/generate_mcp_tools.py +++ b/scripts/generate_mcp_tools.py @@ -74,7 +74,7 @@ } AGENT_DEPTHS = { - "getAdTree": "adset", + "getAdTree": "campaign", } SAME_ARGUMENTS_IDEMPOTENT_OPERATIONS = { @@ -452,7 +452,7 @@ def _with_agent_default( *, name: str, value: str | None, - widest: str, + hint: str, ) -> list[dict[str, Any]]: if value is None: return params @@ -462,7 +462,7 @@ def _with_agent_default( { **p, "default": f'"{value}"', - "description": f"{p['description'].strip()} Defaults to {value} here; pass {widest} for everything.".strip(), + "description": f"{p['description'].strip()} Defaults to {value} here; {hint}".strip(), } if p["name"] == name else p @@ -471,8 +471,14 @@ def _with_agent_default( def _with_agent_view(operation_id: str, params: list[dict[str, Any]]) -> list[dict[str, Any]]: - params = _with_agent_default(operation_id, params, name="view", value=AGENT_VIEWS.get(operation_id), widest="full") - return _with_agent_default(operation_id, params, name="depth", value=AGENT_DEPTHS.get(operation_id), widest="ad") + params = _with_agent_default(operation_id, params, name="view", value=AGENT_VIEWS.get(operation_id), hint="pass full for everything.") + return _with_agent_default( + operation_id, + params, + name="depth", + value=AGENT_DEPTHS.get(operation_id), + hint="pass adset with campaign_id for one campaign's ad sets, or ad for everything.", + ) def extract_parameters( diff --git a/tests/test_mcp_agent_views.py b/tests/test_mcp_agent_views.py index 6ab38276..c1b34753 100644 --- a/tests/test_mcp_agent_views.py +++ b/tests/test_mcp_agent_views.py @@ -87,7 +87,9 @@ def test_listings_default_to_the_summary_view_for_agents( ) -def test_the_ads_tree_defaults_to_ad_set_depth_for_agents(mcp_generator) -> None: +def test_the_ads_tree_defaults_to_campaign_depth_and_says_how_to_drill_down( + mcp_generator, +) -> None: operation = _operation("getAdTree", "depth", ["campaign", "adset", "ad"], "ad") params = mcp_generator._with_agent_view( "getAdTree", mcp_generator.extract_parameters(operation, {}) @@ -102,8 +104,11 @@ def test_the_ads_tree_defaults_to_ad_set_depth_for_agents(mcp_generator) -> None "Get ad tree", ) - assert "depth: Literal['campaign', 'adset', 'ad'] = \"adset\"" in handler - assert "Defaults to adset here; pass ad for everything." in handler + assert "depth: Literal['campaign', 'adset', 'ad'] = \"campaign\"" in handler + assert ( + "Defaults to campaign here; pass adset with campaign_id for one campaign's ad sets, or ad for everything." + in handler + ) def test_a_tree_spec_without_the_depth_parameter_warns_and_keeps_its_parameters(