DistillQL

Your agent knows your tables. It does not know what net revenue means.

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

Five-minute quickstart
Register interest
$ distillql crawl distillql.yaml postgres 10 tables 393 queries 25 repeated reports duckdb 6 tables 84 queries 6 repeated reports wrote .distillql/context.yaml: 26 definitions, 19 joins, 14 metrics 9 need a decision, most used and least certain first $ distillql review .distillql/context.yaml net revenue service fees minus referral credits, by month 31 runs of rpt_finance_monthly agree 3 ad-hoc queries leave the credits out active renter any GMV in the month, stopped storage included from 4 months of active_renters, no disagreement renter region two readings in the history 12 queries: the region on the day of the charge 7 queries: the account's region today approve one, edit, or leave it drafted

More right answers on every model we tested

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.

Standard AIDistillQL pageDistillQL page + your written definitionsDistillQL toolsDistillQL tools + your written definitions

Right answers

Claude

Claude Haiku
Claude Sonnet
Claude Opus

Open models

gpt-oss 20b
Gemma 4 26B

Cost per right answer

Claude

Claude Haiku
Claude Sonnet
Claude Opus

Open models

gpt-oss 20b
Free: it runs on your own machine
Gemma 4 26B
Free: it runs on your own machine

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.

If you already run dbt, LookML, Apache Ossie, DataHub or OpenMetadata

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.

Standard AI + dbt's tools, the catalog's MCP server, or the file pasted inDistillQL tools reading it

dbt

Claude Haiku
Claude Sonnet
Claude Opus

LookML

Claude Haiku
Claude Sonnet
Claude Opus

Apache Ossie

Claude Haiku
Claude Sonnet
Claude Opus

DataHub

Claude Haiku
Claude Sonnet
Claude Opus

DataHub: cost per right answer

Claude Haiku
Claude Sonnet
Claude Opus

OpenMetadata

Claude Haiku
Claude Sonnet
Claude Opus

OpenMetadata: cost per right answer

Claude Haiku
Claude Sonnet
Claude Opus

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.

How a question travels, before and with DistillQL

Before
  1. Question

    "What was net revenue in August?"

  2. Context

    The agent gets the schema: every table and column, and nothing about what they mean.

    Nothing says what net revenue is

  3. SQL

    The agent writes a query and chooses a definition on its own.

    A plausible wrong number

  4. Run

    A database server runs it as a shared service account.

    Every question sees all the account can

  5. Answer

    Every row returns into the conversation and the agent reads off a figure.

    No record of what ran, or why

With DistillQL
  1. 1 Question

    The same question, from the same person, in the agent they already use.

    Nothing new to learn

  2. 2 Context

    DistillQL hands over the definition, the tables it uses and the report that already computes it.

    Meaning your team approved

  3. 3 SQL

    The agent writes the query from that definition. DistillQL checks it: one read, known columns, defined terms.

    An undefined term is reported as undefined

  4. 4 Run

    DistillQL runs it as the person asking, on every database it touches, within a cost cap.

    Your own row filters and grants apply

  5. 5 Answer

    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.

Where the context comes from

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.

1
Your team's definitions

What a person approved. Always wins.

2
Your semantic layers

dbt metrics, descriptions and tests from target/; LookML measures from the project's files; Apache Ossie models.

3
Catalogs

OpenMetadata and DataHub.

next
4
Lineage

Airflow and Prefect: which table feeds which, and which one is current.

next
5
Query history

The reports people run every month, and where two teams compute a term differently.

6
Schema and profiles

Tables, columns, keys and what the values look like.

Distilled intoone page, read up front

What DistillQL does at each step

The five stages from the map above, in detail, with an example from the synthetic marketplace we test on.

1Question

  • Asked in the agent you already use. Add the server with 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.
  • Or with any LLM, and no app. 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.
  • Or with no agent at all. 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.
  • Nothing to model first. Install, point it at your databases, run the crawl. Our ten-table test database crawls in under a second; a few hundred tables take minutes.
Claude Code: one command
claude mcp add distillql -- distillql mcp distillql.yaml
Claude Desktop: claude_desktop_config.json. Cursor: ~/.cursor/mcp.json. LM Studio: ~/.lmstudio/mcp.json
{ "mcpServers": { "distillql": { "command": "distillql", "args": ["mcp", "distillql.yaml"] } } }
Ollama or LM Studio, with no app: one command
distillql ask distillql.yaml "What is our total revenue?" \ --model gpt-oss:20b The total revenue is $135,666.00, from paid orders of real (non-test) customers, as the glossary defines revenue.

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.

