| title | Ontology Agent Tools | ||||
|---|---|---|---|---|---|
| description | Guide for using ontology read/write tools via MCP to discover, read, propose, and validate ontology notes | ||||
| category | how-to | ||||
| tags |
|
||||
| updated-date | 2026-02-11 | ||||
| difficulty-level | intermediate |
VisionFlow exposes 7 ontology tools that agents can invoke via MCP (Model Context Protocol) or REST API. These tools enable agents to discover knowledge, read enriched notes, validate queries, traverse the ontology graph, and propose new notes or amendments — all grounded in OWL 2 EL++ reasoning via the Whelk inference engine.
Logseq markdown notes with OntologyBlock headers ARE the knowledge graph nodes. Discovery happens via ontology semantics: class hierarchy traversal, Whelk subsumption reasoning, and relationship fan-out.
flowchart TB
subgraph Agent["AI Agent"]
MCP[MCP Tool Call]
end
subgraph API["VisionFlow REST API"]
Handler[ontology_agent_handler]
end
subgraph Services["Service Layer"]
QS[OntologyQueryService]
MS[OntologyMutationService]
end
subgraph Data["Data Stores"]
Repo[OntologyRepository<br>In-Memory Store]
Neo4j[(Neo4j)]
Whelk[Whelk EL++<br>Inference Engine]
end
subgraph Output["External"]
GitHub[GitHub PR]
end
MCP -->|HTTP POST| Handler
Handler --> QS
Handler --> MS
QS --> Repo
QS --> Neo4j
QS --> Whelk
MS --> Repo
MS --> Whelk
MS --> GitHub
Find relevant ontology classes by keyword with Whelk inference expansion.
MCP Tool Name: ontology_discover
REST Endpoint: POST /api/ontology-agent/discover
Input:
{
"query": "neural network",
"limit": 10,
"domain": "ai"
}| Field | Type | Required | Description |
|---|---|---|---|
query |
string | Yes | Keywords to search for |
limit |
integer | No | Max results (default: 20) |
domain |
string | No | Filter by domain prefix (e.g., "ai", "mv") |
Output: Array of DiscoveryResult:
[
{
"iri": "ai:NeuralNetwork",
"preferred_term": "Neural Network",
"definition_summary": "A computational model inspired by...",
"relevance_score": 0.95,
"quality_score": 0.8,
"domain": "ai",
"relationships": [
{ "rel_type": "subClassOf", "target_iri": "ai:MachineLearning", "target_term": "Machine Learning" }
],
"whelk_inferred": false
}
]Discovery Pipeline:
- Keyword match against
OwlClasspreferred_term and label - Expand via Whelk transitive closure (subclasses + superclasses)
- Follow semantic relationships (has-part, requires, enables, bridges-to)
- Score and rank results by relevance
Read a full ontology note with axioms, relationships, and schema context.
MCP Tool Name: ontology_read
REST Endpoint: POST /api/ontology-agent/read
Input:
{
"iri": "mv:Person"
}Output: EnrichedNote with:
- Full Logseq markdown content
- Ontology metadata (OWL class, physicality, role, domain, quality score)
- Whelk-inferred axioms
- Related notes with summaries
- Schema context for LLM grounding
Execute Cypher queries against the knowledge graph with schema-aware validation.
MCP Tool Name: ontology_query
REST Endpoint: POST /api/ontology-agent/query
Input:
{
"cypher": "MATCH (n:Person) RETURN n LIMIT 10"
}Validation Features:
- Checks all node labels against known OWL classes
- Provides Levenshtein distance hints for typos (e.g., "Perzon" → "Did you mean Person?")
- Built-in labels (OwlClass, OwlProperty, etc.) always pass validation
- Returns validation errors before execution
Walk the ontology graph via BFS from a starting node.
MCP Tool Name: ontology_traverse
REST Endpoint: POST /api/ontology-agent/traverse
Input:
{
"start_iri": "mv:Person",
"depth": 3,
"relationship_types": ["subClassOf", "has-part"]
}| Field | Type | Required | Description |
|---|---|---|---|
start_iri |
string | Yes | Starting class IRI |
depth |
integer | No | Max BFS depth (default: 3) |
relationship_types |
array | No | Filter by relationship types |
Output: TraversalResult with nodes and edges discovered during BFS.
Create new notes or amend existing ones with Whelk consistency checks.
MCP Tool Name: ontology_propose
REST Endpoint: POST /api/ontology-agent/propose
Create Input:
{
"action": "create",
"preferred_term": "Quantum Computing",
"definition": "A type of computation using quantum mechanics",
"owl_class": "tc:QuantumComputing",
"physicality": "non-physical",
"role": "concept",
"domain": "tc",
"is_subclass_of": ["mv:Technology"],
"relationships": { "requires": ["tc:Qubit"] },
"alt_terms": ["QC"],
"owner_user_id": "user-123",
"agent_context": {
"agent_id": "researcher-001",
"agent_type": "researcher",
"task_description": "Research quantum computing concepts",
"confidence": 0.85,
"user_id": "user-123"
}
}Amend Input:
{
"action": "amend",
"target_iri": "mv:Person",
"amendment": {
"add_relationships": { "has-part": ["mv:Brain"] },
"update_definition": "A human being or sentient entity"
},
"agent_context": { ... }
}Proposal Pipeline:
- Generate Logseq markdown with
OntologyBlockheader - Validate via OntologyParser round-trip
- Check Whelk EL++ consistency (rejects inconsistent proposals)
- Compute quality score (definition, relationships, alt_terms completeness)
- Stage in repository
- Create GitHub PR if
GITHUB_TOKENis set
Output: ProposalResult with:
proposal_id: Unique identifierconsistency: Whelk consistency reportquality_score: Automated completeness score (0.0 - 1.0)markdown_preview: Generated Logseq markdownpr_url: GitHub PR URL (if created)status: Staged | PRCreated | Merged | Rejected
Validate a set of axioms against the Whelk reasoner without creating a proposal.
MCP Tool Name: ontology_validate
REST Endpoint: POST /api/ontology-agent/validate
Input:
{
"axioms": [
{ "axiom_type": "SubClassOf", "subject": "Cat", "object": "Animal" },
{ "axiom_type": "DisjointWith", "subject": "Cat", "object": "Dog" }
]
}Output: ConsistencyReport with consistency status and explanation.
Check ontology service health and statistics.
MCP Tool Name: ontology_status
REST Endpoint: GET /api/ontology-agent/status
Output: Class count, axiom count, service health status.
Configure ontology agent behavior in your environment or AppFullSettings:
[ontology_agent]
auto_merge_threshold = 0.95
min_confidence = 0.6
max_discovery_results = 50
require_consistency_check = true
github_owner = "DreamLab-AI"
github_repo = "VisionFlow"
github_base_branch = "main"
notes_path_prefix = "pages/"
pr_labels = ["ontology", "agent-proposed"]| Setting | Default | Description |
|---|---|---|
auto_merge_threshold |
0.95 | Quality score above which proposals auto-merge |
min_confidence |
0.6 | Minimum agent confidence to accept proposals |
max_discovery_results |
50 | Cap on discovery results |
require_consistency_check |
true | Require Whelk consistency before staging |
| Variable | Required | Description |
|---|---|---|
GITHUB_TOKEN |
No | Enables automatic PR creation for proposals |
GITHUB_OWNER |
No | GitHub repository owner |
GITHUB_REPO |
No | GitHub repository name |
Notes are per-user: each user's agents write to their own namespace. The owner_user_id in NoteProposal and user_id in AgentContext control ownership. Agents can only amend notes owned by their user.
- Agent Orchestration - Deploy and coordinate AI agents
- Ontology Reasoning Pipeline - Whelk inference details
- Ontology Storage Architecture - Data persistence
- REST API Reference - Full API documentation