Skip to content

Commit 4417bdf

Browse files
Remove get_model_parents/get_model_children; enrich get_lineage with description
get_lineage(depth=1) already covers the immediate-parent/child use case. Adding description to lineage nodes preserves the information that was available via the removed tools. Removes ~200 LOC of dead client code. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent c804eab commit 4417bdf

14 files changed

Lines changed: 61 additions & 378 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
kind: Enhancement or New Feature
2+
body: Remove get_model_parents and get_model_children tools; get_lineage(depth=1) provides the same information and now also returns a description field per node
3+
time: 2026-06-22T10:30:11.723713-07:00

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,11 @@ To learn more about the dbt Discovery API, click [here](https://docs.getdbt.com/
4747
- `get_all_sources`: Gets all sources with freshness status; option to filter by source name.
4848
- `get_exposure_details`: Gets exposure details including owner, parents, and freshness status.
4949
- `get_exposures`: Gets all exposures (downstream dashboards, apps, or analyses).
50-
- `get_lineage`: Gets full lineage graph (ancestors and descendants) with type and depth filtering.
50+
- `get_lineage`: Gets full lineage graph (ancestors and descendants) with type and depth filtering; use depth=1 to get immediate parents or children.
5151
- `get_macro_details`: Gets details for a specific macro.
5252
- `get_mart_models`: Retrieves all mart models.
53-
- `get_model_children`: Gets downstream dependents of a model.
5453
- `get_model_details`: Gets model details including compiled SQL, columns, and schema.
5554
- `get_model_health`: Gets health signals: run status, test results, and upstream source freshness.
56-
- `get_model_parents`: Gets upstream dependencies of a model.
5755
- `get_model_performance`: Gets execution history for a model; option to include test results.
5856
- `get_related_models`: Finds similar models using semantic search.
5957
- `get_seed_details`: Gets details for a specific seed.

src/dbt_mcp/discovery/client.py

Lines changed: 0 additions & 165 deletions
Original file line numberDiff line numberDiff line change
@@ -140,125 +140,6 @@ class GraphQLQueries:
140140
}
141141
""")
142142

143-
COMMON_FIELDS_PARENTS_CHILDREN = textwrap.dedent("""
144-
{
145-
... on ExposureAppliedStateNestedNode {
146-
resourceType
147-
name
148-
description
149-
}
150-
... on ExternalModelNode {
151-
resourceType
152-
description
153-
name
154-
}
155-
... on MacroDefinitionNestedNode {
156-
resourceType
157-
name
158-
description
159-
}
160-
... on MetricDefinitionNestedNode {
161-
resourceType
162-
name
163-
description
164-
}
165-
... on ModelAppliedStateNestedNode {
166-
resourceType
167-
name
168-
description
169-
}
170-
... on SavedQueryDefinitionNestedNode {
171-
resourceType
172-
name
173-
description
174-
}
175-
... on SeedAppliedStateNestedNode {
176-
resourceType
177-
name
178-
description
179-
}
180-
... on SemanticModelDefinitionNestedNode {
181-
resourceType
182-
name
183-
description
184-
}
185-
... on SnapshotAppliedStateNestedNode {
186-
resourceType
187-
name
188-
description
189-
}
190-
... on SourceAppliedStateNestedNode {
191-
resourceType
192-
sourceName
193-
uniqueId
194-
name
195-
description
196-
}
197-
... on TestAppliedStateNestedNode {
198-
resourceType
199-
name
200-
description
201-
}
202-
""")
203-
204-
GET_MODEL_PARENTS = (
205-
textwrap.dedent("""
206-
query GetModelParents(
207-
$environmentId: BigInt!,
208-
$modelsFilter: ModelAppliedFilter
209-
$first: Int,
210-
) {
211-
environment(id: $environmentId) {
212-
applied {
213-
models(filter: $modelsFilter, first: $first) {
214-
pageInfo {
215-
endCursor
216-
}
217-
edges {
218-
node {
219-
parents
220-
""")
221-
+ COMMON_FIELDS_PARENTS_CHILDREN
222-
+ textwrap.dedent("""
223-
}
224-
}
225-
}
226-
}
227-
}
228-
}
229-
}
230-
""")
231-
)
232-
233-
GET_MODEL_CHILDREN = (
234-
textwrap.dedent("""
235-
query GetModelChildren(
236-
$environmentId: BigInt!,
237-
$modelsFilter: ModelAppliedFilter
238-
$first: Int,
239-
) {
240-
environment(id: $environmentId) {
241-
applied {
242-
models(filter: $modelsFilter, first: $first) {
243-
pageInfo {
244-
endCursor
245-
}
246-
edges {
247-
node {
248-
children
249-
""")
250-
+ COMMON_FIELDS_PARENTS_CHILDREN
251-
+ textwrap.dedent("""
252-
}
253-
}
254-
}
255-
}
256-
}
257-
}
258-
}
259-
""")
260-
)
261-
262143
GET_SOURCES = textwrap.dedent("""
263144
query GetSources(
264145
$environmentId: BigInt!,
@@ -511,52 +392,6 @@ async def fetch_models(
511392
config=config,
512393
)
513394

514-
async def fetch_model_parents(
515-
self,
516-
model_name: str | None = None,
517-
unique_id: str | None = None,
518-
*,
519-
config: DiscoveryConfig,
520-
) -> list[dict]:
521-
model_filters = self._get_model_filters(model_name, unique_id)
522-
variables = {
523-
"environmentId": config.environment_id,
524-
"modelsFilter": model_filters,
525-
"first": 1,
526-
}
527-
result = await execute_query(
528-
GraphQLQueries.GET_MODEL_PARENTS, variables, config=config
529-
)
530-
raise_gql_error(result)
531-
edges = result["data"]["environment"]["applied"]["models"]["edges"]
532-
if not edges:
533-
return []
534-
return edges[0]["node"]["parents"]
535-
536-
async def fetch_model_children(
537-
self,
538-
model_name: str | None = None,
539-
unique_id: str | None = None,
540-
*,
541-
config: DiscoveryConfig,
542-
) -> list[dict]:
543-
model_filters = self._get_model_filters(model_name, unique_id)
544-
variables = {
545-
"environmentId": config.environment_id,
546-
"modelsFilter": model_filters,
547-
"first": 1,
548-
}
549-
result = await execute_query(
550-
GraphQLQueries.GET_MODEL_CHILDREN,
551-
variables,
552-
config=config,
553-
)
554-
raise_gql_error(result)
555-
edges = result["data"]["environment"]["applied"]["models"]["edges"]
556-
if not edges:
557-
return []
558-
return edges[0]["node"]["children"]
559-
560395
async def fetch_model_health(
561396
self,
562397
model_name: str | None = None,

src/dbt_mcp/discovery/graphql/get_full_lineage.gql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ query GetFullLineage($environmentId: BigInt!, $types: [ResourceNodeType!]!) {
55
name
66
uniqueId
77
resourceType
8+
description
89
... on LineageNodeWithParents {
910
parentIds
1011
}

src/dbt_mcp/discovery/tools.py

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -159,42 +159,6 @@ async def get_model_details(
159159
)
160160

161161

162-
@dbt_mcp_tool(
163-
description=get_prompt("discovery/get_model_parents"),
164-
title="Get Model Parents",
165-
read_only_hint=True,
166-
destructive_hint=False,
167-
idempotent_hint=True,
168-
)
169-
async def get_model_parents(
170-
context: DiscoveryToolContext,
171-
name: str | None = NAME_FIELD,
172-
unique_id: str | None = UNIQUE_ID_FIELD,
173-
) -> list[dict]:
174-
config = await context.config_provider.get_config()
175-
return await context.models_fetcher.fetch_model_parents(
176-
model_name=name, unique_id=unique_id, config=config
177-
)
178-
179-
180-
@dbt_mcp_tool(
181-
description=get_prompt("discovery/get_model_children"),
182-
title="Get Model Children",
183-
read_only_hint=True,
184-
destructive_hint=False,
185-
idempotent_hint=True,
186-
)
187-
async def get_model_children(
188-
context: DiscoveryToolContext,
189-
name: str | None = NAME_FIELD,
190-
unique_id: str | None = UNIQUE_ID_FIELD,
191-
) -> list[dict]:
192-
config = await context.config_provider.get_config()
193-
return await context.models_fetcher.fetch_model_children(
194-
name, unique_id, config=config
195-
)
196-
197-
198162
@dbt_mcp_tool(
199163
description=get_prompt("discovery/get_model_health"),
200164
title="Get Model Health",
@@ -480,8 +444,6 @@ async def get_test_details(
480444
get_mart_models,
481445
get_all_models,
482446
get_model_details,
483-
get_model_parents,
484-
get_model_children,
485447
get_model_health,
486448
get_model_performance,
487449
get_lineage,

src/dbt_mcp/discovery/tools_multiproject.py

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -171,44 +171,6 @@ async def get_model_details(
171171
)
172172

173173

174-
@dbt_mcp_tool(
175-
description=get_prompt("discovery/get_model_parents"),
176-
title="Get Model Parents",
177-
read_only_hint=True,
178-
destructive_hint=False,
179-
idempotent_hint=True,
180-
)
181-
async def get_model_parents(
182-
context: MultiProjectDiscoveryToolContext,
183-
project_id: Annotated[int, Field(description=DISCOVERY_PROJECT_ID_DESCRIPTION)],
184-
name: str | None = NAME_FIELD,
185-
unique_id: str | None = UNIQUE_ID_FIELD,
186-
) -> list[dict]:
187-
config = await context.config_provider.get_config(project_id=project_id)
188-
return await context.models_fetcher.fetch_model_parents(
189-
name, unique_id, config=config
190-
)
191-
192-
193-
@dbt_mcp_tool(
194-
description=get_prompt("discovery/get_model_children"),
195-
title="Get Model Children",
196-
read_only_hint=True,
197-
destructive_hint=False,
198-
idempotent_hint=True,
199-
)
200-
async def get_model_children(
201-
context: MultiProjectDiscoveryToolContext,
202-
project_id: Annotated[int, Field(description=DISCOVERY_PROJECT_ID_DESCRIPTION)],
203-
name: str | None = NAME_FIELD,
204-
unique_id: str | None = UNIQUE_ID_FIELD,
205-
) -> list[dict]:
206-
config = await context.config_provider.get_config(project_id=project_id)
207-
return await context.models_fetcher.fetch_model_children(
208-
model_name=name, unique_id=unique_id, config=config
209-
)
210-
211-
212174
@dbt_mcp_tool(
213175
description=get_prompt("discovery/get_model_health"),
214176
title="Get Model Health",
@@ -508,8 +470,6 @@ async def get_test_details(
508470
get_mart_models,
509471
get_all_models,
510472
get_model_details,
511-
get_model_parents,
512-
get_model_children,
513473
get_model_health,
514474
get_model_performance,
515475
get_lineage,

src/dbt_mcp/prompts/discovery/get_lineage.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,33 @@ A list of all nodes in the connected subgraph, where each node contains:
77
- `uniqueId`: The resource's unique identifier
88
- `name`: The resource name
99
- `resourceType`: The type of resource (Model, Source, etc.)
10+
- `description`: A description of the resource
1011
- `parentIds`: List of unique IDs that this resource directly depends on
1112

13+
**Getting immediate parents or children:** use `depth=1`. This returns the target node plus its direct upstream dependencies and direct downstream dependents.
14+
1215
**Example Response:**
1316
```json
1417
[
1518
{
1619
"uniqueId": "source.raw.users",
1720
"name": "users",
1821
"resourceType": "Source",
22+
"description": "Raw user events from the application",
1923
"parentIds": []
2024
},
2125
{
2226
"uniqueId": "model.stg_customers",
2327
"name": "stg_customers",
2428
"resourceType": "Model",
29+
"description": "Staged customer records",
2530
"parentIds": ["source.raw.users"]
2631
},
2732
{
2833
"uniqueId": "model.customers",
2934
"name": "customers",
3035
"resourceType": "Model",
36+
"description": "Customer dimension model",
3137
"parentIds": ["model.stg_customers"]
3238
}
3339
]
@@ -38,12 +44,12 @@ A list of all nodes in the connected subgraph, where each node contains:
3844
# Get complete lineage (all connected nodes, all types, default depth of 5)
3945
get_lineage(unique_id="model.analytics.customers")
4046

47+
# Get only immediate parents and children (replaces get_model_parents / get_model_children)
48+
get_lineage(unique_id="model.analytics.customers", depth=1)
49+
4150
# Get lineage filtered to only models and sources
4251
get_lineage(unique_id="model.analytics.customers", types=["Model", "Source"])
4352

44-
# Get only immediate neighbors (depth=1)
45-
get_lineage(unique_id="model.analytics.customers", depth=1)
46-
4753
# Get deeper lineage for comprehensive analysis
4854
get_lineage(unique_id="model.analytics.customers", depth=10)
4955
```

src/dbt_mcp/prompts/discovery/get_model_children.md

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)