Warehouse Graph MCP Server
Builds a metadata and lineage graph from dbt artifacts, enabling lineage-aware analysis and querying over dbt project metadata.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
warehouse-graph
Shared foundation for two linked projects:
warehouse-qa: a governed, lineage-aware "ask your warehouse" assistantpipeline-sentinel: a tiered incident agent for data pipelines
This package will build a metadata/lineage graph from dbt artifacts, compile one policies.yml to database access controls (Postgres RLS / Unity Catalog), and serve the graph over an MCP server.
Status: Phase 9 (runs on Postgres and Databricks Unity Catalog). Done so far:
repo tooling and the LLM wrapper (cost ledger, cache, budget cap, Batch API)
Kiwi Retail Co., a deliberately messy synthetic warehouse: 40 dbt models, 13 metrics, 6 dashboards, 13 documented traps
the metadata graph: 575 nodes and 1,026 edges built from the dbt artifacts in ~10 s, with 97.8% column-level lineage and a Python query API
governance: one
policies.ymlcompiled to Postgres roles, RLS, column grants and masked views; role-filtered metadata; a description lint; an append-only audit log; and the 5-tool MCP serverUnity Catalog: the same
policies.ymlcompiled to per-principal catalogs, row filters and column masks, and tested against Postgres principal by principal
Quick start
cp .env.example .env # add ANTHROPIC_API_KEY for real model calls
uv sync
make warehouse # Postgres + synthetic data + dbt build + artifacts (~1 min)
make graph # make warehouse, then build the graph file (build/graph.wgz)
make policies # make graph, then lint + apply policies.yml (rerun after any dbt build)
make demo # make policies, then the Dagster UI at http://localhost:3000
make check # lint, format check, type-check, testsRelated MCP server: dagsmith
The demo warehouse: Kiwi Retail Co.
A fictional NZ/AU retailer: 12 stores (2 online), 9,000 customers, ~29k orders from Jan 2024 to Sep 2026, in NZD and AUD.
raw.* (11 tables, seeded generator)
└─ staging (11 views) ─ intermediate (9 views) ─ marts (20 tables)
├─ core: customers, products, stores, employees, orders, items, payments, refunds
├─ finance: fct_revenue_daily (canonical revenue), rpt_revenue_by_region
├─ marketing: campaigns, ad spend, campaign performance
├─ customers: churn, LTV, active customers
└─ legacy: orders_v1 (deprecated), rpt_regional_sales_legacy (fan-out)Piece | Where |
Generator and loader |
|
dbt project (models, tests, freshness, exposures, Semantic Layer metrics) |
|
Tribal knowledge attached to nodes |
|
Validated question → SQL examples |
|
Orchestration (nightly |
|
Artifacts for the graph |
|
Planted traps and their measured effects |
The metadata graph
warehouse-graph build turns the four dbt artifacts, caveats.yml and query_examples.yml into one versioned file, build/graph.wgz. It holds a NetworkX graph, a local sentence-transformer embedding per node, and the manifest hash. It loads into memory in under a second and needs no database.
Nodes | Edges |
|
|
Every node carries the governance metadata later phases need: owner, deprecation + replacement, planted-trap flags, and PII/sensitivity tags, which spread along pass-through column lineage down to the raw tables. Counts and lineage coverage are in docs/graph-stats.md.
from pathlib import Path
from warehouse_graph.graph import GraphArtifact, GraphQuery
q = GraphQuery(GraphArtifact.load(Path("build/graph.wgz")))
q.search_nodes("churn rate", k=5) # hybrid BM25 + vector, reciprocal-rank fused
q.get_node("model.orders_v1") # record + caveats + columns (deprecated -> fct_orders)
q.get_lineage("column.fct_revenue_daily.net_revenue_nzd", "upstream", depth=10, level="column")
q.get_blast_radius("source.shop.orders") # downstream models, dashboards, metrics by criticality
q.get_metric("revenue") # definition + SQL; canonical_alternative = net_revenueThese five operations become the five MCP tools in Phase 3.
Lineage of the canonical revenue model (warehouse-graph lineage model.fct_revenue_daily --direction both):
flowchart LR
model_fct_revenue_daily["fct_revenue_daily"]:::model
exposure_executive_revenue_dashboard[/"executive_revenue_dashboard"/]:::exposure
metric_gross_revenue{{"gross_revenue"}}:::metric
metric_net_revenue{{"net_revenue"}}:::metric
model_fct_orders["fct_orders"]:::model
model_fct_refunds["fct_refunds"]:::model
model_rpt_revenue_by_region["rpt_revenue_by_region"]:::model
model_int_orders__enriched["int_orders__enriched"]:::model
model_int_orders__item_totals["int_orders__item_totals"]:::model
model_int_payments__by_order["int_payments__by_order"]:::model
model_int_refunds__by_order["int_refunds__by_order"]:::model
model_stg_shop__refunds["stg_shop__refunds"]:::model
model_int_order_items__priced["int_order_items__priced"]:::model
model_stg_shop__orders["stg_shop__orders"]:::model
model_stg_shop__payments["stg_shop__payments"]:::model
model_stg_shop__stores["stg_shop__stores"]:::model
source_shop_refunds[("shop.refunds")]:::source
model_stg_shop__order_items["stg_shop__order_items"]:::model
model_stg_shop__products["stg_shop__products"]:::model
source_shop_orders[("shop.orders")]:::source
source_shop_payments[("shop.payments")]:::source
source_shop_stores[("shop.stores")]:::source
source_shop_order_items[("shop.order_items")]:::source
source_shop_products[("shop.products")]:::source
model_fct_revenue_daily --> exposure_executive_revenue_dashboard
model_rpt_revenue_by_region --> exposure_executive_revenue_dashboard
model_fct_revenue_daily --> metric_gross_revenue
model_fct_revenue_daily --> metric_net_revenue
model_int_orders__enriched --> model_fct_orders
model_int_orders__item_totals --> model_fct_orders
model_int_payments__by_order --> model_fct_orders
model_int_refunds__by_order --> model_fct_orders
model_int_orders__enriched --> model_fct_refunds
model_stg_shop__refunds --> model_fct_refunds
model_fct_orders --> model_fct_revenue_daily
model_fct_refunds --> model_fct_revenue_daily
model_stg_shop__order_items --> model_int_order_items__priced
model_stg_shop__orders --> model_int_order_items__priced
model_stg_shop__products --> model_int_order_items__priced
model_stg_shop__orders --> model_int_orders__enriched
model_stg_shop__stores --> model_int_orders__enriched
model_int_order_items__priced --> model_int_orders__item_totals
model_stg_shop__payments --> model_int_payments__by_order
model_stg_shop__refunds --> model_int_refunds__by_order
model_fct_revenue_daily --> model_rpt_revenue_by_region
source_shop_order_items --> model_stg_shop__order_items
source_shop_orders --> model_stg_shop__orders
source_shop_payments --> model_stg_shop__payments
source_shop_products --> model_stg_shop__products
source_shop_refunds --> model_stg_shop__refunds
source_shop_stores --> model_stg_shop__stores
classDef source fill:#e8f0fe,stroke:#4a6fa5
classDef model fill:#f4f4f4,stroke:#666
classDef metric fill:#e6f4ea,stroke:#3c8d5a
classDef exposure fill:#fff4e5,stroke:#c77700
classDef column fill:#fafafa,stroke:#999
classDef flagged stroke:#c62828,stroke-width:2px,stroke-dasharray:4 2Governance: one policy file, enforced by the database
The LLM is never the enforcement point. policies.yml defines six principals: admin, finance, marketing, analyst_au, analyst_nz and the sentinel service principal. For each, it sets the schemas they may use, a row filter, and hidden or masked columns, selected by the graph's PII tags (pii:email, sensitivity:restricted, ...).
warehouse-graph policies resolves that file against the graph, refuses to continue if any visible description mentions a hidden column, and compiles it to Postgres:
Control | How |
Identity | one LOGIN role per principal: NOINHERIT, read-only, 30 s statement timeout, so no |
Rows | RLS on the tables behind |
Hidden columns | never granted (column-level grants), and removed from the principal's metadata |
Masked columns |
|
Metadata | each principal gets its own filtered graph; a hidden id is "not found", exactly like a made-up one |
Audit |
|
The SQL is the same for every role (select email from marts.dim_customers); the database decides what comes back. Design: D13-D15 in docs/design-decisions.md.
Runs on Postgres and Databricks Unity Catalog
The same dbt project, the same policies.yml and the same marts.<table> SQL run on both. Only the compiler and the adapter differ.
Control | Postgres ( | Unity Catalog ( |
Rows | RLS on | view predicate and native row filter on |
Masked columns |
| view and native column mask |
Hidden columns | no column grant | not in the principal's catalog of views; NULL in the base table |
Reach | schema and column grants | granted its own catalog only; catalog-qualified SQL is refused |
Identity | one login role per principal | one user per principal |
uv sync --extra databricks # DATABRICKS_* in .env (see .env.example)
uv run warehouse-graph demo-data --target databricks --stale ad_spend
uv run warehouse-graph demo-build --target databricks # dbt-databricks, isolated with uvx
uv run warehouse-graph policies --backend databricks # rerun after every dbt build
WG_DATABRICKS_TESTS=1 uv run pytest -m databricks # compare with local PostgresTested live, for all six principals: same row counts in every visible table, same visible columns, same non-null and distinct counts in every marts column, identical masked values, and hidden columns and unseen tables that don't exist. The native filters alone (no views) give the same access. Breaking a view or a mask on purpose fails the tests.
Not tested: that a second user is refused outside its own catalog, because the Free Edition workspace has one user (D18). Queries only ever compare access: accuracy is evaluated on Postgres.
MCP server
Both projects reach the graph only through these five tools, always as the caller's principal:
Tool | Returns |
| hybrid-ranked nodes with scores, trap and deprecation flags |
| full record including caveats and columns |
| subgraph at model or column level |
| downstream models, dashboards and metrics, ranked by criticality |
| definition, canonical SQL and the canonical alternative |
uv run warehouse-graph mcp --identity analyst.au@kiwiretail.example # stdio; add --audit to log callsInput and output schemas are pinned in schemas/mcp/v1/. Prior art: dbt Labs ships an official dbt-mcp server (lineage, Semantic Layer, text-to-SQL). This one differs in three ways: caveat and trap nodes, metadata filtered per role by the same policy the database enforces, and the eval harness built on top of it (Phases 4-8).
Docs
docs/design-decisions.md: decisions and whydocs/planted-traps.md: the 13 traps the evals are built arounddocs/graph-stats.md: node/edge counts and column-lineage coveragedocs/parking-lot.md: ideas deliberately left out of v1
Licence
MIT. See LICENSE.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
Related MCP Connectors
The grounded data layer for any LLM: governed SQL, metrics, lineage and catalog over your data.
Define, ship & query your analytics tracking from one source of truth, trusted by humans and agents.
Cross-tool context for your data stack. Search, lineage, and impact across warehouse and BI tools.
Provenance-first database for teams and agents: every value carries sources, rules and coverage.
Related MCP Servers
- AlicenseBqualityCmaintenanceA read-only MCP server that exposes dbt project artifacts and data quality result tables (BigQuery/Postgres) to LLM clients, enabling deep introspection, run-history analysis, source freshness, test coverage, and lineage walks.2756 npmMIT
- AlicenseNot gradedqualityDmaintenanceMCP server providing read-only Snowflake metadata tools (schemas, tables, queries, lineage) for agentic data pipeline generation, enabling natural-language-to-pipeline workflows with dbt, Airflow, and Great Expectations.1MIT
- AlicenseNot gradedqualityBmaintenanceEnables agents to inspect dbt model semantics, retrieve contracts and lineage, and verify that edits do not change what models mean.Apache 2.0
- AlicenseAqualityCmaintenanceExposes a governed semantic layer to AI agents so they select metrics and dimensions from a closed, engineer-declared vocabulary instead of writing SQL. Validates every typed call against the contract, rejects out-of-contract requests with structured errors and suggestions, and returns query rows together with the compiled SQL and dbt lineage for auditing.4MIT