plainontology
Extracts dbt models and sources into concepts, carrying over tests, lineage, and semantic-layer measures as notes.
Provides a GitHub Action that runs ontology drift checks and can post the drift report as a pull request comment.
Supports live MariaDB databases through the MySQL source kind, extracting schema concepts and constraints.
Extracts MySQL schema concepts from dumps or live databases, including keys, constraints, enums, and comments.
Extracts PostgreSQL schema concepts from dumps or live databases, including tables, views, keys, constraints, comments, enums, and partitions.
Provides pre-commit hooks (plainonto-check, plainonto-drift) to validate ontology files and detect drift on every commit.
Extracts SQLite schema concepts from database files or SQLite-compatible SQL files.
Extracts concepts from Swagger 2.0 definitions, including schemas, operations, parameters, request bodies, and returns.
PlainOntology
Write down the ontology your system already has, as one plain text file that people can edit and AI agents can read.
Try it: pip install plainontology, then plainonto init my.onto --from sqlite:my.db

Every running system carries an implicit ontology: tables and foreign keys, JSON schemas, the tool definitions an LLM agent calls. Its meaning (what a "loan" is, that a "Title" is a "Book", that member holds personal data) usually lives in people's heads. PlainOntology extracts the structure into a readable text file, keeps your hand-written meaning next to it, and tells you when the system drifts away from it.
concept Book [auto: postgres table books]
definition "A title the library holds; one record per edition." [auto]
has id : integer key [auto]
has title : text required [auto]
has isbn : text unique "ISBN-13 without hyphens." [auto]
length ..13 [auto]
label "ISBN"
has pages : integer [auto]
min 1 [auto]
author -> Author required [auto: fk books.author_id]
tags -> Tag many [auto: via book_tags]
label "Livre"@fr
synonym "Title"
same_as schema:BookThe definition and the description come from comments in the database, length ..13 from varchar(13), and min 1 from CHECK (pages > 0).
Lines tagged [auto] come from the sources and are refreshed. Every other line is yours and is never overwritten.
What it does
Extract | PostgreSQL, MySQL and SQLite (live databases, dumps or migration scripts), JSON Schema (draft 7 and 2020-12, across files), OpenAPI 3.x and Swagger 2.0, dbt manifests, and AI agent tool definitions (Anthropic, OpenAI Chat and Responses, MCP |
Keep your edits | Refresh replaces |
Follow renames | A renamed table or column keeps your lines; |
Report drift |
|
Check | Duplicate lines, unknown targets, undeclared prefixes, misplaced rules, proposals waiting for review |
Validate | Check JSON records (for example an agent's structured output) against a concept: types, enums, required fields, min, max, length, pattern, format |
Multilingual | Labels, definitions and synonyms in any language ( |
Export | RDF Turtle (OWL structure, SKOS meaning), SHACL shapes for validating RDF data, and LinkML YAML |
Serve to agents | An MCP server so agents look concepts up, validate their output, and propose new lines for a person to review |
The core has no dependencies beyond the Python standard library. Extras: mcp for the MCP server, postgres and mysql for those databases, openapi for YAML OpenAPI files, all for everything.
Documentation: tutorial, sources, CI, agents and the file format (also built as a site with mkdocs serve).
Related MCP server: RunContext
Quick start
pip install "plainontology[all]" # or just [mcp], [postgres], [mysql], [openapi]
cd examples
plainonto init mine.onto --from sqlite:library.sql --from tools:agent-tools.json
# edit mine.onto: add definitions, synonyms, same_as mappings
plainonto refresh mine.onto # re-extract; your lines stay
plainonto drift mine.onto # report only; exit 1 on drift
plainonto check mine.onto
plainonto export mine.onto --to turtle -o library.ttl
plainonto export mine.onto --to shacl -o library.shapes.ttl
plainonto export mine.onto --to linkml -o library.yaml
plainonto validate mine.onto Loan record.json
plainonto rename mine.onto Member Patron # after a table rename that refresh did not detectThe command is plainonto (short for plainontology; both work).
Sources are written KIND:LOCATION and stored in the file; file paths are relative to it:
Kind | Location |
| a schema dump ( |
| a schema dump ( |
| a SQLite database, or a SQLite-compatible |
| a JSON Schema file; |
| an OpenAPI 3.x or Swagger 2.0 file (JSON, or YAML with the |
| a dbt manifest ( |
| a JSON list of tool definitions, or an object with a |
Databases. Dumps are read in their own dialect, and live databases through SQLAlchemy, read-only. Both give the same result (CI checks this against real PostgreSQL 16 and MySQL 8.4 servers):
From the database | In the file |
tables, views | concepts (views get a note); tables outside |
table and column comments | the concept's definition, the property's description |
primary and foreign keys, unique constraints |
|
| an enum, |
enums, domains, arrays, |
|
| the copied columns (and keys and checks with |
join tables | a |
triggers | notes |
| applied in order, so a folder of migration scripts concatenated into one file works as a dump |
partitions | fold into the parent table with a note; foreign keys declared on partitions carry up |
anything the parser cannot read | reported as a |
Everything else in a dump (SET, data, functions) is skipped. For a live database:
export LIBRARY_DB="postgresql://reader@db.internal/library" # password via ~/.pgpass, or in this variable
plainonto init library.onto --from postgres:env:LIBRARY_DBA URL with a password is refused, because the source line is saved in the ontology file.
Use it in CI and git hooks
# .github/workflows/ontology.yml
on: [pull_request]
permissions: { contents: read, pull-requests: write }
jobs:
drift:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: cfuracao-academic/plainontology@v0.2.0
with:
file: ontology/library.onto
install: plainontology[postgres]
comment: "true" # post the drift report on the pull request# .pre-commit-config.yaml
repos:
- repo: https://github.com/cfuracao-academic/plainontology
rev: v0.2.0
hooks:
- id: plainonto-check
- id: plainonto-drift # runs on every commit, so a schema-only change is caughtplainonto drift and plainonto check with no file check every .onto file under the current folder. All inputs are in docs/ci.md. Editors: a VS Code extension highlights .onto files.
Tried on real schemas
CI extracts two public sample databases at pinned versions on every push:
Schema | Result |
Pagila (PostgreSQL) | 25 concepts from 71 tables and 8 views (one materialized): 55 monthly partitions fold into |
Sakila (MySQL) | 23 concepts (16 tables, 7 views); no warnings, |
Each takes about 0.4 seconds.
Performance
1,000 tables (13,500 lines) extract or refresh in about 1.5 seconds; 5,000 tables in about 7; check and the exports take under a second. Time grows linearly. Details and the script in docs/performance.md.
Use it from an AI agent (MCP)
plainonto mcp path/to/library.onto # read-only tools
plainonto mcp path/to/library.onto --allow-proposals # also lets agents propose linesClaude Code:
claude mcp add plainontology -- plainonto mcp /absolute/path/to/library.ontoClaude Desktop or any MCP client (mcpServers in the client's config):
{
"mcpServers": {
"plainontology": { "command": "plainonto", "args": ["mcp", "/absolute/path/to/library.onto"] }
}
}Tool | What it does |
| every concept with its definition |
| a concept's lines, inherited properties and who points to it |
| find concepts by name, label, synonym, definition or property |
| check a JSON object against a concept before acting on it |
| compare the file with its sources now |
| only with |
The file is re-read on every call, so edits show up at once. Agents can never change or delete an existing line.
Why a text file
Diffable. Ontology changes go through pull requests like code.
Two layers in one place. Structure (
has,->,is_a) and meaning (label,definition,synonym,same_as,note) sit together, so neither drifts from the other.Interoperable. Export to OWL/SKOS and LinkML when you need the standard toolchains.
How it compares
PlainOntology | LinkML | OWL editors (Protégé) | Data catalogues (DataHub, OpenMetadata) | |
Direction | extracts from a running system | you write the schema, it generates | you write the ontology | ingests metadata |
Format | one plain text file | YAML | RDF/OWL | database behind a server |
Keeps hand edits across re-extraction | yes | n/a | n/a | partly |
LLM tool schemas and MCP | yes | no | no | no |
Setup |
|
| desktop app | servers |
PlainOntology does not replace these. It exports to LinkML and OWL so you can move to them when you need more.
Format
The full grammar and refresh rules are in SPEC.md. In short:
prefix : <https://example.org/library#>
source sqlite:library.sql
concept NAME [auto: where it came from]
has PROPERTY : TYPE [FLAGS] ["description"]
label "..." (also synonym, note: about the property)
min N (also max N, length LOW..HIGH, pattern "regex", format email)
PROPERTY -> CONCEPT [FLAGS] ["description"]
is_a CONCEPT
unique (PROPERTY, PROPERTY)
label "..."@fr (also definition, synonym, note; language tag optional)
same_as prefix:TermTypes: text integer decimal boolean date datetime binary json any enum(a|b). Flags: key required unique many. The empty prefix line sets the base IRI for exports.
Scope
PlainOntology reads schemas by parsing their syntax, not by asking a running database. It is tested on output from pg_dump, mysqldump and SQLite, on Django, Rails, Laravel, Prisma and Flyway migrations, and on public schemas such as Pagila and Sakila. Hand-written SQL in unusual forms, vendor extensions and edge cases may fall outside what it reads. When a statement or column cannot be read, the report says so with a ? warning rather than guessing. For the exact picture, point it at a live database or a fresh dump from your database tool.
Known limitations
To give an extracted concept a friendlier name, add a
label; the concept name follows the source.Concept names are made with English singular rules (
booksbecomesBook,peoplebecomesPerson).The MCP server searches by keyword, runs locally over stdio, and does not lock the file while an agent proposes a line.
JSON Schema references to web URLs are not fetched;
plainonto checkflags the missing concept.CHECK constraints more complex than a list, a comparison, a range or a regex are kept as notes, not enforced by
validate.Field names that are not valid property names (
first name,@id) becomefirst_nameand_id;validateaccepts either form in a record.Patterns are Python regular expressions.
validate, pyshacl and LinkML use them as they are; other SHACL engines (XPath regex) may not accept\b, look-arounds or(?i).Views are read for their columns and types; the meaning of the query itself is not.
Development
python -m venv .venv && .venv/bin/pip install -e ".[dev]"
pytestSee CONTRIBUTING.md and ROADMAP.md.
Citing
If you use PlainOntology in research, please cite it using CITATION.cff. The DOI 10.5281/zenodo.24562420 always points to the latest version; each release also has its own DOI on Zenodo.
Licence
MIT
Available Tools
5 toolsdescribe_conceptB
Show a concept's lines (properties, relations, labels, definition), the properties it inherits, and which concepts point to it.
Inputs: name (required). Returns: result
driftA
Compare the file with its sources now and report what changed, without writing.
Inputs: no named parameters. Returns: result
list_conceptsA
List every concept in the ontology with its one-line definition.
Inputs: no named parameters. Returns: result
searchC
Find concepts by name, label, synonym, definition or property.
Inputs: query (required). Returns: result
validate_recordA
Check a JSON object against a concept: unknown fields, missing required fields, wrong types and enum values. Use it on structured output before acting on it.
Inputs: record (required), concept (required). Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 5 tools
Each tool targets a distinct operation: enumeration (list_concepts), per-concept detail (describe_concept), lookup by criteria (search), record validation (validate_record), and change comparison (drift). The only mild overlap is list_concepts vs. search, since both surface concepts, but their scope (all vs. filtered) is clear from the descriptions.
Three tools follow a verb_noun snake_case pattern (list_concepts, describe_concept, validate_record), but 'search' is a bare verb and 'drift' is a bare noun with no object. The convention is readable but not uniform across the set.
Five tools is a tight, well-scoped surface for an ontology inspection/validation server; each tool covers a distinct need. It is on the lean side, but nothing feels redundant or padded.
The read/inspect/validate lifecycle is covered, but there is no way to create, update, or remove concepts, and 'drift' explicitly reports changes 'without writing' — implying a apply/sync counterpart that is absent. Agents hitting drift findings or ontology gaps have no tool to act on them.
Maintenance
Related MCP Connectors
Governed, auditable knowledge your team curates for its AI assistants, self-hostable
Store, query, and update structured data from any AI agent
Shared knowledge base for AI agents. Semantic search across agents, no setup required — just a URL.
Self-hostable shared brain for you and your AI agents — docs, flows, meetings, decisions, rationale
Related MCP Servers
AlicenseNot gradedqualityDmaintenanceTurns your data model into a semantic layer for AI agents, automatically generating typed, discoverable tools with entity relationships and schema discovery.644Apache 2.0- AlicenseNot gradedqualityDmaintenanceEnables AI agents to understand and query your database safely by providing a semantic layer of metadata, with tools to search, explain, validate, and generate safe SQL.2MIT
- AlicenseNot gradedqualityBmaintenanceProvides a semantic intelligence layer for SQL Server databases, enabling AI agents to understand schema structure, relationships, and safely interact through policy-gated tools.3MIT
- AlicenseAqualityDmaintenanceExposes SQL Server and Snowflake schema metadata to AI coding agents, enabling schema search, join path discovery, and stored procedure metadata retrieval without live queries.18GPL 3.0