Skip to main content
Glama
OWL MCP Server

OWL MCP Server

by liftkkkk

🦉 OWL MCP Server

Let AI read and write your OWL / TTL / RDF ontology files directly

License: MIT Python MCP owlready2

English | 简体中文

Quick Start · Tools · Examples


Introduction

OWL MCP Server is an ontology manipulation server built on the Model Context Protocol (MCP).

It lets AI assistants such as Claude, Cursor, and WorkBuddy query, modify, and reason over your OWL/TTL/RDF ontology files as easily as ordinary files — no hand-written SPARQL, no OWL syntax details; complex knowledge-graph operations done through natural-language conversation.

You: "Find all individuals of class XX, sorted by amount in descending order"
AI:  [calls sparql_query] → returns structured results

Use Cases

  • 🏦 Finance: CRUD on bank-statement and invoice ontologies

  • 🏥 Healthcare: exploration and reasoning over clinical knowledge graphs

  • 🏗️ Engineering: management and validation of equipment and process ontologies

  • 🎓 Research: rapid prototyping and testing of OWL ontologies


Related MCP server: Ontology MCP

Quick Start

Step 1: Install dependencies

pip install mcp owlready2 rdflib

Or via requirements.txt:

pip install -r requirements.txt

⚠️ Reasoners need Java: run_reasoner (Pellet/HermiT) requires a local JDK 8+ installation.

Step 2: Configure your MCP client

WorkBuddy

Add to ~/.workbuddy/mcp.json:

{
  "mcpServers": {
    "owl": {
      "command": "python",
      "args": ["/absolute/path/server.py"]
    }
  }
}

💡 Recommended: use the absolute path of a virtualenv Python to avoid dependency conflicts:

"command": "C:/Users/yourname/.workbuddy/binaries/python/envs/default/Scripts/python.exe"

Claude Desktop

Add to claude_desktop_config.json:

{
  "mcpServers": {
    "owl-mcp": {
      "command": "python",
      "args": ["/absolute/path/server.py"]
    }
  }
}

Cursor

Add the same configuration to .cursor/mcp.json, restart Cursor, and the server is available in Agent mode.

Step 3: Enable it and start talking

In the WorkBuddy connector management page, find owl, click Trust to enable it, then just chat in natural language:

"Load the ontology file C:/work/xxxx.ttl"
"List all classes, only the ones starting with xxx:"
"Describe the full structure of the BankStatement class"
"Run the HermiT reasoner to check ontology consistency"
"Save the new classes back to the original file"

Tools

📖 Query tools

Tool

Description

load_ontology

Load an ontology file (local path or IRI; formats: TTL / OWL / RDF)

get_ontology_info

Get an overview (counts of classes, individuals, properties; namespaces)

list_classes

List all classes, with prefix filtering and limit

list_individuals

List all individuals, optionally filtered by class

list_properties

List object properties / data properties

describe_class

Describe a class in detail (parents, children, restrictions, known individuals)

describe_individual

Describe an individual (types and all property values)

search_entity

Fuzzy-search classes / individuals / properties by keyword

sparql_query

Run a SPARQL 1.1 SELECT query

✏️ Modification tools

Tool

Description

add_class

Add a new class (with optional parent, rdfs:label, rdfs:comment)

add_individual

Add a new individual (with optional initial property values)

add_object_property_assertion

Add an object-property triple assertion

save_ontology

Save the ontology (rdfxml / turtle / ntriples)

🧠 Reasoning tools

Tool

Description

run_reasoner

Run a reasoner (Pellet or HermiT) to check consistency and infer implicit knowledge

Note: add_* operations are not saved automatically — call save_ontology explicitly.


Examples

Exploring the ontology structure

You: Load xxx.ttl and give me an overview
AI:  This ontology has 47 classes, 213 individuals, 18 object properties...

You: Describe the BankStatement class
AI:  BankStatement is a subclass of FinancialDocument, with the following data
     properties: amount, currency, date...

SPARQL queries

-- Find all BankStatement individuals and their amounts (descending)
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX : <http://test.com/t#>

SELECT ?ind ?amount WHERE {
  ?ind rdf:type :BankStatement .
  ?ind :amount ?amount .
}
ORDER BY DESC(?amount)

Incremental modification

You: Add a new class AA whose parent is BB, with label "CC"
AI:  [calls add_class] → class AA added

