Skip to main content

ontary — the ontology SDK

Author an ontology once — typed objects, links, actions, functions, and a security policy — and get a governed runtime: scope- and sensitivity-aware reads, audited business-verb actions, and an MCP server for AI agents. The engine is domain-agnostic; the ticket domain below is just an example.

Python 3.12+ · pydantic-only core · mypy --strict · offline make verify.

Release metadata: version 0.15.0, store schema v11. Releases are annotated tags (v0.15.0).

Documentation: https://ryoochi0112.github.io/ontary/ (English / 日本語).

Install

From PyPI:

pip install "ontary[mcp]"

mcp serves the ontology to AI agents; postgres adds PostgresStore. The core depends only on pydantic. Pin an exact version: ontary is pre-1.0 and any minor may break you (see Compatibility).

uv add "ontary[mcp]==0.15.0"

or in pyproject.toml:

[project]
dependencies = ["ontary[mcp]==0.15.0"]

Without an index, install the tagged git ref:

uv add "ontary @ git+https://github.com/ryoochi0112/ontary@v0.15.0"

Quickstart

Two object types, one business-verb action, a SQLite store, and an MCP server for one queue-scoped agent. Runs as-is (tests/test_docs.py executes it).

from ontary import (
    ActionContext, ActionError, ActionParams, Consumer, DirectProperty,
    ObjectStore, Ontology, OntologyObject, SelfScope, Source,
    build_mcp_server, prop, target,
)

ontology = Ontology(name="tickets", scope_levels=["queue"])

@ontology.object(layer="L0", scope=[SelfScope(level="queue")])
class Queue(OntologyObject):
    id: str = prop(primary_key=True)
    name: str

@ontology.object(
    layer="L0", owned={"escalated": False},
    scope=[DirectProperty(level="queue", property_name="queue_id")],
)
class Ticket(OntologyObject):
    id: str = prop(primary_key=True)
    subject: str
    queue_id: str = prop(scope_level="queue")
    escalated: bool | None = prop(default=False)

class EscalateTicket(ActionParams):
    ticket_id: str = target(Ticket)

@ontology.action(
    EscalateTicket, target=Ticket, roles=["Agent"],
    display_name="Escalate ticket", description="Mark a ticket urgent.",
    api_name="EscalateTicket",
)
def escalate(ctx: ActionContext, params: EscalateTicket) -> dict[str, str]:
    if ctx.read_current("Ticket", params.ticket_id) is None:
        raise ActionError("ticket does not exist", code="PRECONDITION_FAILED")
    ctx.update("Ticket", params.ticket_id, {"escalated": True})
    return {"ticket_id": params.ticket_id}

ontology.validate()
store = ObjectStore(ontology.registry)          # ObjectStore(registry, "tickets.db") persists
source = Source(source_system="demo")
store.insert("Queue", {"id": "queue-a", "name": "Billing"}, source)
ticket_id = store.insert(
    "Ticket", {"subject": "Invoice mismatch", "queue_id": "queue-a"}, source
)
agent = Consumer(actor_id="agent-1", role="Agent", scope_level="queue",
                 scope_id="queue-a", kind="human")
client = ontology.bind(store).for_consumer(agent)
client.execute(EscalateTicket(ticket_id=ticket_id))
assert client.get(Ticket, ticket_id).escalated is True

server = build_mcp_server(ontology, store, agent)   # server.run() serves stdio

The full Org → Queue → Ticket → Comment ontology with functions and a multi-consumer MCP server is examples/tickets/.

Command line

The package installs ontary and ontary-mcp.

  • ontary validate pkg.module:attr validates an ontology and reports diagnostics. Use --json for JSON output.
  • ontary serve pkg.module:attr --dev [--store PATH] [--port N] serves an ontology over localhost MCP.
  • ontary version prints the version.
ontary serve your_app.ontology:ontology --dev --store ./dev.sqlite --port 8000

ontary-mcp is a placeholder that exits with instructions. Full flags and exit codes: CLI reference.

Where to go

Learn about Destination
The docs site (EN / 日本語) https://ryoochi0112.github.io/ontary/
First ontology in ten minutes Getting started · 日本語
Authoring an ontology Ontology design guide · 日本語
Names and errors API reference · error codes · 日本語
Storage and tenancy Storage, tenancy, and schema
MCP serving MCP serving
Command line CLI reference · 日本語
Testing your ontology Testing · 日本語
Worked recipes Tickets reference app
What is planned Roadmap
Compatibility and migration CHANGELOG.md · Compatibility
Cutting a release (maintainers) Releasing
Reporting a vulnerability Security policy

License

MIT — see LICENSE. ontary continues the ontos SDK, which Atrae, Inc. authored and released to the author for open-source development.

Metadata

Release files for ontary 0.15.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ontary 0.15.0
File Size Uploaded
ontary-0.15.0.tar.gz 740.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ontary 0.15.0
File Interpreter ABI Platform
ontary-0.15.0-py3-none-any.whl Python 3 none any Details

Total release size: 934.5 kB

Release files / ontary-0.15.0.tar.gz

Download URL ontary-0.15.0.tar.gz
Size 740.0 kB
Tags Source
SHA-256 checksum
How to use checksums
65e2dfef28f58162c6d8fd02b9a7f3e11adf05daf940679e1ebdbb5e6101c87b
BLAKE2b-256 checksum
How to use checksums
f08b8bec7a48a76e9121e7683aafb663a8ef4cb093a2fa076c6e4359b7bd5351
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 27, 2026.

Transparency log

Release files / ontary-0.15.0-py3-none-any.whl

Download URL ontary-0.15.0-py3-none-any.whl
Size 194.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6346909a26597a7e28c76360dda4e9b7f3b3e653754912df583c9e4a32388dd0
BLAKE2b-256 checksum
How to use checksums
2b614696d26c6c536d61ad2de48ab4045eb05ed914520e477a8a2e32ce0fe4f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 27, 2026.

Transparency log

Release history Release notifications | RSS feed

0.18.0

2 release files

0.17.0

2 release files

0.16.0

2 release files

This release

0.15.0 This release

2 release files

0.14.0

2 release files

0.13.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page