Understory
Exposes a client's dbt semantic layer through MCP, reading semantic manifests and supporting MetricFlow and dbt Cloud for querying metrics and dimensions.
Provides a warehouse adapter for DuckDB, allowing the server to query DuckDB databases when answering analytics questions.
Enables integration with Slack bots, allowing employees to ask natural-language analytics questions and receive answers in Slack.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@UnderstoryWhat were our sales in the US in March 2025?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Understory
The natural-language interface for analytics, by Polyculture Research.
Understory is an MCP server that exposes a client's dbt semantic layer to the chatbot their employees already use (ChatGPT Enterprise, Claude, or a Slack bot). It asks when a question is ambiguous, says "we don't know" when the data can't answer, falls back to labeled SQL when the semantic layer can't, and shows where every number came from. Every question, clarification, refusal, and answer is logged so the semantic layer gets better over time.
The billable work at each client is the dbt model and semantic layer. Understory is the reusable part that turns that work into something people can use through chat within days.
Design
MVP design. Tools, the traps registry, semantic layer and warehouse adapters, identity and logging, the eval harness, and the build sequence.
Roadmap. What comes after the MVP and why it waits, including the Breakdown-based explanation engine for "why did X change" questions.
Architecture draft 0.1. The original design. The MVP design supersedes its sections 3 through 8.
Related MCP server: SLayer
Quickstart
Understory develops against fake_companies, four synthetic companies with dbt projects and MetricFlow metrics on DuckDB. Clone it as a sibling directory (or set FAKE_COMPANIES_DIR), generate a company, and build its dbt project:
cd ../fake_companies && uv sync --extra dbt
uv run fake-companies generate --config configs/alpenglow_retail_dtc.yaml --out out/alpenglow.duckdb
DBT_PROFILES_DIR=dbt/retail_dtc FAKE_DB=$PWD/out/alpenglow.duckdb uv run dbt build --project-dir dbt/retail_dtcThen, in this repo:
uv sync --all-extras
uv run understory check --tenant tenants/alpenglow # manifest, traps, warehouse, freshness
uv run understory serve --tenant tenants/alpenglow # MCP over streamable HTTP at :8000/mcp
uv run pytest # 170 tests; DuckDB and mf tests skip if data is absentPoint any MCP client at http://127.0.0.1:8000/mcp. For a chatbot on the internet, run the container and put it behind HTTPS with auth.mode: static in tenant.yml.
Layout
src/understory/
server/ MCP tools (mcp.py), tool logic (service.py), sessions, windows, auth, serve CLI
catalog/ semantic_manifest.json reader, get_context assembly, describe
traps/ traps registry schema, matcher, CI check, `understory traps check`
semantic/ SemanticLayer: metricflow_local (mf query --explain + cache), dbt_cloud
warehouse/ Warehouse: duckdb, bigquery
guard/ sqlglot read-only SQL guard for run_sql
telemetry/ write-only Parquet log in two families, HMAC user hashing
harness/ Pydantic AI agent over OpenRouter, golden sets, eval runner
dbt_understory/ dbt package modeling the log: fct_questions, fct_sessions, mart_eval_daily, ...
tenants/ one directory per client; four fake_companies tenants committedA tenant is a directory: tenant.yml, context.md, traps.yml, semantic_manifest.json, and golden/questions.yml.
Stack
Python 3.13, the official MCP SDK, open-source MetricFlow, DuckDB and BigQuery, Parquet, dbt, sqlglot, Pydantic AI over OpenRouter.
Status
MVP on the mvp-scaffold branch. The server, all seven tools, the telemetry package, and the harness work end to end against the four fake tenants. The deterministic eval passes every golden item on every tenant, and the live path is verified through OpenRouter. Not yet done: a deployment against a real client warehouse, and connector auth against an identity provider.
export OPENROUTER_API_KEY=...
uv run understory ask --tenant tenants/alpenglow "How were sales in the US in March 2025?"
uv run understory eval --tenant tenants/alpenglow --deterministic # no LLM, runs in CI
uv run understory eval --tenant tenants/alpenglow # live, writes tenants/alpenglow/.evals/Related
Breakdown. Bayesian metric trees and root cause analysis. Understory will call it for explanation questions.
fake_companies. Synthetic company data with dbt projects and labeled anomalies for four verticals.
This server cannot be deployed
Maintenance
Related MCP Connectors
Ask data questions in natural language. Get SQL, insights, and charts from your databases.
Ask business questions in plain English. Get instant answers from your database, no SQL needed.
Query your org's data in natural language — read-only MCP access to SQL, NoSQL, files & warehouses.
The grounded data layer for any LLM: governed SQL, metrics, lineage and catalog over your data.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceA server that enables querying the dbt Semantic Layer through natural language conversations with Claude Desktop and other AI assistants, allowing users to discover metrics, create queries, analyze data, and visualize results.11MIT
- AlicenseAqualityAmaintenanceAgent-native semantic layer, letting AI agents query databases through specifying intent instead of writing SQL, then compiling structured queries into correct, dialect-aware SQL. Dynamic and expressive, supporting multi-stage queries, time-shifts, and complex join schemas.21168MIT
- AlicenseAqualityCmaintenanceQuery SQL databases (SQLite, PostgreSQL, BigQuery, Databricks) in natural language through a business semantic layer — glossary, metrics, and a data dictionary grounded against your real schema. Read-only by default, with an embedded SQLite + sqlite-vec metadata store and no external infra required.252MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to understand and query your database safely by providing a semantic layer of metadata, with tools to search, explain, validate, and generate safe SQL.2MIT