DistillQL is a Python package that sits between your AI agent and your databases. It drafts what your company's terms mean from the queries people already run, hands the agent that page, and runs every query read-only as the person asking.
pip install distillqlthe command line, Python, and any LLM
pip install 'distillql[mcp]'adds the server for AI apps
Standard AI: the agent gets your tables and columns and runs its own SQL. DistillQL page: it also gets one page of definitions DistillQL drafts from the queries your company already runs, pasted into its instructions; it works in any agent, at little cost. DistillQL page + your written definitions: your team's own written definitions pasted in beside the page; where the two disagree, the agent follows yours. DistillQL tools: it asks DistillQL as it works, for the tables and definitions that fit each question, and runs its SQL through DistillQL; the most right answers with nothing written down, with more reading per question. DistillQL tools + your written definitions: the tools, with your team's definitions in the agent's instructions; where the two disagree, the agent follows yours.
Claude
Open models
Claude
Open models
360 questions over twelve companies' databases, synthetic data on Postgres, one pass each. API-equivalent cost. Each company's written definitions were written with its data.
The same agent, given your semantic layer two ways: through dbt's own tools or your catalog's own MCP server, or with the LookML project or Ossie model pasted into its instructions; or with DistillQL's tools reading it. With half the dbt project missing, or a metric in five out of date, DistillQL still scores 22 to 36 points higher than dbt's tools. With DataHub or OpenMetadata, DistillQL cost 21% to 51% less per right answer than the catalog's own MCP server.
dbt
LookML
Apache Ossie
DataHub
DataHub: cost per right answer
OpenMetadata
OpenMetadata: cost per right answer
360 questions, one pass each; dbt: the complete project. dbt's tools: dbt Labs' MCP server and the Semantic Layer's query tools over MetricFlow. Each dbt project, LookML project and Ossie model was written from that company's definitions; the Ossie model, as a second team would keep one, holds two thirds of them. DataHub and OpenMetadata: run as a company runs them; cost per right answer is API-equivalent model cost. DataHub 1.8 and OpenMetadata 2.0.6 with sign-in on, each loaded by its own Postgres connector, with a glossary of that company's written definitions linked to their columns. The agent queries Postgres through Postgres MCP Pro beside the catalog's own MCP server; DistillQL reads the live catalog and the database's own query log.
"What was net revenue in August?"
The agent gets the schema: every table and column, and nothing about what they mean.
Nothing says what net revenue is
The agent writes a query and chooses a definition on its own.
A plausible wrong number
A database server runs it as a shared service account.
Every question sees all the account can
Every row returns into the conversation and the agent reads off a figure.
No record of what ran, or why
The same question, from the same person, in the agent they already use.
Nothing new to learn
DistillQL hands over the definition, the tables it uses and the report that already computes it.
Meaning your team approved
The agent writes the query from that definition. DistillQL checks it: one read, known columns, defined terms.
An undefined term is reported as undefined
DistillQL runs it as the person asking, on every database it touches, within a cost cap.
Your own row filters and grants apply
The rows stay in DistillQL. The agent gets a summary and the record of what ran; it can propose a good answer for your team to keep.
Every answer shows its work
DistillQL is one server with six tools, standing where the catalog server and the database server would be. The agent still writes the SQL. Each stage further down says what DistillQL does there, with an example from the synthetic marketplace we test on.
DistillQL reads what your company already knows, in order of trust, and writes it onto one page your agent reads before the first question. Where a higher layer is silent, the next one speaks.
What a person approved. Always wins.
dbt metrics, descriptions and tests from target/; LookML measures from the project's files; Apache Ossie models.
OpenMetadata and DataHub.
Airflow and Prefect: which table feeds which, and which one is current.
The reports people run every month, and where two teams compute a term differently.
Tables, columns, keys and what the values look like.
The five stages from the map above, in detail, with an example from the synthetic marketplace we test on.
pip install 'distillql[mcp]' and point Claude Code, Claude Desktop, Cursor or LM Studio at DistillQL's server. It appears as six tools: glossary, search_context, query, profile, write, verify.distillql ask runs the conversation itself, with a model in Ollama or LM Studio on your machine, or a cloud model your config names. The model gets four read-only tools, at most 20 rows of any result, and never a personal column; nothing else to install.pip install distillql alone gives the command line (crawl, glossary, review, sql) and import distillql: the same six tools as Python functions, and the engine underneath them.The same server in each app. With no app, distillql ask talks to any model that speaks OpenAI's API; a model off your machine must be named in the config. Give apps the full path that which distillql prints.
target/: each metric becomes a verified definition, descriptions fill in missing comments, and tests mark keys, joins and allowed values. No dbt install or account.net revenue
Service fees minus referral credits, by month.
31 runs of rpt_finance_monthly agree
3 ad-hoc queries leave the credits out
fees summed, credits left out: 6% high and plausible
matches the finance report
If your definitions already live in dbt, DistillQL reads the project's metrics, descriptions and tests first, and mines history only for what dbt leaves out, so you keep one set of definitions. distillql gaps lists the numbers people compute that dbt lacks, and the dbt metrics they compute differently. LookML projects and Apache Ossie files are read the same way; catalogs come next. On Snowflake alone, Cortex Analyst does part of this inside Snowflake; DistillQL does it over Postgres and the warehouse together, in the agent you already use.
| renter | region | GMV |
|---|---|---|
| Halden Labs | EU | 48,200 |
| Oriel AI | US | 44,910 |
| Mistvale | EU | 31,075 |
| Tanager | APAC | 29,660 |
| Northbeam | US | 27,300 |
| Quillon | US | 22,480 |
| renter | region | GMV |
|---|---|---|
| Halden Labs | EU | 48,200 |
| Mistvale | EU | 31,075 |
| 4 rows outside EU never read. The filter is Postgres's own, applied because the query arrived as her. | ||
verify; it can never approve its own. Saving those proposals for your team to accept is the next build.distillql.yaml names each database and how to sign in as the person, the row and byte caps, and the one folder write may put files in. No credentials go anywhere else..distillql/context.yaml is the crawl's output: every drafted definition, join path, metric and repeated report, each with the queries it came from, a confidence, and a status of drafted or verified. Plain YAML; your team can edit it, diff it, keep it in git.pg_stat_statements; Snowflake in its query history. DistillQL reads what is already there. It does not install anything in your database..distillql/records/, and writing verified queries back into the context file, are the next build; both are small.write saves one to a named table or a file in the write folder; nothing else leaves.Nothing is sent anywhere. Two files on your disk, and the database you already have.