Open Ontologies
AI-native ontology engineering. Generate OWL/RDF directly, validate with MCP tools, iterate until clean, govern with a Terraform-style lifecycle.
Prerequisites
This skill requires the Open Ontologies MCP server to provide the onto_* tools.
Install: cargo install open-ontologies or download from GitHub releases
MCP config (add to .mcp.json or Claude settings):
CODEBLOCK0
No credentials needed. All processing runs locally in an in-memory Oxigraph triple store. Network access is only used when you explicitly call onto_pull (fetch remote ontology) or onto_push (send to SPARQL endpoint) with a URL you provide. Monitor alerts (onto_monitor) are logged to stdout only.
Core Workflow
When building or modifying ontologies, follow this workflow. Decide which tools to call and in what order based on results -- this is not a fixed pipeline.
1. Generate
- - Understand the domain requirements (natural language, competency questions, methodology constraints)
- Generate Turtle/OWL directly -- Claude knows OWL, RDF, BORO, 4D modeling natively
- For complex methodologies, ask for background documents or constraints
2. Validate and Load
- - Call
onto_validate on the generated Turtle -- if it fails, fix syntax errors and re-validate - Call
onto_load to load into the Oxigraph triple store - Call
onto_stats to verify class count, property count, triple count match expectations
3. Verify
- - Call
onto_lint to check for missing labels, comments, domains, ranges -- fix any issues found - Call
onto_query with SPARQL to verify structure (expected classes, subclass hierarchies, competency questions) - If a reference ontology exists, call
onto_diff to compare
4. Iterate
- - If any step reveals problems, fix the Turtle and restart from step 2
- Continue until validation passes, stats match, lint is clean, and SPARQL queries return expected results
5. Persist
- - Call
onto_save to write the final ontology to a .ttl file - Call
onto_version to save a named snapshot for rollback
Ontology Lifecycle (Terraform-style)
For evolving ontologies in production:
- 1. Plan --
onto_plan shows added/removed classes, blast radius, risk score. Check onto_lock for protected IRIs. - Enforce --
onto_enforce with a rule pack (generic, boro, value_partition) checks design pattern compliance. - Apply --
onto_apply with mode safe (clear + reload) or migrate (add owl:equivalentClass bridges). - Monitor --
onto_monitor runs SPARQL watchers with threshold alerts. Use onto_monitor_clear if blocked. - Drift --
onto_drift compares versions with rename detection and self-calibrating confidence.
Data Extension Workflow
When applying an ontology to external data:
- 1.
onto_map -- generate mapping config from data schema + loaded ontology - INLINECODE27 -- parse structured data (CSV, JSON, NDJSON, XML, YAML, XLSX, Parquet) into RDF
- INLINECODE28 -- validate against SHACL shapes (cardinality, datatypes, classes)
- INLINECODE29 -- run RDFS or OWL-RL inference, materializing inferred triples
- Or use
onto_extend to run the full pipeline: ingest, SHACL validate, reason in one call
Clinical Terminology Support
For healthcare ontologies:
- -
onto_crosswalk -- look up mappings between ICD-10, SNOMED CT, and MeSH - INLINECODE32 -- add skos:exactMatch triples linking classes to clinical codes
- INLINECODE33 -- check class labels against clinical crosswalk terminology
Ontology Alignment
For aligning two ontologies:
- -
onto_align -- detect alignment candidates (equivalentClass, exactMatch, subClassOf) using 6 weighted signals - INLINECODE35 -- accept/reject candidates to self-calibrate confidence weights
Tool Reference
| Tool | When to use |
|---|
| INLINECODE36 | After generating or modifying Turtle -- always validate first |
| INLINECODE37 |
After validation passes -- loads into triple store |
|
onto_stats | After loading -- sanity check on counts |
|
onto_lint | After loading -- catches missing labels, domains, ranges |
|
onto_query | Verify structure, answer competency questions |
|
onto_diff | Compare against a reference or previous version |
|
onto_save | Persist ontology to a file |
|
onto_convert | Convert between formats (Turtle, N-Triples, RDF/XML, N-Quads, TriG) |
|
onto_clear | Reset the store before loading a different ontology |
|
onto_pull | Fetch ontology from a remote URL or SPARQL endpoint |
|
onto_push | Push ontology to a SPARQL endpoint |
|
onto_import | Resolve and load owl:imports chains |
|
onto_version | Save a named snapshot before making changes |
|
onto_history | List saved version snapshots |
|
onto_rollback | Restore a previous version |
|
onto_ingest | Parse structured data into RDF and load into store |
|
onto_map | Generate mapping config from data schema + ontology |
|
onto_shacl | Validate data against SHACL shapes |
|
onto_reason | Run RDFS or OWL-RL inference |
|
onto_extend | Full pipeline: ingest, SHACL validate, reason |
|
onto_plan | Show added/removed classes, blast radius, risk score |
|
onto_apply | Apply changes in safe or migrate mode |
|
onto_lock | Protect production IRIs from removal |
|
onto_drift | Compare versions with rename detection |
|
onto_enforce | Design pattern checks: generic, boro, value_partition, or custom |
|
onto_monitor | Run SPARQL watchers with threshold alerts |
|
onto_monitor_clear | Clear blocked state after resolving alerts |
|
onto_crosswalk | Look up clinical terminology mappings (ICD-10, SNOMED, MeSH) |
|
onto_enrich | Add skos:exactMatch triples linking to clinical codes |
|
onto_validate_clinical | Check class labels against clinical terminology |
|
onto_align | Detect alignment candidates between two ontologies |
|
onto_align_feedback | Accept/reject alignment candidates for self-calibrating weights |
|
onto_lineage | View session lineage trail (plan, enforce, apply, monitor, drift) |
|
onto_lint_feedback | Accept/dismiss lint issues to teach suppression |
|
onto_enforce_feedback | Accept/dismiss enforce violations to teach suppression |
Usage Examples
Build a pizza ontology from scratch
CODEBLOCK1
Load and query an existing ontology
CODEBLOCK2
Evolve an ontology safely
CODEBLOCK3
Ingest CSV data into a knowledge graph
CODEBLOCK4
Align two ontologies
CODEBLOCK5
Key Principle
Dynamically decide the next tool call based on what the previous tool returned. If onto_validate fails, fix and retry. If onto_stats shows wrong counts, regenerate. If onto_lint finds missing labels, add them. The MCP tools are individual operations -- Claude is the orchestrator.
开放本体论
AI原生本体工程。直接生成OWL/RDF,使用MCP工具验证,迭代至纯净,以Terraform风格生命周期进行治理。
前置条件
本技能需要开放本体论MCP服务器提供onto_*工具。
安装: cargo install open-ontologies 或从GitHub发布页下载
MCP配置(添加到.mcp.json或Claude设置中):
json
{
mcpServers: {
open-ontologies: {
command: open-ontologies,
args: [serve]
}
}
}
无需凭证。 所有处理均在内存中的Oxigraph三元组存储中本地运行。仅当您显式调用ontopull(获取远程本体)或ontopush(发送至SPARQL端点)并提供URL时,才会使用网络访问。监控告警(onto_monitor)仅记录到标准输出。
核心工作流
在构建或修改本体时,请遵循此工作流。根据结果决定调用哪些工具及其调用顺序——这不是固定流水线。
1. 生成
- - 理解领域需求(自然语言、能力问题、方法论约束)
- 直接生成Turtle/OWL——Claude原生掌握OWL、RDF、BORO、4D建模
- 对于复杂方法论,请求背景文档或约束条件
2. 验证与加载
- - 对生成的Turtle调用ontovalidate——若失败,修复语法错误并重新验证
- 调用ontoload加载至Oxigraph三元组存储
- 调用onto_stats验证类数量、属性数量、三元组数量是否符合预期
3. 核查
- - 调用ontolint检查缺失的标签、注释、定义域、值域——修复发现的问题
- 使用SPARQL调用ontoquery验证结构(预期类、子类层次结构、能力问题)
- 若存在参考本体,调用onto_diff进行比较
4. 迭代
- - 若任何步骤发现问题,修复Turtle并从步骤2重新开始
- 持续直至验证通过、统计匹配、检查干净、SPARQL查询返回预期结果
5. 持久化
- - 调用ontosave将最终本体写入.ttl文件
- 调用ontoversion保存命名快照以便回滚
本体生命周期(Terraform风格)
用于生产环境中演进的本体:
- 1. 规划——ontoplan显示新增/移除的类、影响范围、风险评分。检查ontolock中的受保护IRI。
- 强制——ontoenforce配合规则包(generic、boro、valuepartition)检查设计模式合规性。
- 应用——ontoapply使用模式safe(清除+重载)或migrate(添加owl:equivalentClass桥接)。
- 监控——ontomonitor运行带有阈值告警的SPARQL监视器。若被阻塞,使用ontomonitorclear。
- 漂移——onto_drift通过重命名检测和自校准置信度比较版本。
数据扩展工作流
将本体应用于外部数据时:
- 1. ontomap——从数据模式+已加载本体生成映射配置
- ontoingest——将结构化数据(CSV、JSON、NDJSON、XML、YAML、XLSX、Parquet)解析为RDF
- ontoshacl——根据SHACL形状(基数、数据类型、类)进行验证
- ontoreason——运行RDFS或OWL-RL推理,物化推理出的三元组
- 或使用onto_extend运行完整流水线:一次调用完成摄取、SHACL验证、推理
临床术语支持
用于医疗本体:
- - ontocrosswalk——查找ICD-10、SNOMED CT和MeSH之间的映射
- ontoenrich——添加将类链接到临床代码的skos:exactMatch三元组
- ontovalidateclinical——根据临床交叉引用术语检查类标签
本体对齐
用于对齐两个本体:
- - ontoalign——使用6种加权信号检测对齐候选(equivalentClass、exactMatch、subClassOf)
- ontoalign_feedback——接受/拒绝候选以自校准置信度权重
工具参考
| 工具 | 使用时机 |
|---|
| ontovalidate | 生成或修改Turtle后——始终先验证 |
| ontoload |
验证通过后——加载至三元组存储 |
| onto_stats | 加载后——对数量进行合理性检查 |
| onto_lint | 加载后——捕获缺失的标签、定义域、值域 |
| onto_query | 验证结构、回答能力问题 |
| onto_diff | 与参考版本或先前版本比较 |
| onto_save | 将本体持久化至文件 |
| onto_convert | 在格式间转换(Turtle、N-Triples、RDF/XML、N-Quads、TriG) |
| onto_clear | 在加载不同本体前重置存储 |
| onto_pull | 从远程URL或SPARQL端点获取本体 |
| onto_push | 将本体推送至SPARQL端点 |
| onto_import | 解析并加载owl:imports链 |
| onto_version | 在修改前保存命名快照 |
| onto_history | 列出已保存的版本快照 |
| onto_rollback | 恢复至先前版本 |
| onto_ingest | 将结构化数据解析为RDF并加载至存储 |
| onto_map | 从数据模式+本体生成映射配置 |
| onto_shacl | 根据SHACL形状验证数据 |
| onto_reason | 运行RDFS或OWL-RL推理 |
| onto_extend | 完整流水线:摄取、SHACL验证、推理 |
| onto_plan | 显示新增/移除的类、影响范围、风险评分 |
| onto_apply | 以安全或迁移模式应用变更 |
| onto_lock | 保护生产IRI免遭移除 |
| onto_drift | 通过重命名检测比较版本 |
| onto_enforce | 设计模式检查:通用、boro、值分区或自定义 |
| onto_monitor | 运行带有阈值告警的SPARQL监视器 |
| onto
monitorclear | 解决告警后清除阻塞状态 |
| onto_crosswalk | 查找临床术语映射(ICD-10、SNOMED、MeSH) |
| onto_enrich | 添加链接至临床代码的skos:exactMatch三元组 |
| onto
validateclinical | 根据临床术语检查类标签 |
| onto_align | 检测两个本体之间的对齐候选 |
| onto
alignfeedback | 接受/拒绝对齐候选以自校准权重 |
| onto_lineage | 查看会话谱系轨迹(规划、强制、应用、监控、漂移) |
| onto
lintfeedback | 接受/驳回lint问题以教导抑制 |
| onto
enforcefeedback | 接受/驳回强制违规以教导抑制 |
使用示例
从头构建披萨本体
为我构建一个披萨本体,包含Pizza、PizzaBase(ThinAndCrispy、DeepPan)、
PizzaTopping(Mozzarella、Tomato、Pepperoni、Mushroom)等类,
以及hasBase、hasTopping属性。所有内容包含rdfs:labels和rdfs:comments。
进行验证并运行能力查询,检查能否询问玛格丽特披萨有哪些配料?
加载并查询现有本体
从https://www.w3.org/TR/owl-guide/wine.rdf加载本体,显示统计信息,
进行lint检查,并运行SPARQL查询查找Wine的所有子类。
安全演进本体
我需要添加一个新类GlutenFreePizza作为Pizza的子类,并限制hasBase仅限GlutenFreeBase。
规划变更,根据通用规则进行强制,并以安全模式应用。
将CSV数据摄取至知识图谱
我有一个员工CSV文件,包含列:name、department、role、start_date。
将其映射到已加载的HR本体并进行摄取。然后使用SHACL形状验证,
并运行推理以物化部门层次结构。
对齐两个本体
加载schema.org和我的公司本体。运行onto_align查找equivalentClass
和exactMatch候选。我将进行审查并给出反馈以校准权重。
关键原则
根据