2Context

  • Drafts the definitions from what your company already runs. The schema, a profile of every table and the query history, mined into join paths, measures, metrics, the reports that repeat, and the definitions behind them. Each line carries the queries it came from.
  • Serves them all, marked drafted or verified. Nothing has to be reviewed before the first question. The agent sees each definition with its status and prefers the verified ones. Your team approves, edits or strikes each line on a review page on its own machine, with the past queries behind the line beside it. An agent can propose a line, never approve it.
  • Reads your dbt project first. Point it at 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.
  • Reads LookML and Apache Ossie too. Point it at a LookML project's folder or an Ossie file: each measure becomes a verified definition, written as Looker or the semantic view would compute it. No Looker instance. Where two layers define a term the same way, the page says they agree.
  • Says "undefined" when nothing was approved. A term with no definition is handed over as such, so the agent asks instead of guessing.

net revenue

Service fees minus referral credits, by month.

31 runs of rpt_finance_monthly agree
3 ad-hoc queries leave the credits out

verified by the finance team, 12 Sep

The agent's guess, without it

$1,284,310

fees summed, credits left out: 6% high and plausible

With it

$1,207,955

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.

3SQL

  • The agent still writes it. DistillQL does not compile SQL from a model. It gives the agent the definition and the SQL that already computes it, and the agent writes from those.
  • One read-only statement, checked before it runs. Writes, DDL, a second statement and unknown functions are refused with the reason. A result is kept only by writing to a table your team named.
  • Checked against a cost cap you set. DistillQL estimates each query against the rows and bytes you allow and refuses over the cap before the warehouse bills a thing.
  • select * from eventsRefused before anything ran. events has about 2.1 billion rows and the query has no filter; the cap is 50 million. Add a date range, or ask profile for a summary.
  • delete from events where ts < '2024-01-01'Refused. query runs one read-only statement.
  • select pg_read_file('/etc/passwd')Refused. pg_read_file is not an allowed function.
  • select sum(fee) - sum(credit) from … where month = '2026-08'Ran. One read, 2 tables, estimated 18 MB, within the cap.

4Run

  • As the person asking. DistillQL signs in as them, or as their database role, so the grants and row filters you already maintain decide what each question can see. There is no shared account to over-privilege.
  • Where your data runs. A Python package on your machine or your server. There is no DistillQL service and no telemetry. DistillQL reads schemas and history with code, not a model; the only model in the loop is the one your agent already uses.
  • Across databases when it must. A question that spans Postgres and the warehouse is split, each part run where its data lives, and joined locally. Today that runs on Postgres and DuckDB; the three warehouse connectors are written and unproven.

As a shared service account

renterregionGMV
Halden LabsEU48,200
Oriel AIUS44,910
MistvaleEU31,075
TanagerAPAC29,660
NorthbeamUS27,300
QuillonUS22,480

With DistillQL, as priya.n (EU)

renterregionGMV
Halden LabsEU48,200
MistvaleEU31,075
4 rows outside EU never read. The filter is Postgres's own, applied because the query arrived as her.

5Answer

  • The rows stay in DistillQL. The agent gets a handle: a count, a sample, a profile, a chart, or a write to a named table. Ten thousand rows cost it a few hundred tokens; read whole, they would cost about four hundred thousand.
  • Every answer carries its record. What ran, where, as whom, which definitions it used, where each column came from, and how long it took and how much it read. A week later, "where did this number come from?" takes one look at the record.
  • Good answers can be proposed for keeping. The agent offers an answer's SQL with verify; it can never approve its own. Saving those proposals for your team to accept is the next build.
question
Net revenue, August 2026
answer
$1,207,955, 1 row; handle h_7f3a
definition
net revenue, verified by the finance team 12 Sep 2026
ran as
priya.n, read only
where
postgres: billing.charges, billing.credits
columns
net_revenue ← sum(charges.fee) − sum(credits.amount)
cost
0.4 s, 18 MB read from Postgres, within the cap
proposed as
reviewed query "net revenue by month", waiting for your team

6Where everything lives

  • One config file you write. 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.
  • One context file DistillQL writes. .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.
  • Query history comes from the database. Postgres keeps it in pg_stat_statements; Snowflake in its query history. DistillQL reads what is already there. It does not install anything in your database.
  • Every answer's record comes back with the answer. Today it is returned to the agent and to Python, not stored. Writing each record to .distillql/records/, and writing verified queries back into the context file, are the next build; both are small.
  • Results live in memory until you keep them. Handles sit in DistillQL's local engine for the session. write saves one to a named table or a file in the write folder; nothing else leaves.
distillql.yaml you write it: databases, identity, caps .distillql/ context.yaml DistillQL writes it: definitions, joins, metrics, reports; each with sources, confidence, drafted | verified records/ next build: a record per answer <write folder>/ only what the agent asked to keep in your database, untouched pg_stat_statements the query history DistillQL reads grants, row filters what each person may see in memory, for the session handles result rows, until written or dropped

Nothing is sent anywhere. Two files on your disk, and the database you already have.