You: Save the change in turtle format
AI:  [calls save_ontology] → saved to xxx.ttl

Consistency checking

You: Run the HermiT reasoner and check the ontology for logical contradictions
AI:  [calls run_reasoner] → the ontology is consistent; 3 new implicit class
     memberships were inferred...

Tech Stack

Component

Purpose

owlready2

OWL ontology loading, modification, reasoner invocation

rdflib

SPARQL 1.1 query engine

mcp

Model Context Protocol SDK


Notes

  • Reasoners need Java: Pellet / HermiT depend on JDK 8+; make sure java is on your system PATH

  • Large ontologies: beyond ~100k triples, use the limit parameter with the list_* tools

  • Changes are not auto-saved: all add_* operations only update the in-memory model; call save_ontology explicitly

  • SPARQL syntax: standard SPARQL 1.1, executed by the rdflib engine


Compatible MCP Clients

  • ✅ WorkBuddy

  • ✅ Trae/Traw-work

  • ✅ Claude

  • ✅ Cursor (Agent mode)

  • ✅ Any MCP-compliant AI client


License

MIT


☕ Buy Me a Coffee

OWL MCP Server is an open-source project I develop and maintain in my spare time, and it will stay free forever.

If it has saved you even half an hour of hand-writing SPARQL, consider buying me a coffee (¥9.9 is enough ☕) — every bit of support goes straight into new features and bug fixes.

Prefer not to donate? Giving the project a ⭐ Star, opening an Issue, or sharing it with someone who needs it is equally great support!


Available Tools

14 tools
add_classA

向本体添加一个新类,可指定父类、标签和注释。修改不会自动保存,需调用 save_ontology。

Inputs: class_name (required), label, comment, parent_class.

add_individualA

向本体添加一个新个体,并指定所属类。修改不会自动保存,需调用 save_ontology。

Inputs: class_name (required), individual_name (required), properties.

add_object_property_assertionA

为个体添加对象属性断言(subject --property--> object)。修改不会自动保存,需调用 save_ontology。

Inputs: object (required), subject (required), property (required).

describe_classA

描述一个类:父类、子类、等价类、限制条件、所有个体。

Inputs: class_name (required).

describe_individualA

描述一个个体:所属类、属性值(数据属性和对象属性)。

Inputs: individual_name (required).

get_ontology_infoB

获取当前加载本体的基本信息:IRI、类数量、个体数量、属性数量等。

Inputs: no named parameters.

list_classesA

列出本体中所有类(OWL Class)。可选按名称前缀过滤。

Inputs: limit, prefix.

list_individualsA

列出本体中所有个体(OWL Individual)。可选按类名过滤。

Inputs: limit, class_name.

list_propertiesB

列出本体中所有对象属性(ObjectProperty)和数据属性(DataProperty)。

Inputs: prop_type.

load_ontologyA

加载一个 OWL/TTL/RDF 本体文件(本地路径或 IRI)。后续所有操作都在这个本体上进行。

Inputs: path (required).

run_reasonerA

运行推理器(Pellet 或 HermiT)对本体进行推理,检查一致性并推断隐含知识。需要本机安装 JDK 8+。

Inputs: reasoner.

save_ontologyA

将当前本体(含所有未保存的修改)保存到文件。

Inputs: path, format.

search_entityA

按名称关键词搜索类、个体、属性(大小写不敏感模糊匹配)。

Inputs: keyword (required), limit.

sparql_queryA

对当前本体执行 SPARQL SELECT 查询,返回结果列表。

Inputs: query (required), limit.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.8/5.0

    Scored across 14 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose: loading, saving, listing, describing, adding, searching, reasoning, and querying. No two tools overlap in functionality.

    Naming Consistency4/5

    Most tool names follow a <verb>_<noun> pattern (e.g., add_class, describe_individual). The exception is sparql_query, which uses noun_noun, but it's still consistent with the underscore convention and clearly understandable.

    Tool Count5/5

    14 tools is well-scoped for an ontology server, covering essential operations without being overwhelming or too sparse.

    Completeness3/5

    Missing delete and update operations for classes, individuals, and properties. Only object property assertions can be added, not data property assertions or property definitions. However, core loading, saving, listing, describing, reasoning, and querying are present.

    Related MCP Connectors

    Related MCP Servers