mcp-ontology-layer
基于 OWL、HermiT 与 Ollama 的本地 MCP 语义代理
一种在 macOS 上完全本地执行的架构,用于通过 LLM 代理和基于 STDIO 的模型上下文协议(MCP)对银行本体(OWL/RDF)进行确定性检查、变更、描述逻辑(DL)推理和 SPARQL 查询。
核心能力
HermiT DL 推理: 集成的描述逻辑推理器(
sync_reasoner_hermit),用于验证本体一致性、计算推断的类层次结构并检测不可满足的类。SPARQL 查询引擎: 通过 RDFLib 直接在 RDF 知识图谱上执行 W3C SPARQL 查询,支持复杂的语义查询、过滤和聚合。
分类与实例变更(TBox/ABox): 动态插入 OWL 类、子类层次结构和命名个体断言。
交互式力导向可视化: 自动将知识图谱导出为交互式 PyVis HTML 网络。
双执行模式: 自动化批处理流水线(
agente.py)和持久化对话式 REPL(agent_interactive.py)。
Related MCP server: OWL-MCP
架构
该系统将模型推理与图执行解耦,分为四个核心层:
代理编排器:
agente.py:自动化流水线,端到端执行批量代理目标。agent_interactive.py:多轮对话式 REPL,维护状态并执行动态多步语义工作流。
LLM 引擎(
Ollama): 执行本地模型(例如glm-5.2:cloud、qwen2.5-coder),在不直接访问文件的情况下进行意图分解和参数格式化。MCP 服务器(
server.py): 通过 STDIO 通信的 JSON-RPC 2.0 接口,通过 Owlready2 和 RDFLib 将模型工具调用转换为确定性的语义图操作。语义层(
core.owl): 持久化的 W3C RDF/XML 本体图,使用 HermiT DL 推理器验证。
仓库结构
core.owl:RDF/XML 格式的基础银行本体文件(W3C OWL 标准)。server.py:原生 JSON-RPC 2.0 MCP 服务器,提供 TBox/ABox 变更、SPARQL 执行、HermiT 推理和 PyVis 图导出。agente.py:将 Ollama 连接到 MCP 服务器的自动化批量执行代理。agent_interactive.py:用于实时本体管理的交互式对话 REPL 代理。requirements.txt:Python 依赖(owlready2、rdflib、pyvis)。graph.html:导出的交互式 HTML 图可视化(按需生成)。README.md:项目架构、工具文档和设置说明。
先决条件
操作系统: macOS(Apple Silicon 或 Intel)
Python: 3.10 或更高版本
Ollama: 已安装并在本地运行
Java: OpenJDK / JRE(Owlready2 的 HermiT 推理器需要)
安装与环境设置
克隆仓库并进入项目目录:
git clone [https://github.com/jairorodriguezarias/mcp-ontology-layer.git](https://github.com/jairorodriguezarias/mcp-ontology-layer.git)
cd mcp-ontology-layer创建并激活虚拟环境:
python3 -m venv venv
source venv/bin/activate安装所需依赖:
pip install -r requirements.txt4 . 在 Ollama 中下载模型:
ollama pull glm-5.2:cloud运行代理演示:
python3 agente.py6 .
python3 agent_interactive.py可视化知识图谱
open graph.html可用的 MCP 工具
list_classes
参数: 无
描述: 加载
core.owl并返回所有已注册的本体类。add_subclass
参数:
new_class(字符串,必填)、parent_class(字符串,必填)描述: 在现有父类下插入一个新类,并将更新后的 RDF/XML 图保存到磁盘。
create_individual
参数:
class_name(字符串,必填)、individual_id(字符串,必填)描述: 实例化一个属于特定类的具体 ABox 个体。
check_consistency
参数: 无
描述: 运行 HermiT 描述逻辑(DL)推理器以验证逻辑一致性并检测不可满足的类。
execute_sparql
参数:
query(字符串,必填)描述: 对 RDF 知识图谱执行标准 W3C SPARQL 查询。
export_graph
参数:
output_html(字符串,可选;默认值:graph.html)描述: 使用 PyVis 生成本体的交互式力导向 HTML 图可视化。
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
Related MCP Connectors
Repository knowledge graph MCP server for codebase understanding and debugging.
Query your own knowledge graph from any MCP client. The graph lives in a database you own.
Cross-vendor AI memory over MCP. One semantic store, readable and writeable from every MCP client.
MCP server for querying BrainKB, a knowledge base for neuroscience knowledge graphs.
Related MCP Servers
- AlicenseCqualityDmaintenanceA Model Context Protocol (MCP) server that connects GraphDB's SPARQL endpoints and Ollama models to Claude, enabling Claude to query and manipulate ontology data while leveraging various AI models.283MIT
- FlicenseNot gradedqualityDmaintenanceA Model-Context-Protocol server that enables AI assistants to create, edit, and manage Web Ontology Language (OWL) ontologies through function calls using OWL functional syntax.22-
- AlicenseAqualityAmaintenanceAI-native ontology engineering MCP server for OWL/RDF/SPARQL. Validate, query, diff, lint, version, and govern knowledge graphs via Oxigraph triple store.422,971MIT

ontoloomofficial
AlicenseNot gradedqualityDmaintenanceMCP server for building and exploring OWL 2 ontologies using AI agents, with tools for axiom management, structural pattern matching, and persistent selections.25BSD 3-Clause