# Auto Ontology

> NVIDIA's ontology context layer for agent text-to-SQL

- Category: Retrieval & Knowledge (RAG) / RAG Frameworks & Platforms
- Language: Python
- Licence: Apache-2.0
- Repository: https://github.com/NVIDIA/auto-ontology
- Canonical page: https://ai-tldr.dev/tools/auto-ontology/

## In short

Auto Ontology is an open-source library from NVIDIA that builds a context layer for agents that query enterprise data. It generates an ontology from database metadata, connects existing ontologies and semantic models, and reconciles metric and entity definitions that disagree across systems. It sits in the RAG Frameworks & Platforms category of the Retrieval & Knowledge (RAG) tools and is open-source, written in Python and licensed Apache-2.0.

## Overview

Auto Ontology is an open-source library from NVIDIA that builds a context layer for agents that query enterprise data. It generates an ontology from database metadata, connects existing ontologies and semantic models, and reconciles metric and entity definitions that disagree across systems. Agents use that layer to learn where data lives, what it means and how to use it. The goal is reliable agentic analytics: a quickly answered revenue question is worth nothing if the number is wrong. Generated queries are checked against certified definitions and lineage, and every answer carries its provenance.

The project is a full stack rather than a single package. A Next.js web UI handles chat, analysis, the data catalog, analytics and settings, plus authentication and role-based access through Better Auth. A FastAPI backend built on LangChain runs the chat and natural-language-to-SQL flow, the catalog and the datasource APIs. An ingestion worker ingests tabular data and writes embeddings, and Postgres with pgvector stores the app metadata, the catalog and ontology, and the vectors. HashiCorp Vault can optionally hold connection credentials. Source databases can be Databricks, Postgres, Snowflake or DuckDB.

Inference goes through NVIDIA NIM endpoints, either the hosted NVIDIA API catalog or self-hosted NIMs. The template defaults to Nemotron 3 Nano 30B-A3B for reasoning, Nemotron 3 Embed 1B for embeddings and Llama Nemotron Rerank VL 1B v2 for reranking. Each role (reasoning, non-reasoning, embedding, rerank) is set by an endpoint, API key and model triplet that falls back to shared defaults. The project is Apache-2.0 licensed and does not accept external contributions.

## What it does

- Generates enterprise ontologies from database metadata, connects existing ontologies and semantic models, and reconciles inconsistent definitions across systems
- Natural-language querying: questions become SQL that runs against connected Databricks, Postgres, Snowflake or DuckDB sources
- Validates generated queries against certified definitions and lineage and returns provenance with every answer
- Serves the context layer to agent harnesses through an MCP server, a CLI and an authenticated REST API with streaming, multi-turn chat completions
- Better Auth login with SSO, RBAC and per-user API tokens, with optional HashiCorp Vault for connection credentials
- Docker Compose for a local stack or a Helm chart for Kubernetes, with ready-made agent skills for setup, management and querying

## Getting started

The README's local path is Docker Compose. You need Docker with Compose v2, an NVIDIA API key (nvapi-…) from build.nvidia.com for NIM inference, and connection details for the database you want to query. Kubernetes deployments use the Helm chart described in DEPLOYMENT.md.

1. Clone the repository

   Clone the project and move into it.

```bash
git clone https://github.com/NVIDIA/auto-ontology.git auto_ontology && cd auto_ontology
```

2. Create the environment file

   Copy the template and fill in the Postgres credentials, DEFAULT_MODELS_API_KEY and CONNECTION_STRINGS. AUTH_SECRET and APP_URL are required: without them every page fails with a Better Auth "default secret" error.

```bash
cp .env.example .env
# edit .env
```

3. Build and start the stack

   This builds the backend and frontend images and brings up Postgres and pgAdmin. A one-shot migration job syncs the database schema, then the backend, ingestion service and frontend start.

```bash
docker compose up -d --build
```

4. Open the UI and connect data

   Open http://localhost:3000. The backend API listens on :3001 and pgAdmin on :5050. Connections added in the UI are stored in plaintext in Postgres unless Vault is configured. CONNECTION_STRINGS is only a fallback, used when no UI connections exist.

5. Query from a script with an API token

   In the user menu, open API Tokens and create a token. It is shown only once. Send it as x-api-key on any /api call. POST /api/chat/completions streams step, result or error events followed by [DONE]. Pass a conversation_id UUID to continue a thread.

```python
import os
import requests

session = requests.Session()
session.headers["x-api-key"] = os.environ["AUTO_ONTOLOGY_API_TOKEN"]

terms = session.get("https://auto_ontology.example.com/api/terms").json()

answer = session.post(
    "https://auto_ontology.example.com/api/chat/completions",
    json={"question": "How many orders shipped last week?"},
).json()
```

6. Connect an agent over MCP

   The MCP server is an HTTP client of the public API and holds no credentials of its own. Users sign in through Auto Ontology's own login, and each call runs with that user's permissions. Run it against your deployment, then point Cursor, Claude Desktop or another MCP client at the server's /mcp endpoint.

```bash
AUTO_ONTOLOGY_API_URL=http://localhost:3000 \
  uvx --from "git+https://github.com/NVIDIA/auto-ontology.git#subdirectory=mcp" auto-ontology-mcp

# client config
{
  "mcpServers": {
    "auto-ontology": { "url": "https://auto-ontology-mcp.example/mcp" }
  }
}
```

## When to use it

- Give an analytics agent trusted business definitions of metrics such as "active customer" before it writes SQL
- Reconcile conflicting metric definitions across Databricks, Snowflake and Postgres into one governed semantic catalog
- Expose warehouse data to Cursor, Claude Desktop or an internal agent through MCP while keeping each user's role-based permissions
- Run self-hosted natural-language querying over enterprise databases on NVIDIA NIM models, hosted or on-prem
