Skip to main content
Glama

基于 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

架构

该系统将模型推理与图执行解耦,分为四个核心层:

  1. 代理编排器:

    • agente.py:自动化流水线,端到端执行批量代理目标。

    • agent_interactive.py:多轮对话式 REPL,维护状态并执行动态多步语义工作流。

  2. LLM 引擎(Ollama): 执行本地模型(例如 glm-5.2:cloudqwen2.5-coder),在不直接访问文件的情况下进行意图分解和参数格式化。

  3. MCP 服务器(server.py): 通过 STDIO 通信的 JSON-RPC 2.0 接口,通过 Owlready2 和 RDFLib 将模型工具调用转换为确定性的语义图操作。

  4. 语义层(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 依赖(owlready2rdflibpyvis)。

  • graph.html:导出的交互式 HTML 图可视化(按需生成)。

  • README.md:项目架构、工具文档和设置说明。

先决条件

  • 操作系统: macOS(Apple Silicon 或 Intel)

  • Python: 3.10 或更高版本

  • Ollama: 已安装并在本地运行

  • Java: OpenJDK / JRE(Owlready2 的 HermiT 推理器需要)

安装与环境设置

  1. 克隆仓库并进入项目目录:

git clone [https://github.com/jairorodriguezarias/mcp-ontology-layer.git](https://github.com/jairorodriguezarias/mcp-ontology-layer.git)
cd mcp-ontology-layer
  1. 创建并激活虚拟环境:

python3 -m venv venv
source venv/bin/activate
  1. 安装所需依赖:

pip install -r requirements.txt

4 . 在 Ollama 中下载模型:

ollama pull glm-5.2:cloud
  1. 运行代理演示:

python3 agente.py

6 .

python3 agent_interactive.py
  1. 可视化知识图谱

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 图可视化。

F
license - not found
Not graded
quality - not tested
B
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • A
    license
    C
    quality
    D
    maintenance
    A 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.
    28
    3
    MIT
  • A
    license
    A
    quality
    D
    maintenance
    An MCP server that enables AI-powered exploration of RDF data and SPARQL querying via RDF4J. It provides tools for executing queries, searching knowledge graph resources, and retrieving schema summaries.
    13
    1
    MIT

View all related MCP servers

Related MCP Connectors

  • Cross-vendor AI memory over MCP. One semantic store, readable and writeable from every MCP client.

  • AI Reasoning Cache & Consensus Layer with 11 MCP tools via Streamable HTTP.

  • Private-by-default, local-first memory/context/task orchestrator for MCP apps and agents.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/jairorodriguezarias/mcp-ontology-layer'

If you have feedback or need assistance with the MCP directory API, please join our Discord server