Labsco
MCP SERVER

Pretensor

by pretensor-ai

Give an agent your warehouse schema as a graph, so it stops guessing at joins.

Data Platform: Pipelines, Warehousing, BI & Governance
Summary
`pretensor analyze` is the part that makes the graph more than a schema dump.

It scans a repository for SQL string literals in Python, resolves the tables each statement touches, and links the code to the graph — so `consumers` can name the service and file that read a table, and `impact` carries that provenance with it. Notably, raw SQL text is never stored, only a fingerprint. Two things to check before adopting: install the driver extra for your database or the index step fails at connect time, and the project is Beta with tool names and graph schema still allowed to move between minor versions.

What it is

A schema knowledge base for PostgreSQL, Snowflake and BigQuery. It introspects the database, builds a graph of tables, columns, foreign keys and inferred joins, and serves that graph to an agent — so schema questions are answered from the graph rather than from raw SQL against your warehouse.

What you get
  • `list_databases` shows indexed connections with table counts and staleness, `schema` shows node labels and edge types
  • `query` runs BM25 keyword search over table and entity metadata, upgrading to a hybrid BM25 + cosine rerank when embeddings are installed
  • `semantic_search` ranks tables by cosine similarity, and returns a structured BM25-fallback envelope when the embeddings extra is absent
  • `context` returns everything about one table — columns, joins, lineage, cluster metadata — and `traverse` finds join paths between two tables
  • `impact` lists downstream tables reachable by foreign key and inferred-join edges, each carrying its external code consumers
  • `consumers` names the service, file, line range, read/write op and confidence for code that touches a table, populated by `pretensor analyze`
  • `cypher` runs read-only queries against the graph; mutating clauses are rejected
  • `detect_changes` compares the live schema against the last indexed snapshot without mutating the graph
  • `compile_metric` compiles semantic-layer YAML into validated SQL, and `validate_sql` checks SQL against the graph before you execute it
Requirements

Python 3.11 or 3.12. Published on PyPI as pretensor version 0.1.0. Database drivers are extras, not part of the base install — `pip install 'pretensor[postgres]'`, `[snowflake]`, `[bigquery]`, or `[all-connectors]`; a bare install has no driver and fails at connect time. `[embeddings]` adds local ONNX embeddings and is what turns `semantic_search` from a fallback into real cosine ranking; `[clustering]` adds Leiden community detection. Usage is `pretensor index` against your database URL, then `pretensor serve --config-only`, which prints the client JSON to merge into your settings. `--state-dir` and `--graph-dir` override the default `.pretensor` directory. It is marked Beta, and the advice is to pin exact versions until 1.0.0.

Setup effort

One command — pip install 'pretensor[postgres]'