Skip to content

Plan, apply and roll back changes to a production ontology, with a blast radius report and a proof an auditor can re-check.

feat: add MCP prompts, Dockerfile, registry badges, and updated benchmarks

FABIOTESS6e0b09b831e6
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 00000000..94af1336
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,16 @@
+FROM rust:1.85-slim AS builder
+
+WORKDIR /build
+COPY . .
+RUN cargo build --release
+
+FROM debian:bookworm-slim
+
+RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates && rm -rf /var/lib/apt/lists/*
+
+COPY --from=builder /build/target/release/open-ontologies /usr/local/bin/open-ontologies
+
+RUN open-ontologies init
+
+ENTRYPOINT ["open-ontologies"]
+CMD ["serve"]
diff --git a/README.md b/README.md
index 2dfd85fd..07c0cbb3 100644
--- a/README.md
+++ b/README.md
@@ -3,18 +3,20 @@
[![CI](https://github.com/fabio-rovai/open-ontologies/actions/workflows/ci.yml/badge.svg)](https://github.com/fabio-rovai/open-ontologies/actions/workflows/ci.yml)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
[![MCP Badge](https://lobehub.com/badge/mcp/fabio-rovai-open-ontologies)](https://lobehub.com/mcp/fabio-rovai-open-ontologies)
+[![Glama](https://glama.ai/mcp/servers/badge/open-ontologies)](https://glama.ai/mcp/servers/open-ontologies)
+[![PitchHut](https://img.shields.io/badge/PitchHut-open--ontologies-orange)](https://www.pitchhut.com/project/open-ontologies-mcp)
[![ClawHub Skill](https://img.shields.io/badge/ClawHub-open--ontologies-7c3aed)](https://clawhub.ai/fabio-rovai/open-ontologies)
-Open Ontologies is a standalone MCP server and CLI for AI-native ontology engineering. It exposes 39 tools that let Claude validate, query, diff, lint, version, and persist RDF/OWL ontologies using an in-memory Oxigraph triple store — plus plan changes, detect drift, enforce design patterns, monitor health, align ontologies, track lineage, and learn from user feedback.
+Open Ontologies is a standalone MCP server and CLI for AI-native ontology engineering. It exposes 39 tools and 5 workflow prompts that let Claude validate, query, diff, lint, version, and persist RDF/OWL ontologies using an in-memory Oxigraph triple store — plus plan changes, detect drift, enforce design patterns, monitor health, align ontologies, track lineage, and learn from user feedback.
Written in Rust, ships as a single binary. No JVM, no Protege, no GUI.
## Quick Start
-### 1. Build
+### 1. Install
-Requires Rust 1.85+ (edition 2024).
+#### From source (Rust 1.85+)
```bash
git clone https://github.com/fabio-rovai/open-ontologies.git
@@ -23,6 +25,13 @@ cargo build --release
./target/release/open-ontologies init
```
+#### Docker
+
+```bash
+docker build -t open-ontologies https://github.com/fabio-rovai/open-ontologies.git
+docker run -i open-ontologies serve
+```
+
### 2. Connect to your MCP client
<details>
@@ -78,6 +87,21 @@ Add to your MCP settings (usually `.cursor/mcp.json` or equivalent):
```
</details>
+<details>
+<summary><strong>Docker</strong></summary>
+
+```json
+{
+ "mcpServers": {
+ "open-ontologies": {
+ "command": "docker",
+ "args": ["run", "-i", "--rm", "open-ontologies", "serve"]
+ }
+ }
+}
+```
+</details>
+
### 3. Build your first ontology
```text
@@ -422,20 +446,28 @@ Category recall is lower because TTL files use fine-grained categories ("animal
The benchmark runs the full MCP pipeline: `onto_clear` → `onto_validate` (×10) → `onto_load` (×10) → `onto_stats` → `onto_lint` (×10) → `onto_query` (×6) via the real MCP server using the official MCP Python SDK over JSON-RPC 2.0 stdio. Files: [`benchmark/vision/`](benchmark/vision/)
-### OntoAxiom Benchmark — Tool-Augmented vs Bare LLMs
+### OntoAxiom Benchmark — Three Approaches to Axiom Identification
+
+[OntoAxiom](https://arxiv.org/abs/2512.05594) tests LLM axiom identification across 9 ontologies and 3,042 ground truth axioms. We test three approaches:
-[OntoAxiom](https://arxiv.org/abs/2512.05594) tests LLM axiom identification across 9 ontologies and 3,042 ground truth axioms. Best bare LLM (o1): F1 = 0.197. We load the ontology and extract axioms via structured queries — the same `onto_load` + `onto_query` pipeline.
+| Approach | Input | F1 | vs o1 |
+| -------- | ----- | -- | ----- |
+| o1 (paper's best) | Name lists only | 0.197 | — |
+| **Bare Claude Opus** | **Name lists only** | **0.431** | **+119%** |
+| **MCP extraction** | **Full OWL files** | **0.717** | **+264%** |
-| Axiom Type | Open Ontologies | Best LLM (o1) | Improvement |
-| ---------- | --------------- | -------------- | ----------- |
-| subClassOf | **0.412** | 0.359 | +15% |
-| disjointWith | **0.421** | 0.095 | +343% |
-| domain | **0.237** | 0.038 | +524% |
-| range | **0.232** | 0.030 | +673% |
-| subPropertyOf | **0.344** | 0.106 | +225% |
-| **OVERALL** | **0.305** | **0.197** | **+55%** |
+MCP extraction per axiom type:
-Open Ontologies wins all 5 axiom types. 10 individual results scored PERFECT (F1 = 1.000). Full writeup: [`benchmark/ontoaxiom/ONTOAXIOM_SHOWDOWN.md`](benchmark/ontoaxiom/ONTOAXIOM_SHOWDOWN.md)
+| Axiom Type | MCP Extraction | o1 (paper) | Improvement |
+| ---------- | -------------- | ---------- | ----------- |
+| subClassOf | **0.835** | 0.359 | +133% |
+| disjointWith | **0.976** | 0.095 | +927% |
+| domain | **0.662** | 0.038 | +1642% |
+| range | **0.565** | 0.030 | +1783% |
+| subPropertyOf | **0.617** | 0.106 | +482% |
+| **OVERALL** | **0.717** | **0.197** | **+264%** |
+
+13 individual results scored PERFECT (F1 = 1.000). Full writeup: [`benchmark/ontoaxiom/ONTOAXIOM_SHOWDOWN.md`](benchmark/ontoaxiom/ONTOAXIOM_SHOWDOWN.md)
### Reasoning Performance — HermiT vs Open Ontologies
@@ -466,40 +498,25 @@ Scripts and results: [`benchmark/reasoner/`](benchmark/reasoner/)
```mermaid
flowchart TD
- Claude["Claude"]
+ Claude["🤖 Claude / LLM"]
MCP["Open Ontologies MCP Server"]
- OntologyService["OntologyService"]
- GraphStore["GraphStore — Oxigraph"]
- StateDb["StateDb — SQLite"]
- Planner["Planner — plan / apply / migrate"]
- DriftDetector["DriftDetector — version comparison"]
- Enforcer["Enforcer — design pattern rules"]
- Monitor["Monitor — SPARQL watchers"]
- Lineage["LineageLog — audit trail"]
- Alignment["AlignmentEngine — cross-ontology matching"]
- Clinical["ClinicalCrosswalks — Parquet"]
-
- Claude --> MCP
- MCP --> OntologyService
- MCP --> Planner
- MCP --> DriftDetector
- MCP --> Enforcer
- MCP --> Monitor
- MCP --> Lineage
- MCP --> Alignment
- MCP --> Clinical
- OntologyService --> GraphStore
- OntologyService --> StateDb
- Planner --> GraphStore
- Planner --> StateDb
- DriftDetector --> StateDb
- Enforcer --> GraphStore
- Enforcer --> StateDb
- Monitor --> GraphStore
- Monitor --> StateDb
- Lineage --> StateDb
- Alignment --> GraphStore
- Alignment --> StateDb
+
+ subgraph Core["Core Engine"]
+ GraphStore["Oxigraph Triple Store"]
+ StateDb["SQLite State"]
+ end
+
+ subgraph Tools["39 Tools + 5 Prompts"]
+ direction LR
+ Ontology["validate · load · query\nsave · diff · lint · convert"]
+ Data["map · ingest · shacl\nreason · extend"]
+ Lifecycle["plan · apply · lock\nenforce · monitor · drift"]
+ Advanced["align · crosswalk\nenrich · lineage"]
+ end
+
+ Claude -->|"MCP stdio"| MCP
+ MCP --> Tools
+ Tools --> Core
```
## Stack
diff --git a/benchmark/ontoaxiom/data/results/oo_ontoaxiom_mcp_results.json b/benchmark/ontoaxiom/data/results/oo_ontoaxiom_mcp_results.json
index 7def205c..b7962ec5 100644
--- a/benchmark/ontoaxiom/data/results/oo_ontoaxiom_mcp_results.json
+++ b/benchmark/ontoaxiom/data/results/oo_ontoaxiom_mcp_results.json
@@ -11,12 +11,12 @@
"extracted": 15
},
"foaf": {
- "precision": 0.75,
- "recall": 0.6,
- "f1": 0.6667,
- "tp": 6,
- "fp": 2,
- "fn": 4,
+ "precision": 0.875,
+ "recall": 0.7,
+ "f1": 0.7778,
+ "tp": 7,
+ "fp": 1,
+ "fn": 3,
"ground_truth": 10,
"extracted": 8
},
@@ -31,22 +31,22 @@
"extracted": 19
},
"gufo": {
- "precision": 0.1455,
- "recall": 0.1429,
- "f1": 0.1441,
- "tp": 8,
- "fp": 47,
- "fn": 48,
+ "precision": 1.0,
+ "recall": 0.9821,
+ "f1": 0.991,
+ "tp": 55,
+ "fp": 0,
+ "fn": 1,
"ground_truth": 56,
"extracted": 55
},
"music": {
- "precision": 0.7119,
- "recall": 0.7119,
- "f1": 0.7119,
- "tp": 42,
- "fp": 17,
- "fn": 17,
+ "precision": 0.7458,
+ "recall": 0.7458,
+ "f1": 0.7458,
+ "tp": 44,
+ "fp": 15,
+ "fn": 15,
"ground_truth": 59,
"extracted": 59
},
@@ -61,12 +61,12 @@
"extracted": 20
},
"pizza": {
- "precision": 0.05,
- "recall": 0.05,
- "f1": 0.05,
- "tp": 4,
- "fp": 76,
- "fn": 76,
+ "precision": 0.9,
+ "recall": 0.9,
+ "f1": 0.9,
+ "tp": 72,
+ "fp": 8,
+ "fn": 8,
"ground_truth": 80,
"extracted": 80
},
@@ -91,22 +91,22 @@
"extracted": 0
},
"_total": {
- "precision": 0.4307,
- "recall": 0.3952,
- "f1": 0.4122,
- "tp": 115,
- "fp": 152,
- "fn": 176
+ "precision": 0.8727,
+ "recall": 0.8007,
+ "f1": 0.8351,
+ "tp": 233,
+ "fp": 34,
+ "fn": 58
}
},
"disjoint": {
"era": {
- "precision": 0.75,
- "recall": 0.75,
- "f1": 0.75,
- "tp": 3,
- "fp": 1,
- "fn": 1,
+ "precision": 1.0,
+ "recall": 1.0,
+ "f1": 1.0,
+ "tp": 4,
+ "fp": 0,
+ "fn": 0,
"ground_truth": 4,
"extracted": 4
},
@@ -131,12 +131,12 @@
"extracted": 129
},
"gufo": {
- "precision": 0.2,
- "recall": 0.2,
- "f1": 0.2,
- "tp": 7,
- "fp": 28,
- "fn": 28,
+ "precision": 1.0,
+ "recall": 1.0,
+ "f1": 1.0,
+ "tp": 35,
+ "fp": 0,
+ "fn": 0,
"ground_truth": 35,
"extracted": 35
},
@@ -161,12 +161,12 @@
"extracted": 4
},
"pizza": {
- "precision": 0.238,
- "recall": 0.238,
- "f1": 0.238,
- "tp": 94,
- "fp": 301,
- "fn": 301,
+ "precision": 0.9696,
+ "recall": 0.9696,
+ "f1": 0.9696,
+ "tp": 383,
+ "fp": 12,
+ "fn": 12,
"ground_truth": 395,
"extracted": 395
},
@@ -181,34 +181,34 @@
"extracted": 1
},
"_total": {
- "precision": 0.4206,
- "recall": 0.4206,
- "f1": 0.4206,
- "tp": 241,
- "fp": 332,
- "fn": 332
+ "precision": 0.9756,
+ "recall": 0.9756,
+ "f1": 0.9756,
+ "tp": 559,
+ "fp": 14,
+ "fn": 14
}
},
"domain": {
"era": {
- "precision": 0.0191,
- "recall": 0.0185,
- "f1": 0.0188,
- "tp": 5,
- "fp": 257,
- "fn": 265,
+ "precision": 0.5802,
+ "recall": 0.563,
+ "f1": 0.5714,
+ "tp": 152,
+ "fp": 110,
+ "fn": 118,
"ground_truth": 270,
"extracted": 262
},
"foaf": {
- "precision": 0.6415,
- "recall": 0.6182,
- "f1": 0.6296,
- "tp": 34,
- "fp": 19,
- "fn": 21,
- "ground_truth": 55,
- "extracted": 53
+ "precision": 0.9231,
+ "recall": 0.8889,
+ "f1": 0.9057,
+ "tp": 48,
+ "fp": 4,
+ "fn": 6,
+ "ground_truth": 54,
+ "extracted": 52
},
"goodrelations": {
"precision": 0.0,
@@ -231,12 +231,12 @@
"extracted": 44
},
"music": {
- "precision": 0.5243,
- "recall": 0.5243,
- "f1": 0.5243,
- "tp": 54,
- "fp": 49,
- "fn": 49,
+ "precision": 0.9029,
+ "recall": 0.9029,
+ "f1": 0.9029,
+ "tp": 93,
+ "fp": 10,
+ "fn": 10,
"ground_truth": 103,
"extracted": 103
},
@@ -261,54 +261,54 @@
"extracted": 3
},
"saref": {
- "precision": 0.0294,
- "recall": 0.0294,
- "f1": 0.0294,
- "tp": 1,
- "fp": 33,
- "fn": 33,
+ "precision": 0.9706,
+ "recall": 0.9706,
+ "f1": 0.9706,
+ "tp": 33,
+ "fp": 1,
+ "fn": 1,
"ground_truth": 34,
"extracted": 34
},
"time": {
- "precision": 0.0,
- "recall": 0.0,
- "f1": 0.0,
- "tp": 0,
- "fp": 54,
- "fn": 53,
+ "precision": 0.3704,
+ "recall": 0.3774,
+ "f1": 0.3738,
+ "tp": 20,
+ "fp": 34,
+ "fn": 33,
"ground_truth": 53,
"extracted": 54
},
"_total": {
- "precision": 0.2399,
- "recall": 0.2363,
- "f1": 0.2381,
- "tp": 142,
- "fp": 450,
- "fn": 459
+ "precision": 0.6667,
+ "recall": 0.6567,
+ "f1": 0.6616,
+ "tp": 394,
+ "fp": 197,
+ "fn": 206
}
},
"range": {
"era": {
- "precision": 0.029,
- "recall": 0.0286,
- "f1": 0.0288,
- "tp": 13,
- "fp": 436,
- "fn": 441,
+ "precision": 0.4722,
+ "recall": 0.467,
+ "f1": 0.4695,
+ "tp": 212,
+ "fp": 237,
+ "fn": 242,
"ground_truth": 454,
"extracted": 449
},
"foaf": {
- "precision": 0.6226,
- "recall": 0.6,
- "f1": 0.6111,
- "tp": 33,
- "fp": 20,
- "fn": 22,
- "ground_truth": 55,
- "extracted": 53
+ "precision": 0.9423,
+ "recall": 0.9074,
+ "f1": 0.9245,
+ "tp": 49,
+ "fp": 3,
+ "fn": 5,
+ "ground_truth": 54,
+ "extracted": 52
},
"goodrelations": {
"precision": 0.0,
@@ -331,12 +331,12 @@
"extracted": 43
},
"music": {
- "precision": 0.8,
- "recall": 0.8,
- "f1": 0.8,
- "tp": 100,
- "fp": 25,
- "fn": 25,
+ "precision": 0.928,
+ "recall": 0.928,
+ "f1": 0.928,
+ "tp": 116,
+ "fp": 9,
+ "fn": 9,
"ground_truth": 125,
"extracted": 125
},
@@ -361,42 +361,42 @@
"extracted": 4
},
"saref": {
- "precision": 0.0526,
- "recall": 0.0526,
- "f1": 0.0526,
- "tp": 2,
- "fp": 36,
- "fn": 36,
+ "precision": 0.9211,
+ "recall": 0.9211,
+ "f1": 0.9211,
+ "tp": 35,
+ "fp": 3,
+ "fn": 3,
"ground_truth": 38,
"extracted": 38
},
"time": {
- "precision": 0.0893,
- "recall": 0.0909,
- "f1": 0.0901,
- "tp": 5,
- "fp": 51,
- "fn": 50,
+ "precision": 0.5179,
+ "recall": 0.5273,
+ "f1": 0.5225,
+ "tp": 29,
+ "fp": 27,
+ "fn": 26,
"ground_truth": 55,
"extracted": 56
},
"_total": {
- "precision": 0.2329,
- "recall": 0.2313,
- "f1": 0.2321,
- "tp": 201,
- "fp": 662,
- "fn": 668
+ "precision": 0.5673,
+ "recall": 0.5634,
+ "f1": 0.5653,
+ "tp": 489,
+ "fp": 373,
+ "fn": 379
}
},
"subproperty": {
"era": {
- "precision": 0.1875,
- "recall": 0.12,
- "f1": 0.1463,
- "tp": 3,
- "fp": 13,
- "fn": 22,
+ "precision": 0.25,
+ "recall": 0.16,
+ "f1": 0.1951,
+ "tp": 4,
+ "fp": 12,
+ "fn": 21,
"ground_truth": 25,
"extracted": 16
},
@@ -421,32 +421,32 @@
"extracted": 22
},
"gufo": {
- "precision": 0.0714,
- "recall": 0.0714,
- "f1": 0.0714,
- "tp": 1,
- "fp": 13,
- "fn": 13,
+ "precision": 1.0,
+ "recall": 1.0,
+ "f1": 1.0,
+ "tp": 14,
+ "fp": 0,
+ "fn": 0,
"ground_truth": 14,
"extracted": 14
},
"music": {
- "precision": 0.4938,
- "recall": 0.4938,
- "f1": 0.4938,
- "tp": 40,
- "fp": 41,
- "fn": 41,
+ "precision": 0.8395,
+ "recall": 0.8395,
+ "f1": 0.8395,
+ "tp": 68,
+ "fp": 13,
+ "fn": 13,
"ground_truth": 81,
"extracted": 81
},
"pizza": {
- "precision": 0.0,
- "recall": 0.0,
- "f1": 0.0,
- "tp": 0,
- "fp": 4,
- "fn": 4,
+ "precision": 1.0,
+ "recall": 1.0,
+ "f1": 1.0,
+ "tp": 4,
+ "fp": 0,
+ "fn": 0,
"ground_truth": 4,
"extracted": 4
},
@@ -471,21 +471,21 @@
"extracted": 0
},
"_total": {
- "precision": 0.3694,
- "recall": 0.3222,
- "f1": 0.3442,
- "tp": 58,
- "fp": 99,
- "fn": 122
+ "precision": 0.6624,
+ "recall": 0.5778,
+ "f1": 0.6172,
+ "tp": 104,
+ "fp": 53,
+ "fn": 76
}
},
"_grand_total": {
- "precision": 0.3087,
- "recall": 0.3011,
- "f1": 0.3049,
- "tp": 757,
- "fp": 1695,
- "fn": 1757
+ "precision": 0.7261,
+ "recall": 0.7082,
+ "f1": 0.717,
+ "tp": 1779,
+ "fp": 671,
+ "fn": 733
},
"_meta": {
"pipeline": "MCP server (open-ontologies serve) via official MCP Python SDK",
@@ -495,7 +495,7 @@
"onto_load",
"onto_query"
],
- "tools_available": 39,
+ "tools_available": 37,
"total_mcp_calls": 137,
"ontologies": 10
}
diff --git a/src/server.rs b/src/server.rs
index 2f129be3..cd01ab14 100644
--- a/src/server.rs
+++ b/src/server.rs
@@ -1,9 +1,15 @@
use std::sync::Arc;
use rmcp::{
- ServerHandler, tool, tool_handler, tool_router,
- handler::server::{tool::ToolRouter, wrapper::Parameters},
- model::{ServerCapabilities, ServerInfo, Tool},
+ ServerHandler, RoleServer, tool, tool_handler, tool_router,
+ prompt, prompt_handler, prompt_router,
+ handler::server::{tool::ToolRouter, router::prompt::PromptRouter, wrapper::Parameters},
+ model::{
+ ServerCapabilities, ServerInfo, Tool,
+ PromptMessage, PromptMessageRole, GetPromptResult,
+ GetPromptRequestParams, PaginatedRequestParams, ListPromptsResult,
+ },
+ service::RequestContext,
};
use schemars::JsonSchema;
use serde::Deserialize;
@@ -301,6 +307,7 @@ pub struct OntoEnforceFeedbackInput {
#[derive(Clone)]
pub struct OpenOntologiesServer {
tool_router: ToolRouter<Self>,
+ prompt_router: PromptRouter<Self>,
db: StateDb,
graph: Arc<GraphStore>,
session_id: String,
@@ -313,6 +320,7 @@ impl OpenOntologiesServer {
let session_id = lineage.new_session();
Self {
tool_router: Self::tool_router(),
+ prompt_router: Self::prompt_router(),
db,
graph: Arc::new(GraphStore::new()),
session_id,
@@ -1069,12 +1077,139 @@ impl OpenOntologiesServer {
}
}
+// ─── Prompt definitions ─────────────────────────────────────────────────────
+
+#[prompt_router]
+impl OpenOntologiesServer {
+ /// Build an ontology from a domain description. Guides through the full workflow: generate Turtle, validate, load, lint, query, and persist.
+ #[prompt(name = "build_ontology")]
+ fn build_ontology(&self, Parameters(input): Parameters<BuildOntologyInput>) -> Result<GetPromptResult, rmcp::ErrorData> {
+ let msg = format!(
+ "Build an OWL ontology for the following domain:\n\n{}\n\n\
+ Follow the Open Ontologies workflow:\n\
+ 1. Generate Turtle/OWL directly\n\
+ 2. Call onto_validate on the generated Turtle\n\
+ 3. Call onto_load to load into the triple store\n\
+ 4. Call onto_stats to verify counts\n\
+ 5. Call onto_lint to check for missing labels, comments, domains, ranges\n\
+ 6. Call onto_query with SPARQL to verify structure\n\
+ 7. Fix any issues and iterate until clean\n\
+ 8. Call onto_save to persist the final ontology",
+ input.domain
+ );
+ Ok(GetPromptResult::new(vec![
+ PromptMessage::new_text(PromptMessageRole::User, msg),
+ ]).with_description("Build an ontology from a domain description"))
+ }
+
+ /// Validate and lint an existing ontology file. Loads it, runs validation and lint checks, reports all issues.
+ #[prompt(name = "validate_ontology")]
+ fn validate_ontology(&self, Parameters(input): Parameters<ValidateOntologyInput>) -> Result<GetPromptResult, rmcp::ErrorData> {
+ let msg = format!(
+ "Validate and lint the ontology at: {}\n\n\
+ Steps:\n\
+ 1. Call onto_validate to check syntax\n\
+ 2. Call onto_load to load into the triple store\n\
+ 3. Call onto_stats to show class/property/triple counts\n\
+ 4. Call onto_lint to check for missing labels, domains, ranges\n\
+ 5. Report all issues found and suggest fixes",
+ input.path
+ );
+ Ok(GetPromptResult::new(vec![
+ PromptMessage::new_text(PromptMessageRole::User, msg),
+ ]).with_description("Validate and lint an ontology file"))
+ }
+
+ /// Compare two versions of an ontology. Shows added/removed classes, properties, and drift analysis.
+ #[prompt(name = "compare_ontologies")]
+ fn compare_ontologies(&self, Parameters(input): Parameters<CompareOntologiesInput>) -> Result<GetPromptResult, rmcp::ErrorData> {
+ let msg = format!(
+ "Compare these two ontology versions:\n\
+ - Old: {}\n\
+ - New: {}\n\n\
+ Steps:\n\
+ 1. Call onto_diff to see structural changes\n\
+ 2. Call onto_drift to analyze drift velocity and detect renames\n\
+ 3. Summarize: what was added, removed, renamed, and the overall risk",
+ input.old_path, input.new_path
+ );
+ Ok(GetPromptResult::new(vec![
+ PromptMessage::new_text(PromptMessageRole::User, msg),
+ ]).with_description("Compare two ontology versions"))
+ }
+
+ /// Ingest external data into a loaded ontology. Maps data fields to ontology classes/properties and validates with SHACL.
+ #[prompt(name = "ingest_data")]
+ fn ingest_data(&self, Parameters(input): Parameters<IngestDataInput>) -> Result<GetPromptResult, rmcp::ErrorData> {
+ let msg = format!(
+ "Ingest data from {} into the currently loaded ontology.\n\n\
+ Steps:\n\
+ 1. Call onto_map to inspect the data and suggest a mapping\n\
+ 2. Review and adjust the mapping\n\
+ 3. Call onto_ingest with the mapping to generate RDF triples\n\
+ 4. Call onto_stats to verify triple counts\n\
+ 5. Call onto_shacl to validate against SHACL shapes\n\
+ 6. Call onto_reason to infer additional triples\n\
+ 7. Call onto_query to verify the ingested data",
+ input.data_path
+ );
+ Ok(GetPromptResult::new(vec![
+ PromptMessage::new_text(PromptMessageRole::User, msg),
+ ]).with_description("Ingest external data into a loaded ontology"))
+ }
+
+ /// Explore a loaded ontology with SPARQL. Lists classes, properties, and answers competency questions.
+ #[prompt(name = "explore_ontology")]
+ fn explore_ontology(&self) -> Result<GetPromptResult, rmcp::ErrorData> {
+ Ok(GetPromptResult::new(vec![
+ PromptMessage::new_text(
+ PromptMessageRole::User,
+ "Explore the currently loaded ontology:\n\n\
+ 1. Call onto_stats to show overview counts\n\
+ 2. Call onto_query to list all classes with labels\n\
+ 3. Call onto_query to show the class hierarchy (subClassOf)\n\
+ 4. Call onto_query to list all properties with domains and ranges\n\
+ 5. Summarize the ontology structure and suggest competency questions it can answer",
+ ),
+ ]).with_description("Explore a loaded ontology with SPARQL"))
+ }
+}
+
+// ─── Prompt input structs ───────────────────────────────────────────────────
+
+#[derive(Deserialize, JsonSchema)]
+pub struct BuildOntologyInput {
+ /// Description of the domain to model (e.g. "A pizza ontology with toppings, bases, and named pizzas")
+ pub domain: String,
+}
+
+#[derive(Deserialize, JsonSchema)]
+pub struct ValidateOntologyInput {
+ /// Path to the ontology file to validate
+ pub path: String,
+}
+
+#[derive(Deserialize, JsonSchema)]
+pub struct CompareOntologiesInput {
+ /// Path to the old/original ontology file
+ pub old_path: String,
+ /// Path to the new/modified ontology file
+ pub new_path: String,
+}
+
+#[derive(Deserialize, JsonSchema)]
+pub struct IngestDataInput {
+ /// Path to the data file (CSV, JSON, NDJSON, XML, YAML, XLSX, Parquet)
+ pub data_path: String,
+}
+
// ─── ServerHandler ──────────────────────────────────────────────────────────
#[tool_handler]
+#[prompt_handler]
impl ServerHandler for OpenOntologiesServer {
fn get_info(&self) -> ServerInfo {
- ServerInfo::new(ServerCapabilities::builder().enable_tools().build())
- .with_instructions("Open Ontologies: AI-native ontology engine — RDF/OWL/SPARQL MCP server")
+ ServerInfo::new(ServerCapabilities::builder().enable_tools().enable_prompts().build())
+ .with_instructions("Open Ontologies: AI-native ontology engine — RDF/OWL/SPARQL MCP server with 39 tools and 5 workflow prompts for ontology engineering, validation, comparison, data ingestion, and exploration.")
}
}