Skip to main content
Glama
nrwoodpsh
by nrwoodpsh

py-ontology-server-starter

本体知识服务器启动器 — FastAPI 语义层 + Apache Jena Fuseki 三元组存储,消费者同时支持 REST 和 MCP

用代码声明 Palantir 式对象中心本体(Object Type / Property / Link Type), 存储与查询按 W3C 标准(RDF / SPARQL 1.1)处理。应用代码只使用 SPARQL 标准, 因此即使将存储替换为 GraphDB 等,应用也无需改动。

┌─ 소비자 ──────────────────────────────┐
│  AI 에이전트(MCP)      앱·사람(REST)   │
└──────────┬───────────────┬───────────┘
           │               │
   mcp_server.py       api/rest.py      ← 이중 어댑터
           └───────┬───────┘
            ontology/ + store/           ← 코어: 온톨로지 정의 + SPARQL 클라이언트
                   │
        Apache Jena Fuseki (docker)      ← 저장·SPARQL·추론
                   ▲
             ingest/ 파이프라인           ← 지식원 → RDF 변환·적재

快速开始

# 1. 트리플스토어 기동
docker compose up -d fuseki          # http://localhost:3030 (admin / admin)

# 2. 앱 설치
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"

# 3. 샘플 데이터 적재 (CSV → RDF → Fuseki)
python -m ontology_server.ingest.example_csv data/sample/organizations.csv \
  --object-type organization --push

# 4. REST 서버 기동
uvicorn ontology_server.main:app --reload
# → http://localhost:8000/docs
curl localhost:8000/objects/organization

Related MCP server: mcp-ubergraph-query

MCP 适配器(面向 AI 代理)

通过 stdio 传输运行。Claude Code 项目的 .mcp.json

{
  "mcpServers": {
    "ontology": {
      "command": "/절대경로/.venv/bin/python",
      "args": ["-m", "ontology_server.mcp_server"]
    }
  }
}

提供的工具:list_object_types(了解模式)· search_objects(按类型查询实例)· sparql_query(只读直接查询)。

换成自己的领域

  1. src/ontology_server/ontology/sample.py 替换为领域本体 — 只需更改 Object Type 和 Link Type 声明,REST、MCP 和查询构建器就会随之适配。

  2. src/ontology_server/ingest/ 中添加按知识源的采集模块(参考 example_csv.py)。

  3. 如果需要外部对接和标准合规,将命名空间定为实际 URI 体系,并同时管理 OWL 模式文档。

测试

pytest                       # 단위 테스트 (Fuseki 불필요)
RUN_INTEGRATION=1 pytest     # Fuseki 기동 상태에서 통합 테스트 포함

配置

路径

作用

ontology/model.py

Object/Link Type 定义框架(Palantir 式)

ontology/sample.py

示例本体 — 项目中需要替换的文件

store/sparql.py

SPARQL 1.1 客户端(可替换存储的接入点)

api/rest.py

REST 适配器

mcp_server.py

MCP 适配器

ingest/

知识源 → RDF 采集管道

docker-compose.yml

启动 Fuseki

许可证

MIT

A
license - permissive license
Not graded
quality - not tested
C
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
    B
    quality
    C
    maintenance
    A Model Context Protocol server that provides read-only access to Ontotext GraphDB, enabling LLMs to explore RDF graphs and execute SPARQL queries.
    2
    11
    16
    GPL 3.0
  • A
    license
    A
    quality
    D
    maintenance
    Enables AI assistants to query the Ubergraph biomedical ontology SPARQL endpoint with tools for custom SPARQL queries, term lookup, search, and hierarchy traversal.
    4
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    Enables AI agents to interact with ontologies through the Ontology Access Kit, providing ontology querying and management capabilities.
    5
    MIT

View all related MCP servers

Related MCP Connectors

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/nrwoodpsh/py-ontology-server-starter'

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