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: Alpha. Pretensor is on PyPI as
pretensorand currently in alpha. CLI flags, MCP tools, and graph schema can still change between alpha versions — pin exact versions until1.0.0. See docs/releases.md for the versioning policy.
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 supported via thepretensor[snowflake]andpretensor[bigquery]extras.
Install
pip install pretensor
# or, inside a uv-managed environment:
uv pip install pretensor
Optional features are exposed as extras:
| Extra | Adds | Use when |
|---|---|---|
pretensor[snowflake] |
snowflake-sqlalchemy |
You're indexing a Snowflake warehouse. |
pretensor[bigquery] |
google-cloud-bigquery |
You're indexing BigQuery. |
pretensor[clustering] |
leidenalg |
You want Leiden community detection during indexing. Without this, Pretensor falls back to igraph Louvain (works, but no resolution tuning). |
Combine extras with comma separation, e.g. pip install 'pretensor[snowflake,clustering]'.
Try it without installing:
uvx --from pretensor pretensor --help
A note on alpha versions. Pretensor is in alpha. The plain
pip install pretensorcommand picks up the latest alpha because PyPI has no stable release yet. Once1.0.0ships, future alphas will require--pre(e.g.pip install --pre pretensor); pin to a specific version (e.g.pretensor==<version>) if you want a deterministic install today — see the PyPI badge above for the latest.
If you want to hack on Pretensor itself rather than use it, see the contributor setup in CONTRIBUTING.md for the git clone + make install flow.
Quickstart
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:
- The package on PyPI is named
pretensor. The first stable release will be1.0.0; everything before that is alpha.pip install pretensorworks today because no stable version exists yet —--prewill be required once1.0.0ships and future alphas resume. - There is no SemVer stability guarantee yet, so CLI flags, MCP tools, and graph schema may change between alphas. Pin exact versions.
- 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.0a2.tar.gz.
File metadata
- Download URL: pretensor-0.1.0a2.tar.gz
- Upload date:
- Size: 514.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d33c1e9ff2325f995611181eb1a29de07217b1c524513127e576134efa890658
|
|
| MD5 |
e186d46a20fce8f2b5e8041fe3c46d98
|
|
| BLAKE2b-256 |
a1f5e994a294d59e7a9e9d5057eb3b1a80156548aa976c91e8887d26740bb3b4
|
Provenance
The following attestation bundles were made for pretensor-0.1.0a2.tar.gz:
Publisher:
release.yml on pretensor-ai/pretensor
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pretensor-0.1.0a2.tar.gz -
Subject digest:
d33c1e9ff2325f995611181eb1a29de07217b1c524513127e576134efa890658 - Sigstore transparency entry: 1398181488
- Sigstore integration time:
-
Permalink:
pretensor-ai/pretensor@0309c85104217e306dd85ac12e1156fb40db4def -
Branch / Tag:
refs/tags/v0.1.0a2 - Owner: https://github.com/pretensor-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@0309c85104217e306dd85ac12e1156fb40db4def -
Trigger Event:
push
-
Statement type:
File details
Details for the file pretensor-0.1.0a2-py3-none-any.whl.
File metadata
- Download URL: pretensor-0.1.0a2-py3-none-any.whl
- Upload date:
- Size: 254.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
41f3457e29efb94edba9f56e82c67db23278b10e4081322dafbf75940d4ba65b
|
|
| MD5 |
51cbce91dce1cd981cf8dabafa611d9d
|
|
| BLAKE2b-256 |
05b8e5b528f3e2053988458137a4714b73294b71811f02d99d020035d577cda2
|
Provenance
The following attestation bundles were made for pretensor-0.1.0a2-py3-none-any.whl:
Publisher:
release.yml on pretensor-ai/pretensor
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pretensor-0.1.0a2-py3-none-any.whl -
Subject digest:
41f3457e29efb94edba9f56e82c67db23278b10e4081322dafbf75940d4ba65b - Sigstore transparency entry: 1398181504
- Sigstore integration time:
-
Permalink:
pretensor-ai/pretensor@0309c85104217e306dd85ac12e1156fb40db4def -
Branch / Tag:
refs/tags/v0.1.0a2 - Owner: https://github.com/pretensor-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@0309c85104217e306dd85ac12e1156fb40db4def -
Trigger Event:
push
-
Statement type: