Skip to main content
Glama

get_model_parents

Retrieve the parent models of a specified dbt model to understand its dependencies and lineage within the dbt-mcp server.

Instructions

Get the parents of a specific dbt model.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
model_nameYes

Implementation Reference

  • Primary MCP tool handler for get_model_parents. Defines input parameters (name or unique_id), description from prompt, and delegates execution to ModelsFetcher.fetch_model_parents.
    @dbt_mcp_tool( description=get_prompt("discovery/get_model_parents"), title="Get Model Parents", read_only_hint=True, destructive_hint=False, idempotent_hint=True, ) async def get_model_parents( context: DiscoveryToolContext, name: str | None = NAME_FIELD, unique_id: str | None = UNIQUE_ID_FIELD, ) -> list[dict]: return await context.models_fetcher.fetch_model_parents(name, unique_id)
  • Core helper function in ModelsFetcher that constructs GraphQL variables, executes the GET_MODEL_PARENTS query, and extracts the parents from the response.
    async def fetch_model_parents( self, model_name: str | None = None, unique_id: str | None = None ) -> list[dict]: model_filters = self._get_model_filters(model_name, unique_id) variables = { "environmentId": await self._paginator.get_environment_id(), "modelsFilter": model_filters, "first": 1, } result = await self.api_client.execute_query( GraphQLQueries.GET_MODEL_PARENTS, variables ) raise_gql_error(result) edges = result["data"]["environment"]["applied"]["models"]["edges"] if not edges: return [] return edges[0]["node"]["parents"]
  • GraphQL query schema definition for retrieving model parents, including common fields fragment for various node types.
    GET_MODEL_PARENTS = ( textwrap.dedent(""" query GetModelParents( $environmentId: BigInt!, $modelsFilter: ModelAppliedFilter $first: Int, ) { environment(id: $environmentId) { applied { models(filter: $modelsFilter, first: $first) { pageInfo { endCursor } edges { node { parents """) + COMMON_FIELDS_PARENTS_CHILDREN + textwrap.dedent(""" } } } } } } } """) )
  • Registration of get_model_parents (line 340) in the DISCOVERY_TOOLS list, which is bound and registered via register_discovery_tools function.
    DISCOVERY_TOOLS = [ get_mart_models, get_all_models, get_model_details, get_model_parents, get_model_children, get_model_health, get_exposures, get_exposure_details, get_all_sources, get_source_details, get_macro_details, get_seed_details, get_semantic_model_details, get_snapshot_details, get_test_details, ]
  • Tool name constant definition in ToolName enum.
    GET_MODEL_PARENTS = "get_model_parents"

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/dbt-labs/dbt-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server