Pretensor database knowledge graph — Kuzu-backed schema graph from live DB introspection
Project description
Pretensor OSS
Pretensor OSS introspects PostgreSQL and Snowflake, with optional BigQuery connector support, builds a Kuzu knowledge graph of tables, columns, foreign keys, inferred joins, and related metadata, and exposes that graph to AI tools through an MCP (Model Context Protocol) server. Agents query schema context and search without issuing raw SQL against your graph store.
Status: Pre-release. Pretensor is not yet published to PyPI. Install and run it from this repository for now; APIs, CLI flags, and graph schema may change before the first packaged release.
Who is this for
- Data analysts using AI to explore warehouses.
- Data engineers tired of copy-pasting DDLs into chat.
- Data architects who need grounded schema context for agents.
- Anyone feeding database schemas to an LLM by hand.
Prerequisites
- Python 3.11 or 3.12 (3.13 not yet tested).
- A reachable database for
pretensor index. PostgreSQL is the fastest local path; Snowflake and BigQuery are also supported from a source checkout with their optional dependencies. uvis recommended. Ifuvis not installed, create a local.venvfirst andmake installwill usepipinside that environment.
Install From Source
git clone https://github.com/pretensor-ai/pretensor.git
cd pretensor
make install
If uv is not installed, create and activate a local virtualenv first:
python3 -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
make install
Quickstart
make install
pretensor index postgresql://USER:PASSWORD@HOST:5432/DBNAME
pretensor serve --config-only # prints mcpServers JSON for Claude / Cursor
serve --config-only prints the mcpServers JSON to stdout. Merge the pretensor entry into your Claude or Cursor MCP settings — the IDE starts the server automatically. Run pretensor serve directly if you prefer a long-running terminal process (config hints go to stderr, keeping stdout clean for JSON-RPC).
Use --state-dir on index / reindex and --graph-dir on serve when overriding the default state directory (.pretensor).
Full guide — install, tools, visibility, reindexing, graph visualization: guides/quickstart.md
MCP tools
| Name | Role |
|---|---|
list_databases |
List indexed database connections with table counts and staleness. |
schema |
Inspect node labels, edge types, and available properties before writing Cypher. |
query |
BM25 keyword search over table and entity metadata. |
cypher |
Read-only Kuzu Cypher for one indexed database; mutating clauses are rejected. |
context |
Full context for one physical table, including columns, joins, lineage, and cluster metadata. |
traverse |
Join paths between two physical tables, including confirmed cross-database paths. |
impact |
Downstream tables reachable from a table via FK and inferred-join edges. |
detect_changes |
Compare the live database schema to the last indexed snapshot without mutating the graph. |
compile_metric |
Compile semantic-layer YAML into validated SQL for one indexed database. |
validate_sql |
Validate SQL against the indexed graph before execution. |
Architecture
src/pretensor/ is organized by subsystem:
connectors/— database-specific introspection (PostgreSQL, Snowflake, BigQuery)core/— Kuzu graph store, schema writing, relationship discoveryintelligence/— deterministic graph intelligence (classification, clustering, join-path precomputation; metric-template code exists but is not part of the default OSS indexing flow)mcp/— MCP server, tools, resourcescli/— Typer CLI (index,reindex,serve,list,quickstart,export,validate,sync-grants,add,remove, plus thesemanticsubcommand group)
Status
Pretensor is in pre-release development. Before the first packaged release:
- There is no PyPI package yet; install from a source checkout.
- There is no SemVer stability guarantee yet, so APIs, CLI flags, and graph schema may change.
- Treat current builds as evaluation software and test upgrades in a staging environment before production use.
Progress and release notes: CHANGELOG.md.
Contributing
See CONTRIBUTING.md. Security issues: see SECURITY.md.
Tests
make verify
Individual commands are also available:
make test # pytest
make lint # ruff check
make typecheck # pyright
License
MIT — see LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pretensor-0.1.0a0.tar.gz.
File metadata
- Download URL: pretensor-0.1.0a0.tar.gz
- Upload date:
- Size: 509.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
feb90e434024969e9880470461fdda3aeaedb3c77a6fd19e5471a7de413ebd13
|
|
| MD5 |
40eaae7307ab0bdf254e911b74cb1ba5
|
|
| BLAKE2b-256 |
b0bd004301b3fff28c106969554e32db58eaaf8fa5ff6585ce8710c31e133f3a
|
File details
Details for the file pretensor-0.1.0a0-py3-none-any.whl.
File metadata
- Download URL: pretensor-0.1.0a0-py3-none-any.whl
- Upload date:
- Size: 254.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6d588ffb62a29390c60f66f019d3c2dce2e804fecdaf043f2fb2c057bd425035
|
|
| MD5 |
62912027a85cad7f1c77dd8cb40162b0
|
|
| BLAKE2b-256 |
2e781ab7c11395c3426b1971e89ae895b0abe6f6392e405ddaf128d7ce7b751b
|