Skip to content

Commit 8081a51

Browse files
fix: map depth/unique_id args in get_lineage deprecation banner
Per Copilot review feedback: get_lineage isn't a drop-in for get_model_parents/get_model_children — it requires unique_id (these tools accept name alone) and defaults to depth=5 (these tools only ever return immediate parents/children). Without this mapping, a caller following 'use get_lineage instead' silently gets a 5-level graph instead of the old immediate-neighbor behavior. Adds GET_LINEAGE_ARG_MAPPING as a shared constant in param_descriptions.py, reused at all 4 call sites (2 tools x 2 files) via deprecated_description()'s arg_mapping parameter.
1 parent 1188a9e commit 8081a51

5 files changed

Lines changed: 43 additions & 7 deletions

File tree

src/dbt_mcp/discovery/param_descriptions.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,12 @@
3333
MACRO_INCLUDE_DEFAULT_DBT_PACKAGES = (
3434
"When true, include default dbt Labs core/adapter macro packages"
3535
)
36+
37+
# Not a JSON Schema param description — used as the `arg_mapping` for the
38+
# get_model_parents/get_model_children deprecation banner. get_lineage isn't a
39+
# drop-in: it requires unique_id (these tools accept name alone) and defaults
40+
# to depth=5 (these tools only ever return immediate parents/children).
41+
GET_LINEAGE_ARG_MAPPING = (
42+
"Call get_lineage(unique_id=..., depth=1) to match this tool's behavior — "
43+
"get_lineage requires unique_id (not name) and defaults to depth=5."
44+
)

src/dbt_mcp/discovery/tools.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
SourcesFetcher,
1919
)
2020
from dbt_mcp.discovery.param_descriptions import (
21+
GET_LINEAGE_ARG_MAPPING,
2122
MACRO_INCLUDE_DEFAULT_DBT_PACKAGES,
2223
MACRO_PACKAGE_NAMES,
2324
MACRO_RETURN_PACKAGE_NAMES_ONLY,
@@ -161,7 +162,9 @@ async def get_model_details(
161162

162163

163164
@dbt_mcp_tool(
164-
description=deprecated_description(replacement="get_lineage"),
165+
description=deprecated_description(
166+
replacement="get_lineage", arg_mapping=GET_LINEAGE_ARG_MAPPING
167+
),
165168
meta=deprecation_meta(replacement="get_lineage"),
166169
title="Get Model Parents",
167170
read_only_hint=True,
@@ -180,7 +183,9 @@ async def get_model_parents(
180183

181184

182185
@dbt_mcp_tool(
183-
description=deprecated_description(replacement="get_lineage"),
186+
description=deprecated_description(
187+
replacement="get_lineage", arg_mapping=GET_LINEAGE_ARG_MAPPING
188+
),
184189
meta=deprecation_meta(replacement="get_lineage"),
185190
title="Get Model Children",
186191
read_only_hint=True,

src/dbt_mcp/discovery/tools_multiproject.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
)
2424
from dbt_mcp.discovery.param_descriptions import (
2525
DISCOVERY_PROJECT_ID_DESCRIPTION,
26+
GET_LINEAGE_ARG_MAPPING,
2627
MACRO_INCLUDE_DEFAULT_DBT_PACKAGES,
2728
MACRO_PACKAGE_NAMES,
2829
MACRO_RETURN_PACKAGE_NAMES_ONLY,
@@ -173,7 +174,9 @@ async def get_model_details(
173174

174175

175176
@dbt_mcp_tool(
176-
description=deprecated_description(replacement="get_lineage"),
177+
description=deprecated_description(
178+
replacement="get_lineage", arg_mapping=GET_LINEAGE_ARG_MAPPING
179+
),
177180
meta=deprecation_meta(replacement="get_lineage"),
178181
title="Get Model Parents",
179182
read_only_hint=True,
@@ -193,7 +196,9 @@ async def get_model_parents(
193196

194197

195198
@dbt_mcp_tool(
196-
description=deprecated_description(replacement="get_lineage"),
199+
description=deprecated_description(
200+
replacement="get_lineage", arg_mapping=GET_LINEAGE_ARG_MAPPING
201+
),
197202
meta=deprecation_meta(replacement="get_lineage"),
198203
title="Get Model Children",
199204
read_only_hint=True,

tests/unit/contract/contract_snapshot.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,7 +1169,7 @@
11691169
"readOnlyHint": true,
11701170
"title": "Get Model Children"
11711171
},
1172-
"description": "**DEPRECATED \u2014 use `get_lineage` instead.** This tool will be removed in a future release.",
1172+
"description": "**DEPRECATED \u2014 use `get_lineage` instead.** This tool will be removed in a future release.\n\nCall get_lineage(unique_id=..., depth=1) to match this tool's behavior \u2014 get_lineage requires unique_id (not name) and defaults to depth=5.",
11731173
"input_schema": {
11741174
"properties": {
11751175
"name": {
@@ -1361,7 +1361,7 @@
13611361
"readOnlyHint": true,
13621362
"title": "Get Model Parents"
13631363
},
1364-
"description": "**DEPRECATED \u2014 use `get_lineage` instead.** This tool will be removed in a future release.",
1364+
"description": "**DEPRECATED \u2014 use `get_lineage` instead.** This tool will be removed in a future release.\n\nCall get_lineage(unique_id=..., depth=1) to match this tool's behavior \u2014 get_lineage requires unique_id (not name) and defaults to depth=5.",
13651365
"input_schema": {
13661366
"properties": {
13671367
"name": {

tests/unit/discovery/test_deprecated_tools.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,21 @@ def test_deprecated_tool_description_is_trimmed(mock_fastmcp):
8282
fastmcp = _register_single_project(mock_fastmcp)
8383
description = fastmcp.tool_kwargs["get_model_parents"]["description"]
8484
assert "Retrieves the parent models" not in description
85-
assert len(description) < 200
85+
# Banner + a one-line arg mapping should stay well under the original
86+
# prompt's length (which runs to several hundred characters).
87+
assert len(description) < 300
88+
89+
90+
def test_deprecated_tool_description_maps_args_to_replacement(mock_fastmcp):
91+
"""get_lineage isn't a drop-in for get_model_parents/children: it requires
92+
93+
unique_id (these tools accept name alone) and defaults to depth=5 (these
94+
tools only ever return immediate parents/children). The deprecation
95+
description must spell out the mapping so callers reproduce the old
96+
behavior instead of silently getting a 5-level graph.
97+
"""
98+
fastmcp = _register_single_project(mock_fastmcp)
99+
for tool_name in DEPRECATED_TOOLS:
100+
description = fastmcp.tool_kwargs[tool_name]["description"]
101+
assert "depth=1" in description
102+
assert "unique_id" in description

0 commit comments

Comments
 (0)