Datum
Provides a governed semantic layer for querying SQLite databases, enabling natural-language questions that produce validated, read-only SQL with citations and typed abstention for PII or missing data.
Click on "Install 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., "@DatumWhat's our monthly recurring revenue by plan?"
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.
Datum
A semantic context layer that keeps data agents honest.
Datum answers natural-language questions over a database by grounding an LLM on a governed semantic layer. It writes SQL that is validated against the schema, cites the tables and columns it used, and refuses instead of guessing when a question needs data that doesn't exist, is personal (PII), or isn't certified for analytics. It ships with an MCP server, a reliability eval harness, and unit tests for the guardrail.
A confident wrong answer is worse than no answer.
Results
Datum vs. a naive single-prompt text-to-SQL baseline, gpt-4o-mini, averaged over 3 runs.
CWR = Confidently-Wrong Rate (wrong answers plus answers that should have been
refused — PII, uncertified, out-of-scope) — the number a trust layer exists to minimize.
Benchmark | Engine | Execution Acc. ↑ | Refusal Recall ↑ | CWR ↓ | Answer faithfulness ↑ |
Synthetic (30 Q) | Datum | 96.3% | 100% | 0.0% | 100% |
Baseline | 88.9% | 27.8% | 35.6% | 81.5% | |
Chinook (20 Q, real DB) | Datum | 92.9% | 100% | 0.0% | — |
Baseline | 100% | 33.3% | 20.0% | — |
The critic + semantic layer drives confidently-wrong answers to zero and catches
100% of PII / uncertified / out-of-scope queries — without lowering execution
accuracy. The baseline, by contrast, leaks PII (SELECT email FROM employees), queries
uncertified tables, and even aliases AVG(csat_score) AS average_nps to answer a
question about a metric that doesn't exist.
Reproduce:
python evals/run_evals.py --runs 3 --judge # synthetic
python evals/run_external.py evals/chinook_eval.yaml --runs 3 # real Chinook DBRelated MCP server: sql-steward
Why
Point an LLM at a database and it will happily invent an nps_score column, join on
the wrong key, leak an email address, or return a confident number that's just wrong.
Datum puts two things between the model and the data:
A governed semantic layer — definitions, ownership, trust levels, metrics and PII flags — so the agent reasons over meaning, not raw table names.
A deterministic critic — a real SQL parser (
sqlglot, not the LLM) that blocks hallucinated columns, PII, uncertified tables and any non-read-only statement before a query ever runs.
If neither can make the question safe to answer, Datum abstains — with a typed reason.
Architecture
flowchart TD
Q[Natural-language question] --> R[Retriever<br/>relevant semantic assets]
R --> P[Planner<br/>answerable? which assets?]
P -->|no| X[Abstain<br/>pii · missing · untrusted · out-of-scope]
P -->|yes| A[SQL Author<br/>grounded SELECT]
A --> C{Critic<br/>sqlglot guardrail}
C -->|violations| A
C -->|clean| E[(SQLite<br/>read-only)]
E --> Ans[Answerer<br/>NL answer + citations]
SM[[Semantic layer<br/>trust · PII · metrics]] -.governs.-> P
SM -.governs.-> A
SM -.governs.-> CMulti-agent pipeline: Planner → SQL Author → Critic → Answerer, with a repair loop (the Critic's feedback goes back to the Author). Citations are extracted from the validated SQL's AST, so they reflect what the query actually touched.
Features
Grounded NL→SQL over SQLite, with citations and typed abstention.
Governed semantic layer (
context/semantic_model.yaml): trust levels, PII flags, ownership, business metrics with reference SQL.Deterministic critic (
sqlglot): rejects unknown/hallucinated columns, PII columns (even hidden behind a CTE or renamed alias), uncertified tables, and non-read-only SQL.Schema-linking: FK-neighbour expansion pulls join-partner tables into context.
Context retrieval over semantic assets — OpenAI embeddings, with a lexical fallback so the pipeline runs with no key.
MCP server — expose the engine to Claude Desktop / Cursor.
Auto-introspection adapter — build a semantic layer from any SQLite schema.
Reliability eval harness with a naive baseline, an LLM-as-judge faithfulness check, and multi-run averaging.
Unit tests for the guardrail (
pytest, no API needed).
Quickstart
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
cp .env.example .env # add your OPENAI_API_KEY
python -m datum seed # build the demo database
python -m datum ask "What is our monthly recurring revenue?"
python -m datum ask "List the email addresses of our account owners." # abstains (PII)
python -m datum eval # reliability scorecard vs baseline
pytest -q # guardrail unit tests (no API)Example
$ python -m datum ask "What is our monthly recurring revenue?"
╭─ Answer ─────────────────────────────────────────────────────────╮
│ Our monthly recurring revenue is $1,241,366.00. │
│ Source: plans.monthly_price, subscriptions.seats │
╰───────────────────────────────────────────────────────────────────╯
SELECT SUM(p.monthly_price * s.seats) AS mrr
FROM subscriptions s JOIN plans p ON p.plan_id = s.plan_id
WHERE s.status = 'active'
$ python -m datum ask "List the email addresses of our account owners."
╭─ Abstained · pii ────────────────────────────────────────────────╮
│ I can't answer that because it requires personal data (PII) that │
│ policy does not expose. │
╰───────────────────────────────────────────────────────────────────╯Benchmarks
Metrics (standard text-to-SQL + governance):
Metric | Meaning |
| answerable questions whose result matched gold |
| of everything it refused, how much should be refused |
| of the should-refuse questions, how many it caught |
| wrong answers + policy leaks, over all questions (lower better) |
Answer faithfulness | LLM-as-judge: are the answer's numbers grounded in the rows? |
Synthetic (evals/eval_set.yaml, 30 questions, deterministic DB) is the primary
benchmark. Chinook (evals/chinook_eval.yaml, 20 questions) runs the same harness
against the real third-party Chinook DB via schema auto-introspection.
Adding a Spider dev database (or any SQLite): the harness is dataset-agnostic. Drop
the .sqlite file in benchmarks/, copy chinook_eval.yaml, point database: at it,
list its pii_columns, and paste the Spider dev questions + gold SQL as items — then
python evals/run_external.py evals/your_spec.yaml. (Public benchmarks ship no trust/PII
labels; hand-annotating them in the YAML is exactly what the semantic layer is for.)
# fetch the Chinook demo DB used above (~1 MB)
curl -sL -o benchmarks/chinook.sqlite \
https://github.com/lerocha/chinook-database/raw/master/ChinookDatabase/DataSources/Chinook_Sqlite.sqliteTests
pytest -q # 37 tests, ~0.4s, no APIThe guardrail is tested directly with adversarial SQL — stacked-statement injection, write keywords hidden in comments, PII behind a renamed CTE alias, hallucinated columns, unqualified columns shared across two tables — so the "trust layer" claim is proven, not just asserted.
Use it from Claude Desktop / Cursor (MCP)
python -m datum serve starts an MCP server exposing list_certified_tables,
describe_table, and ask:
{
"mcpServers": {
"datum": {
"command": "/ABSOLUTE/PATH/datum/.venv/bin/python",
"args": ["/ABSOLUTE/PATH/datum/mcp_server.py"]
}
}
}Project layout
datum/
├── datum/
│ ├── db.py # sqlite access + read-only guardrail + result compare
│ ├── seed.py # deterministic synthetic SaaS database
│ ├── semantic.py # loads/queries the governed semantic layer
│ ├── introspect.py # auto-build a semantic layer from any SQLite schema
│ ├── retrieval.py # embeddings (or lexical fallback) over assets
│ ├── agents.py # Planner · Author · Critic · Answerer + Engine
│ ├── baseline.py # naive single-prompt baseline (the comparison point)
│ └── cli.py # `python -m datum ...`
├── context/semantic_model.yaml # the governed context layer
├── evals/
│ ├── eval_set.yaml # synthetic benchmark (incl. must-refuse questions)
│ ├── chinook_eval.yaml # real-DB benchmark spec
│ ├── run_evals.py # harness + baseline + faithfulness judge
│ └── run_external.py # run the harness on any external SQLite DB
├── tests/ # pytest guardrail suite (no API)
└── mcp_server.py # MCP server (FastMCP)Design notes, limitations & next steps
Benchmarks are small and partly self-authored (30 synthetic + 20 Chinook). They demonstrate the mechanism and the delta vs. baseline; they are not a large-scale study.
Single dialect. Only SQLite is implemented and tested. The design (semantic layer + AST critic) is dialect-agnostic, but porting to a warehouse dialect is future work, not a claim being made here.
The critic proves validity and governance, not semantic correctness. It guarantees SQL is read-only and touches only real, certified, non-PII columns; whether the query answers the user's intent is what the eval's execution accuracy measures.
Columns behind derived-table/CTE aliases are skipped by the critic to avoid false positives (the read-only + certified-table checks still apply).
Next: Spider/BIRD subsets through
run_external.py; a warehouse dialect; caching embeddings; expanding the eval sets.
License
MIT
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseAqualityAmaintenanceQuery 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
- AlicenseAqualityFmaintenanceA governed SQL gateway that exposes typed tools to AI agents, compiling safe read-only queries from a semantic layer while blocking PII before execution, supporting SQL Server, Postgres, and SQLite.9MIT
- Flicense-qualityCmaintenanceEnables natural language querying of SQL databases with robust safety guarantees including read-only enforcement, AST validation, and row caps.
- Flicense-qualityBmaintenanceEnables AI agents to query a SQLite database using natural language through the Model Context Protocol (MCP). Includes security guardrails that block destructive SQL operations.
Related MCP Connectors
The grounded data layer for any LLM: governed SQL, metrics, lineage and catalog over your data.
Query PostgreSQL databases in plain English — LLM-generated, safety-validated SQL.
Analytical memory for AI agents: a real Postgres queried in plain English over MCP. One command.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/malharinamdar/datum'
If you have feedback or need assistance with the MCP directory API, please join our Discord server