Content
<div align="center">
# Tool List
## Introduction
**OWL MCP Server** is a ontology operation server based on [Model Context Protocol (MCP)](https://modelcontextprotocol.io/).
It enables AI assistants like Claude, Cursor, and WorkBuddy to **directly query, modify, and reason** on your OWL/TTL/RDF ontology files — no need to write SPARQL by hand or understand OWL syntax details. Simply converse in natural language.
### Applicable Scenarios
- 🏦 **Financial Sector**: Add, delete, modify and query of bill and note ontologies
- 🏥 **Medical Health**: Exploration and reasoning of clinical knowledge graphs
- 🏗️ **Engineering Modeling**: Management and verification of equipment and process ontologies
- 🎓 **Academic Research**: Rapid prototyping and testing of OWL ontologies
## Quick Start
### Step 1: Install Dependencies
```bash
pip install mcp owlready2 rdflib
```
or use requirements.txt:
```bash
pip install -r requirements.txt
```
> ⚠️ **Reasoner depends on Java**: Using `run_reasoner` (Pellet/HermiT) requires local installation of **JDK 8+**
### Step 2: Configure MCP Client
#### WorkBuddy
Add the following configuration to `~/.workbuddy/mcp.json`:
```json
{
"mcpServers": {
"owl": {
"command": "python",
"args": ["/absolute/path/server.py"]
}
}
}
```
> 💡 **Recommendation**: Use the absolute path of Python in a virtual environment to avoid dependency conflicts:
> ```json
> "command": "C:/Users/yourname/.workbuddy/binaries/python/envs/default/Scripts/python.exe"
> ```
#### Claude Desktop
Add the following configuration to `claude_desktop_config.json`:
```json
{
"mcpServers": {
"owl-mcp": {
"command": "python",
"args": ["/absolute/path/server.py"]
}
}
}
```
#### Cursor
Add the same configuration to `.cursor/mcp.json` and restart Cursor to use it in Agent mode.
### Step 3: Enable and Start Conversation
Find `owl` in the WorkBuddy connector management page, click **Trust** to enable, and then start natural language conversation:
```
"Load ontology file C:/work/xxxx.ttl"
"List all classes, show only those starting with xxx:"
"Describe the complete structure of BankStatement class"
"Run HermiT reasoner, check ontology consistency"
"Save the added class back to the original file"
```
## Tool List
### 📖 Query Tools
| Tool | Description |
|------|------|
| `load_ontology` | Load ontology file (support local path or IRI, format: TTL / OWL / RDF) |
| `get_ontology_info` | Get ontology overview (number of classes, individuals, properties, namespaces) |
| `list_classes` | List all classes, support prefix filtering and quantity limitation |
| `list_individuals` | List all individuals, support filtering by class |
| `list_properties` | List object properties / data properties |
| `describe_class` | Describe class (parent class, subclass, restriction, known individual) |
| `describe_individual` | Describe individual (belonging type, all property values) |
| `search_entity` | Fuzzy search class / individual / property by keyword |
| `sparql_query` | Execute SPARQL 1.1 SELECT query |
### ✏️ Modification Tools
| Tool | Description |
|------|------|
| `add_class` | Add new class (can specify parent class, rdfs:label, rdfs:comment) |
| `add_individual` | Add new individual (can specify initial property value) |
| `add_object_property_assertion` | Add object property triple assertion |
| `save_ontology` | Save ontology (support rdfxml / turtle / ntriples) |
### 🧠 Reasoning Tools
| Tool | Description |
|------|------|
| `run_reasoner` | Run reasoner (Pellet or HermiT), check consistency and infer implicit knowledge |
> **Note**: `add_*` series of modification operations will not automatically save, need to explicitly call `save_ontology`.
## Example Usage
### Explore Ontology Structure
```
You: Load xxx.ttl, give me an overview
AI: The ontology has 47 classes, 213 individuals, 18 object properties...
You: Describe BankStatement class
AI: BankStatement is a subclass of FinancialDocument, has data properties: amount, currency, date...
```
### SPARQL Query
```sparql
-- Find all BankStatement and its amount (descending order)
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, parent class is BB, label is "CC"
AI: [Call add_class] → AA class added
You: Save this change as turtle format
AI: [Call save_ontology] → Saved to xxx.ttl
```
### Consistency Check
```
You: Run HermiT reasoner, check ontology consistency
AI: [Call run_reasoner] → Ontology consistent, inferred 3 new implicit class membership relationships...
```
## Technical Stack
| Component | Purpose |
|------|------|
| [owlready2](https://pypi.org/project/owlready2/) | OWL ontology loading, modification, reasoner call |
| [rdflib](https://rdflib.readthedocs.io/) | SPARQL 1.1 query engine |
| [mcp](https://github.com/modelcontextprotocol/python-sdk) | Model Context Protocol SDK |
## Precautions
- **Reasoner needs Java**: Pellet / HermiT depends on JDK 8+, make sure `java` is in system PATH
- **Large ontology**: When there are more than 100,000 triples, use `limit` parameter with `list_*` series operations
- **Modification not automatically saved**: All `add_*` operations only update memory model, need to manually call `save_ontology`
- **SPARQL syntax**: Use standard SPARQL 1.1 syntax, executed by rdflib engine
## Compatible MCP Clients
- ✅ WorkBuddy
- ✅ Trae/Traw-work
- ✅ Claude
- ✅ Cursor (Agent mode)
- ✅ Any AI client that supports MCP standard
## License
[MIT](LICENSE)
## ☕ Buy the author a cup of coffee
OWL MCP Server is an open-source project developed and maintained by me in my spare time, and it's permanently free.
If it saves you even half an hour of writing SPARQL, consider buying me a cup of coffee (¥9.9 is enough ☕) —
Your support will directly translate into new feature development and bug fixes.
<p align="center">
<img src="icon.jpg" alt="Donation Code - Buy the author a cup of coffee" width="280">
</p>
<p align="center"><i>Leave a message with your desired feature when donating, I'll prioritize it 😉</i></p>
**No donation?** Give the project a ⭐ Star, raise an Issue, or share it with those in need, it's also a huge support!