PlainOntology
Write down the ontology your system already has, as one plain text file that people can edit and AI agents can read.
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: sqlite table books]
has id : integer key [auto]
has title : text required [auto]
has isbn : text unique "ISBN-13 without hyphens."
author -> Author required [auto: fk books.author_id]
tags -> Tag many [auto: via book_tags]
definition "A title the library holds; one record per edition."
synonym "Title"
same_as schema:Book
Lines tagged [auto] come from the sources and are refreshed. Every other line is yours and is never overwritten.
What it does
| Extract | SQLite databases or .sql schema files, JSON Schema (draft 7 and 2020-12), and LLM tool definitions (Anthropic, OpenAI Chat and Responses, MCP tools/list) |
| Keep your edits | Refresh replaces [auto] lines only. If you rewrite an extracted line, your version wins and is reported |
| Report drift | plainonto drift exits 1 when the sources changed, so it can gate CI |
| Check | Duplicate lines, unknown targets, undeclared prefixes, proposals waiting for review |
| Validate | Check JSON records (for example an agent's structured output) against a concept |
| Export | RDF Turtle (OWL structure, SKOS meaning) 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. The MCP server needs the mcp extra.
Quick start
pip install "plainontology[mcp]"
cd examples
plainonto init library.onto --from sqlite:library.sql --from tools:agent-tools.json
# edit library.onto: add definitions, synonyms, same_as mappings
plainonto refresh library.onto # re-extract; your lines stay
plainonto drift library.onto # report only; exit 1 on drift
plainonto check library.onto
plainonto export library.onto --to turtle -o library.ttl
plainonto export library.onto --to linkml -o library.yaml
plainonto validate library.onto Loan record.json
The command is plainonto (short for plainontology; both work).
Sources are written KIND:PATH and stored in the file, relative to it:
| Kind | Path |
|---|---|
sqlite |
a SQLite database, or a .sql schema file (loaded into memory) |
jsonschema |
a JSON Schema file; $defs and nested objects become concepts. For Pydantic, dump Model.model_json_schema() first |
tools |
a JSON list of tool definitions, or an object with a tools list |
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 lines
Claude Code:
claude mcp add plainontology -- plainonto mcp /absolute/path/to/library.onto
Claude 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 |
|---|---|
list_concepts |
every concept with its definition |
describe_concept |
a concept's lines, inherited properties and who points to it |
search |
find concepts by name, label, synonym, definition or property |
validate_record |
check a JSON object against a concept before acting on it |
drift |
compare the file with its sources now |
propose |
only with --allow-proposals: add a line tagged [proposed]; a person accepts it by deleting the tag |
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 | pip install |
pip install |
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"]
PROPERTY -> CONCEPT [FLAGS] ["description"]
is_a CONCEPT
label "..."
definition "..."
synonym "..."
note "..."
same_as prefix:Term
Types: 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.
Development
python -m venv .venv && .venv/bin/pip install -e ".[dev]"
pytest
See CONTRIBUTING.md and ROADMAP.md.
Citing
If you use PlainOntology in research, please cite it using CITATION.cff.
Licence
MIT
Metadata
Release files for plainontology 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| plainontology-0.1.0.tar.gz | 34.6 kB | With provenance | Details for plainontology-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| plainontology-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for plainontology-0.1.0-py3-none-any.whl |
Total release size: 65.8 kB
Release files / plainontology-0.1.0.tar.gz
| Download URL | plainontology-0.1.0.tar.gz |
|---|---|
| Size | 34.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
657fb47d397764c004f1503870716e00d8d7fe44cc592f5728362095c22c12d3
|
|
BLAKE2b-256 checksum How to use checksums |
c21a47db9261f8e0ffa771df0331ba36e114bb3909e313f293d17c69a7a95e41
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.
Transparency logRelease files / plainontology-0.1.0-py3-none-any.whl
| Download URL | plainontology-0.1.0-py3-none-any.whl |
|---|---|
| Size | 31.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ca82d4b2e14cbdde8b0c2b76c8068b9ee9ec522fe60eb5c90237535ec767693c
|
|
BLAKE2b-256 checksum How to use checksums |
49f070dfd9a25d8c0958f74df2fd426aded04dd7e6a92c504fc7cd174f932c2f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.
Transparency logSecurity for plainontology 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for plainontology-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.