
dbt-plan
io.github.PresentJay由 GitHub 账号 PresentJay 发布v0.18.6更新于 Nov 3, 2026
Predicts the DDL a dbt change will execute, before you run it. Reads files, not the warehouse.
概览
dbt-plan 的本地 MCP 服务器,让助手在运行 dbt run 之前预测 dbt 变更将执行的 DDL,并标出有风险的 schema 变更。
- 可以做什么
- 对已编译的 dbt 产物执行 plan 检查,返回 safe、warning 或 destructive 判定及逐模型操作
- 为当前编译 SQL 与 manifest 建立基线快照,供后续比较
- 查看预测的 DDL,例如新增或删除列、替换表以及配置变更
- 读取单独的 refusals 列表,了解分析拒绝判断的内容
- 将工具指向自定义项目目录或产物目录
- 适用场景
- 适合代理修改 dbt 模型或宏时使用:在真正对仓库执行之前,判断该变更是否会删除列、破坏下游模型或违反契约。它是仓库连接型工具之前的低成本离线关卡,仅依赖编译产物即可运行。
- 运行要求
- 以本地 stdio 进程运行,从 PyPI 安装带 mcp 附加项的 dbt-plan 包;需要 Python 3.10+ 与 dbt-core 1.7+(或 dbt Fusion 引擎)。分析只读取本地编译 SQL 与 manifest 文件,因此项目需先完成编译;检查本身不需要仓库连接或凭据。
安装
在 SourceWeft 中
- 打开 控制台中的 dbt-plan,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
dbt-plan
Static analysis tool that warns about risky DDL changes before dbt run.
Like terraform plan for dbt, and used the same way: you run it before the thing
that changes your warehouse, not only in CI afterwards.
Analyzes compiled SQL files from warehouses including Snowflake, BigQuery, Redshift, Postgres and DuckDB through one code path. SQL dialect support varies; see analysis limits.
What It Looks Like
What It Does
dbt-plan analyzes compiled SQL diffs to catch dangerous schema changes at PR time:
- Column changes: detects ADD/DROP COLUMN from SQL diff
- Risk assessment: judges safety based on materialization x on_schema_change rules
- Cascade analysis: finds downstream models broken by a dropped column — the ones that
name it, resolved against the project's own schema rather than matched as text; the ones
that select
*and lose it without their own file changing; and the tests whose fixtures pin it down. Names the exposures whose owners need telling - Contracts: reports a change an enforced contract will reject, in either direction
- Config changes: detects materialization or on_schema_change policy changes
- Type changes: compares explicit
CASTtypes between revisions SELECT *resolution: reads the columns from the CTEs of the same statement, and follows aref()into the referenced model's compiled SQL
The analysis reads files, compares them, and warns; it does not connect to a warehouse or simulate dbt run. The optional dbt-plan run workflow invokes your compile command, which can require credentials and execute macros.
Quick Start
See a result without a warehouse
The repository includes before/after compiled SQL and a manifest, so you can try the analysis without installing dbt or configuring warehouse credentials:
The sample prints text, GitHub markdown and JSON output. It intentionally contains a
dropped column, so the inner check reports exit code 1 (destructive); the example
script itself completes successfully. See the sample scenario for
the expected finding.
Use it with your dbt project
dbt-plan run does the whole thing in one command and needs whatever credentials your
dbt compile normally needs. If your project already has compiled artifacts, use
dbt-plan check directly; it only reads local files and does not connect to a warehouse.
The loop it is built for
Once you have a baseline, the inner loop is a single sub-second command. Edit a model or a
macro, recompile, and see what dbt run would do — before running it:
dbt-plan check reads local compiled artifacts. Its latency is separate from
dbt compile, which can depend on your adapter, macros, and warehouse.
See the reproducible CLI benchmark for measured workloads,
raw samples, and commands to measure your machine.
Working with a coding agent
An agent editing models cannot eyeball a diff and hesitate. Give it the check and the reasons behind it:
The guidance leads with what an agent most often gets wrong: adding a model to
ignore_models, or downgrading on_schema_change from sync_all_columns to ignore,
silences a real finding without making the change safe.
Or give it the check as an MCP tool:
plan returns the verdict, the per-model operations, and — separately — a refusals
list naming everything dbt-plan declined to judge. That separation is the point: a person
reading "safe" may still glance at the diff, an agent reading it proceeds, so a
non-empty refusals must never be collapsed into the verdict.
Both tools accept target_dir when dbt writes artifacts outside the default target/,
for example plan(project_dir=".", target_dir="build").
The server is a separate package from the analysis core. The core is offline and
synchronous by design and tests/test_invariants.py fails the build on an asyncio or
network import anywhere inside it; an MCP server is both, so keeping them apart is what
keeps that guarantee provable.
Registry entry — the line below is how the MCP registry verifies that whoever publishes the entry also owns this PyPI package, so it has to stay in the README that ships:
More commands
--select accepts model names and optional upstream/downstream + operators;
comma-separated terms form a union. In the next minor release, unsupported or
unknown selections fail with exit 3. Use explicit version names such as
fct_orders_v2. See the selection contract and examples.
Scope
dbt-plan is a static analysis warning tool, not a runtime simulator.
Design principle: false warnings are OK, false safe is never OK.
When to use it
dbt-plan answers a narrower question than the warehouse-connected tools (Recce, SQLMesh, data-diff) and costs nothing to run, so it works as the cheap gate in front of them — and on the Fusion engine, which compiles without a warehouse connection, that includes fork pull requests where they cannot run at all. See use cases for the comparison, real timings, and what it gets wrong.
Deliberately Not Planned
Ideas that look useful but contradict what this tool is:
DDL Prediction Rules
Under a contract, a column's declared data_type is compared with its explicit CAST,
by family -- text against number against date/time against boolean. varchar and text
are the same family and not a finding; varchar and integer are a build failure.
Comparing more finely means a per-adapter type table, and a wrong answer about a type is
worse than no answer.
"Not set by you" means the author wrote no on_schema_change, in the model or in
dbt_project.yml. dbt resolves one for every model regardless, so the resolved value
asserts nothing; an explicit setting is a claim about how that materialization behaves
and is honoured. dbt-plan reads unrendered_config to tell them apart.
An enforced contract inverts the rules above: dbt requires every column to be declared,
so a column added to the SQL fails the build just as a removed one does. Names only —
dbt compares its declared data_type against the warehouse, which dbt-plan does not read.
CI Integration (GitHub Actions)
This example assumes a checked-in uv.lock with your dbt adapter included. The
virtual environment lives outside the checkout so changing revisions cannot replace
it. With pip/requirements.txt, install your adapter before the Action and use the
default dbt compile command. Run dbt deps first if your project uses dbt packages.
Keep the pull_request trigger. Never switch it to pull_request_target — dbt compile
runs Jinja and macros written in the pull request, so that would hand your warehouse
credentials to code from any fork.
Outputs verdict (safe / destructive / warning), exit-code, and report
(path to the JSON report), so a later step can comment on the PR or open a ticket.
For a workflow you own outright rather than a wrapped action, dbt-plan ci-setup
generates one with credential wiring and least-privilege notes inline. The next-minor
generator supports pyproject.toml/uv.lock and requirements.txt, installs dbt and
dbt-plan in one environment, and separates summary rendering from its gate. The default
FAIL_ON: destructive allows warnings but always blocks execution errors. Regenerate
existing workflows to adopt it; see docs/ci-integration.md.
Exit codes
The next minor release separates execution failures from review findings (a breaking change from 0.15.x). This contract is implemented on main and is not yet released.
warning_exit_code still controls review findings; its default remains 2.
Setting it to 0 does not suppress execution errors. Code 3 is reserved and cannot
be used for warnings. The Action fails on execution errors even with fail-on: never.
See the migration guide before upgrading a CI script or pinned Action.
How It Works
Contributing
See CONTRIBUTING.md for development setup, TDD workflow, and coding rules.
First contribution? Choose a small, ready task: SQL fixtures, documentation or a sample-script fix, with exact expected results and no warehouse credentials required.
CI feedback for contributors: PRs to this repository get one automatically
updated status comment with the tested commit, approval waits, and links to failed
jobs. Comment /ci to refresh it, or /ci retry to retry a transient failure.
External contributions still need a maintainer's execution approval; retrying does
not bypass it. See commands and limits.
This helper is for contributions to dbt-plan itself, separate from the GitHub Action
you install in your own dbt project.
Architecture
How to Contribute
Where to start: the open issues, particularly those labelled good first issue. Each starter issue has an agreed scope, expected results and validation commands. Check its assignee and recent comments, then confirm ownership before starting.
Design decisions: See docs/design-notes.md.
Supported
- dbt-core 1.7+, and the dbt Fusion engine (verified against
2.0.0-preview.218) - Snowflake, BigQuery, Redshift, Postgres, DuckDB and other mapped adapters: dialect inferred from the manifest. Unmapped adapters fall back to Snowflake; see analysis limits.
- Python 3.10+
- CTE, UNION ALL, QUALIFY, window functions, VARIANT access
License
Apache-2.0
For adapter dialect fallback, dbt Mesh consumers, and stars over sources or seeds,
see analysis limits. For CLI compile_command argv
semantics, the Action's shell command input, and dbt deps setup, see
compile commands.
来源:README.md,提交 4caa03d
工具
0版本历史
8- v0.18.6最新Nov 3, 2026
- v0.18.5Oct 29, 2026
- v0.18.3Oct 26, 2026
- v0.18.2Oct 22, 2026
- v0.18.1Oct 10, 2026
- v0.18.0Oct 6, 2026
- v0.17.0Sep 25, 2026
- v0.16.1Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分