
dbt-lineage
io.github.sipemu由 GitHub 账号 sipemu 发布v0.15.0更新于 Nov 6, 2026
dbt model and column lineage, downstream impact and test proposals; no warehouse or dbt compile
概览
本地 stdio MCP 服务器,让助手无需数据仓库即可获取 dbt 模型与字段血缘、下游影响分析和测试建议。
- 可以做什么
- 汇总并搜索 dbt 项目的模型、标签与孤立模型
- 追踪模型及单个字段的上游与下游血缘
- 评估变更的下游影响,并读取模型详情与 SQL
- 打包血缘上下文,并为模型提出测试建议
- 以资源形式提供模型 SQL、血缘图和 exposure 元数据,并附带影响评审、文档编写等预设提示词
- 适用场景
- 适合需要让助手理解 dbt 项目依赖关系的场景:评审变更会影响哪些下游、解释字段如何派生、规划重建范围,或为模型起草测试与文档。
- 运行要求
- 以本地进程方式运行,通过 dbt-lineage mcp 命令启动,并指向项目目录或 manifest.json。需先安装 dbt-lineage 可执行文件(crates.io、pip、Homebrew、预编译二进制或源码)。无需连接数据仓库、无需 dbt compile,也不需要 API 密钥或环境变量。
安装
在 SourceWeft 中
- 打开 控制台中的 dbt-lineage,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
dbt-lineage
[CI] [Crates.io] [docs.rs] [codecov]
[dbt-lineage PR comment: lineage diff, column impact, and a downstream impact diagram reaching two dashboards]
Every dbt PR gets one comment: what changed, which downstream columns and dashboards it breaks, and what to rebuild. Live demo →
See what a dbt change breaks — downstream models, columns, dashboards and contracts — before it ships. dbt-lineage parses your project directly (no warehouse, no Python, no dbt compile) and puts lineage and impact wherever you work.
Use it where you work
Features
Source modes
- Direct SQL parsing — extracts
ref()andsource()via a Jinja-aware lexer, nodbt compileneeded - Manifest support — optionally read
manifest.jsonfor column metadata, materializations, and full graph fidelity - Jinja-aware dependencies — finds
ref()/source()anywhere in Jinja ({% set x = ref('a') %},dbt_utils.star(from=ref('a')), versioned refs), follows macros that reference models (project and installed packages, includingadapter.dispatch), and expands loops over literal lists. Check it on your project withverify; see Accuracy - Parallel parsing + on-disk cache —
rayon-parallelized parsing and a content-hash cache at.dbt-lineage/cache.bin; warm runs are near-instant on large monorepos. Bypass with--no-cache. Seedocs/CACHE.md
Analysis subcommands
summary— one-shot project overview (counts, tags, top fan-out, orphans)impact <model>— downstream impact with severity scoring (Critical / High / Medium / Low)diff --base <ref>— compares lineage between git refs, showing added / removed / modified nodes and edgesplan --base <ref>— emits a dbt selector for the minimal rebuild set; pipes intodbt run -s "$(…)"coverage— tests-per-model + per-column map; text, JSON, or SARIF (PR annotations)lint— flags unused sources, undefined refs, dead-end models, missing descriptions, models with only unresolved upstream, circular refssite— static lineage site (search, per-node pages with lineage diagram, column-level lineage, SQL) for GitHub/GitLab Pagesdocs— generates per-model Markdown with description, upstream / downstream, columns, embedded Mermaid lineageperf— joinsrun_results.jsonwith the DAG: slowest models, critical pathsverify— compares parsed lineage with dbt'smanifest.jsonand lists every dependency that differs; exits non-zero when parsing missed onecheck-manifest— flags drift betweenmanifest.jsonand current SQL files using dbt's recorded SHA-256 (mtime fallback); exits non-zero for CI gating
Column-level lineage
- AST-backed analyzer via
sqlparser(0.6.0+) handles aliases, JOINs, aggregations, and CTEs with proper transformation classification (Direct,Aliased,Derived) - Regex-based analyzer remains as a fallback for dialect-specific syntax sqlparser can't yet parse
MCP server (AI-agent integration)
dbt-lineage mcp— stdio Model Context Protocol server. Seedocs/MCP.mdfor setup and cookbook.- 10 tools:
summary,search_models,lineage,impact,get_model_details,read_model_sql,column_upstream,column_downstream,lineage_bundle,propose_test - Resources: model SQL, focused lineage diagrams, source/exposure metadata, always-fresh summary
- Prompts:
review-impact,propose-tests,explain-column,find-bottleneck,document-model,onboard-project
Output
- 6 formats — ASCII, Graphviz DOT, JSON, Mermaid, self-contained SVG, interactive HTML (pan / zoom / search)
- Mermaid niceties —
--show-columnsinlines column names in node labels;--group-by directoryemits Mermaid subgraphs - Graph collapse —
--collapse/--collapse=focaldrops intermediate nodes and labels transitive paths with(via N)edges - Structured errors —
--error-format jsonwrites{level, what, why, hint}to stderr for deterministic agent / CI consumers
Editor integration
dbt-lineage lsp— language server: hover and go-to-definition onref()/source(), lineage code lens per model, lint diagnostics. VS Code extension on the Marketplace and Open VSX (code --install-extension sipemu.dbt-lineage-viewer); Neovim and Helix setup indocs/EDITORS.md
Interactive TUI
- Navigate, search, and explore lineage in a terminal UI (
ratatui) with Unicode box-drawing nodes, orthogonal edge routing, and full mouse support - Run dbt from TUI — execute
dbt run/dbt teston selected models with scope control (+upstream,downstream+,+all+) via keyboard menu or right-click context menu - Run status tracking — color-coded nodes show success (green), error (red), outdated (yellow), or never-run (default)
- Path highlighting — trace upstream / downstream paths with impact analysis
Filtering and node types
- Selector expressions —
-s tag:finance,path:martsfilters by tag, path, or model name (comma-separated) - Node-type filters —
--include-tests,--include-seeds,--include-snapshots,--include-exposures - Node-type support — models, sources, seeds, snapshots, tests, exposures
Accuracy
dbt-lineage reads dependencies from your SQL without running dbt, so it can
miss dependencies that only exist once Jinja is rendered. dbt-lineage verify
measures that on your own project against a manifest.json from dbt parse.
Results on public dbt projects (manifests from dbt parse, dbt Core 1.12 with
the DuckDB adapter; packages measured through their integration_tests
project). scripts/accuracy/run.py produces this
table, and CI runs it on every parser change and weekly, failing on any missed
dependency:
Every extra dependency sits in a Jinja branch switched off by the project's
current vars ({% if var('hubspot_property_enabled') %}). dbt records only the
branches it renders; dbt-lineage keeps them so impact analysis doesn't miss a
dependency that a var can switch on.
What parsing can't follow: refs whose names are computed at render time from
variables or macro return values. verify lists those, and any command reads
--manifest for exact lineage when you need it.
Column lineage
Column impact ("removing stg_orders.customer_id breaks orders.customer_id")
is measured the same way against a reference: sqlglot
column lineage over the SQL dbt compiled after dbt seed and dbt run on
DuckDB (scripts/accuracy-columns/). CI re-runs
it alongside the model check and fails when a number drops below its
baseline. Packages are measured from their integration_tests project,
where dbt ran: its vars reach the package's models as a root project's do.
From SQL alone, columns of models written in SQL are traced completely,
through CTEs, subqueries, joins, unions and select *. Where Jinja writes
the SELECT (loops, macros producing column lists or whole queries, as in
Fivetran's packages), dbt-lineage renders the model the way dbt compile
would, without dbt or a warehouse: the project's and installed packages'
macros (dbt_packages/, with adapter.dispatch), vars (the root
project's over each package's own), graph.nodes / graph.sources from the
parsed project, and the columns it
already knows for each upstream relation (YAML, seed headers, upstream
models) answering adapter.get_columns_in_relation. What stays out of reach
offline: macros that read data (pivots over dbt_utils.get_column_values,
run_query results; ci report lists such models as lineage gaps), columns
of sources that YAML doesn't declare, and staging models over those (Fivetran's
_tmp pass-throughs); the catalog closes most of that gap.
With dbt artifacts: when target/manifest.json holds dbt's compiled SQL
(from dbt compile or dbt run), column lineage reads it for every model
whose file still matches the checksum dbt recorded, so an outdated manifest
never stands in for edited code. target/catalog.json (from dbt docs generate) adds the warehouse's actual columns, so select * from a source
expands to columns YAML doesn't declare. For PR column impact, give ci report the base branch's manifest too (--base-manifest, e.g. the
production manifest many teams keep for slim CI) and run dbt compile in the
PR job; with compiled SQL on one side only, both sides use raw SQL so the
before/after columns are inferred the same way.
Where Jinja decides lineage at render time, the PR comment says so: a
Lineage may be incomplete section lists the affected models on the
impact path and why (a ref() with computed arguments, or columns written by
a loop or macro), so a short impact list isn't mistaken for a complete one.
Compared with dbt's own tools
dbt Labs' new engine (dbt v2, formerly "Fusion", GA since September 2026) also understands SQL statically, and its VS Code extension shows table-level lineage while you edit, and column-level lineage in strict mode. They solve different parts of the problem; as of November 2026:
Sources: supported features, new concepts, Advanced CI, licensing FAQ.
The two combine well: dbt's extension for type checking while you write SQL, dbt-lineage for reviewing what a pull request breaks downstream, on any CI.
Installation
From crates.io
pip / uv (no Rust needed)
Homebrew (macOS, Linux)
With cargo-binstall (no compile)
Pre-built binaries
Every tagged release ships pre-built binaries for Linux (x86_64 + aarch64), macOS (Intel + Apple Silicon), and Windows (x86_64) as downloadable assets on the Releases page. Download the archive for your platform, extract, and put the binary on your PATH.
As a GitHub Action
Live demo: sipemu/dbt-lineage-demo#1 shows the PR comment (lineage diff with SQL body changes, column impact, Mermaid impact diagram, rebuild selector, lint); sipemu.github.io/dbt-lineage-demo is the same project as a dbt-lineage site.
@v0 tracks the latest 0.x release; pin an exact tag (e.g. @v0.9.1) if you prefer. The action installs the matching dbt-lineage binary from this repo's release artifacts, runs summary, diff, plan, and optionally lint/coverage SARIF, then posts a single sticky comment on the PR with the rendered report. See action.yml for the full input/output reference.
To check dbt-lineage against dbt on your own project in every PR, run dbt parse first (it needs your profiles.yml but never connects to the warehouse) and set verify: true; the comment then reports how much of dbt's lineage was found, and fail-on: verify-missed fails the check when a dependency was missed:
Container image
Published to ghcr.io/sipemu/dbt-lineage on every release (latest, v0, 0.x, 0.x.y; amd64 + arm64), with git included for diff / plan / ci report. In GitLab CI, override the entrypoint:
As a pre-commit hook
From source
The binary is installed to ~/.cargo/bin/dbt-lineage.
Usage
Static output
Interactive TUI
Breaking changes to governed models
diff, ci report and the PR comment flag changes that break consumers of governed models (dbt 1.5+ model governance in schema YAML):
- contracted models (
config: {contract: {enforced: true}}): a contract column removed or itsdata_typechanged, or the contract dropped; accessnarrowed (public→protected→private);- a model version (
versions:) or a governed model removed.
ci report --fail-on breaking-changes fails the check. lint adds a private-ref error for refs to access: private models from outside their group, which dbt rejects at parse time.
Impact analysis
Compute downstream impact for a model with severity scoring:
Severity levels:
- Critical — impacts exposures (dashboards, reports)
- High — impacts table/incremental materializations or mart models
- Medium — impacts staging or intermediate models
- Low — impacts tests only
Lineage diff
Compare lineage between git refs to see what changed:
Shows added, removed, and modified nodes and edges with a summary of changes.
Static lineage site
A self-contained static site — search, one page per model/source/seed/exposure with its lineage diagram, columns with column-level lineage, and highlighted SQL — ready for GitHub or GitLab Pages:
Light/dark, phone-friendly, no server or CDN. See docs/SITE.md for Pages workflows.
Project summary
One-shot project overview, designed as the first thing an agent (or human) runs against an unfamiliar dbt project:
Reports counts per node type, tag distribution, top downstream-reach models, and orphan models (no downstream consumers).
BI dashboards as exposures
Generate dbt exposures from Metabase, anofox-visualization, Tableau, Looker, Superset or Power BI dashboards, so impact analysis knows which dashboards a change reaches:
From a LookML project, offline (LookML dashboards → explores → views → tables):
From anofox-visualization dashboards (DuckDB .sql files with ::ROLE panels):
From Tableau workbooks, offline (.twb / .twbx):
From Superset dashboard exports, offline (ZIPs from superset export-dashboards or the UI; dashboard → charts → datasets → tables, virtual-dataset SQL included):
From Power BI, offline: PBIP projects (*.Report + *.SemanticModel, TMDL or model.bim) and .pbit templates; tables come from the partitions' Power Query (M) sources and native SQL:
Tables the dashboards read are mapped onto models and sources; unmatched tables are listed on stderr. See docs/BI.md.
CI report
One Markdown report for PR/MR comments — lineage diff, rebuild selector, manifest freshness, lint, and project summary — plus exit codes for gating:
--base auto (default) reads the target branch from GitHub Actions, GitLab CI, Bitbucket Pipelines or Azure Pipelines, and resolves it as origin/<branch> (fetching it if the checkout is shallow). --outputs appends selector=… and failed=… lines, usable as $GITHUB_OUTPUT or a GitLab dotenv report. dbt-lineage ci comment --file report.md posts it as one sticky PR/MR comment, and dbt-lineage ci annotations --format sarif|codeclimate|bitbucket|azure turns lint findings into inline annotations (Bitbucket Code Insights with --post). The GitHub Action, the GitLab component, the Bitbucket Pipe and the Azure Pipelines template are thin wrappers around these commands; see docs/CI.md.
Verify lineage against dbt
Measure how closely parsed lineage matches dbt's own on your project:
verify compares the upstream models, seeds, snapshots and sources of every model in both graphs and lists dependencies dbt has that parsing missed, dependencies parsing found that dbt doesn't record (usually Jinja branches switched off by vars), and models only one side knows. Run it in CI next to dbt parse to keep SQL-parse mode honest on your project.
Manifest freshness
CI-friendly drift check between a distributed manifest.json and current SQL files:
Flags three kinds of drift: SQL files referenced by the manifest that are now missing, files modified since the manifest was generated, and SQL files added but not yet compiled into the manifest.
Graph collapse
Collapse intermediate nodes so big projects render as just their endpoints, with transitive paths labeled (via N):
Positional focus models (e.g. dbt-lineage orders --collapse) are always preserved even when they would otherwise be classified as intermediate.
Mermaid options
Structured errors for agents and CI
--error-format json writes one JSON object per line to stderr. stdout is unaffected, so piping into jq still works.
Editor integration (language server)
dbt-lineage lsp serves the Language Server Protocol over stdio: hover and go-to-definition on ref() / source(), a code lens with upstream/downstream counts and impact on every model, and lint findings as diagnostics. Use the VS Code extension in editors/vscode, or point Neovim, Helix or any LSP client at dbt-lineage lsp. See docs/EDITORS.md.
MCP server
Expose lineage as stdio MCP tools, resources, and prompts that Claude Code, Claude Desktop, and other MCP-aware clients can call directly:
Works in both SQL-parse and manifest mode (target/manifest.json is picked up automatically when present). Tools: summary, search_models, lineage, impact, get_model_details, read_model_sql, column_upstream, column_downstream, lineage_bundle, propose_test; plus model resources and predefined prompts. MCP Registry name: mcp-name: io.github.sipemu/dbt-lineage. See docs/MCP.md for client setup, prompt walkthroughs, and composition recipes.
CLI Reference
Run dbt-lineage <command> --help for per-subcommand options.
TUI Keybindings
Navigation
Mouse
Search
Analysis
Node list panel
Running dbt
Run menu / context menu options:
General
Node colors in TUI
By run status (when target/run_results.json exists):
By node type (when never run):
How it works
- Parse
dbt_project.ymlto find model/seed/snapshot paths (or readmanifest.json) - Walk those directories, collecting
.sqland.ymlfiles - Extract
ref('model')andsource('schema', 'table')from the Jinja in each SQL file (after a lexer blanks out comments and string literals), including calls inside macros the model uses and loops over literal lists - Parse YAML schema files for sources, model descriptions, and exposures
- Build a directed acyclic graph (petgraph) where edges flow from dependency to dependent
- Resolve column-level lineage by tracing SELECT/FROM/JOIN through the graph
- Filter by focus model, depth, selectors, and node type
- Layout using a Sugiyama-style layered algorithm (longest-path layering + barycenter ordering)
- Render as ASCII, DOT, JSON, Mermaid, SVG, HTML, or interactive TUI
uv / virtualenv support
When running dbt from the TUI, the tool auto-detects whether to use uv run dbt or plain dbt:
- If
uv.lockorpyproject.tomlexists in the dbt project directory, usesuv run dbt - Otherwise, if
dbtis on PATH, uses it directly - If
dbtis not on PATH butuvis, falls back touv run dbt
Building without TUI
The TUI is enabled by default. To build a minimal binary with only static output:
Further reading
CHANGELOG.md— per-release notes from 0.1.0 onward.docs/MCP.md— cookbook for the MCP server: setup, tool reference, prompt walkthroughs, composition recipes.docs/CACHE.md— parse-cache contract, file format, when it helps.BENCHMARKS.md— baseline numbers from the bench harness.
Credits
The agent-oriented additions in 0.3.0 — summary, check-manifest, mcp, --collapse, --error-format json, and the Mermaid --show-columns / --group-by directory options — were inspired by eitsupi/dlin, a hard fork that focuses on non-interactive (CI/agent) workflows. dbt-lineage retains its TUI focus and brings these ideas back upstream.
License
MIT
来源:README.md,提交 73d7d04
工具
0版本历史
2- v0.19.0Nov 7, 2026
- v0.15.0最新Nov 6, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分