Skip to main content
Glama
NiclasOlofsson

DBT Core MCP Server

get_column_lineage

Trace column-level lineage through SQL transformations, showing how columns flow via CTEs, joins, aggregations, and more. Supports upstream, downstream, or full bidirectional tracing.

Instructions

Trace column-level lineage through SQL transformations.

Uses sqlglot to parse compiled SQL and track how columns flow through:

  • CTEs and subqueries

  • JOINs and aggregations

  • Transformations (calculations, CASE statements, etc.)

  • Window functions

This provides detailed column-to-column dependencies that model-level lineage cannot capture.

Args: model_name: Name or unique_id of the dbt model to analyze column_name: Name of the column to trace direction: Direction to trace lineage: - "upstream": Which source columns feed into this column - "downstream": Which downstream columns use this column - "both": Full bidirectional column lineage depth: Maximum levels to traverse (None for unlimited) - depth=1: Immediate column dependencies only - depth=2: Dependencies + their dependencies - None: Full dependency tree

Returns: Column lineage information including: - Source columns this column depends on (upstream) - Downstream columns that depend on this column - Transformations and derivations - CTE transformation paths (via_ctes, transformations) - dbt resource mapping where available

Each dependency includes:
- column: Column name
- table: Source table name
- schema: Source schema (if available)
- database: Source database (if available)
- via_ctes: List of CTE names in transformation order
- transformations: Transformation details per CTE step
  - cte: CTE name
  - column: Column name at this step
  - expression: SQL expression (truncated to 200 chars)

Raises: ValueError: If model not found, column not found, or SQL parse fails RuntimeError: If sqlglot is not installed

Examples: # Find which source columns feed into revenue get_column_lineage("fct_sales", "revenue", "upstream")

# See what downstream models use customer_id
get_column_lineage("dim_customers", "customer_id", "downstream")

# Full bidirectional lineage for a column
get_column_lineage("fct_orders", "order_total", "both")

Note: Requires sqlglot package. Install with: pip install sqlglot The model must be compiled (run 'dbt compile' first).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
model_nameYes
column_nameYes
directionNoupstream
depthNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It explains that the tool parses compiled SQL, tracks columns through CTEs, JOINs, etc., and raises ValueError or RuntimeError for specific conditions. It also notes the need for sqlglot and compiled models.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with sections for Args, Returns, Raises, Examples, and Note. It is front-loaded with the purpose. However, it is somewhat lengthy and could be more concise, especially the detailed return description, but it earns its place given the complexity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of column-level lineage, the output schema exists, and the description covers inputs, outputs, error handling, dependencies, and prerequisites. Examples are provided. The tool is fully described for an AI agent to use correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, but the description thoroughly explains each parameter: model_name, column_name, direction (with three options and meanings), depth (with examples like depth=1, depth=2, None). It also details the return structure, adding significant meaning beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool traces column-level lineage through SQL transformations using sqlglot. It specifies the verb 'trace' and resource 'column-level lineage', and distinguishes it from siblings like 'get_lineage' which likely handles model-level lineage.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context on when to use the tool (to trace column dependencies) and includes prerequisites (sqlglot, compiled model). It gives parameter explanations and examples, but does not explicitly compare to sibling tools or state when not to use it.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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/NiclasOlofsson/dbt-core-mcp'

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