semantica-knowledge-graph
Semantica is a session-scoped knowledge graph MCP server (MIT, v0.6.5+). In-memory graph state accumulates within a session but dies on process exit.
When NOT to Use
- A one-off fact lookup — use
memory_search(AiRaccoon) first. - No decision or extraction needed — skip graph ceremony.
- Durable facts outliving the session — write to AiRaccoon (
memory_write).
Workflows
1. Decision recording
record_decision(category="...", scenario="...", reasoning="...", outcome="...", confidence=0.85)add_entityfor key conceptsadd_relationship(source="...", target="...", relationship_type="...")- Cite decision id in commits or PRs for traceability
2. Entity extraction
- Option 2 (Agent-Guided — Primary): Use LLM reasoning to extract domain concepts and call
add_entity+add_relationship. Instantaneous, zero dependencies. - For Code Structures: Use
code-review-graphMCP tools (semantic_search_nodes_tool,find_callers,find_dependents) for code symbol graphs. - Option 1 (Native Local ML): Optional
extract_entities/extract_relationsvia PyTorch/HuggingFace (pip install torch transformers). Degrades if ML deps missing. - Verify with
get_graph_summary().
3. Decision archaeology
query_decisions(query="keyword")→ find decisionsget_causal_chain(decision_id="...")→ trace ancestryfind_precedents(scenario="...")→ check prior patterns
4. Graph export & AiRaccoon persistence pattern
To prevent data loss from Semantica's ephemeral process:
- Export auto-saves per session: the hook saves each
export_graphresult to.semantica/<session>.json, per-session and timestamped, so parallel sessions never collide. Wired but inert on 0.6.6 — see Gotchas. - Watch the directory once: The
ai-raccoon-memoryskill registers a one-time directory watch on.semantica/viamemory_watch_add(projectId, <absolute path to .semantica>); re-adding is a no-op. - Structural JSON Integration: AiRaccoon ingests every
.semantica/file, parses graphs and decisions, and embeds them into its persistent SQLite memory bank (memory.db). - Cross-Session Retrieval:
memory_searchin AiRaccoon returns both textual decision rationale and structural JSON graph relations. .semantica/is local staging: gitignore.semantica/in the consumer repo — the durable record lives in ai-raccoon memory, not the repo.
Escalation by result
- Graph empty →
get_graph_summaryreturns zero nodes; record decision or entities first - No precedent → record decision now so it becomes a precedent for next time
- Causal chain incomplete → add missing intermediate entities/relationships, re-query
AiRaccoon complementarity
- AiRaccoon (
memory_search): "what do we know?" — semantic recall over indexed docs - Semantica (
query_decisions): "how are things connected?" — structured reasoning over graph - Durable facts →
memory_write(AiRaccoon); ephemeral causal reasoning → Semantica
Gotchas
- Session-scoped only: in-memory graph dies on process exit. No
import_graphmechanism exists. - Extraction ML deps:
extract_entitiesneedstorch+transformers, not LLM API keys. - Parameter names:
add_relationshipusessource/target, notsource_id/target_id. - Known issue:
get_graph_analyticsunavailable in 0.6.5 — useget_graph_summary. - Upstream export bug (0.6.5/0.6.6): every
export_graphformat errors, no fix released — an empty.semantica/is this bug, not a broken bridge. Graph tools work. RDF writes progress to stdout, corrupting MCP; the entry setsSEMANTICA_DISABLE_PROGRESS=1. - All agents auto-save and nudge: export autosave is wired for Hermes (plugin),
Claude Code (PostToolUse), Copilot (postToolUse) — every
export_graphresult lands in.semantica/. The once-per-session export guidance nudge is active across all three hosts.
Verification Checklist
-
get_graph_summaryreturns node/edge counts reflecting session activity - At least one decision recorded and findable via
query_decisions - AiRaccoon
memory_searchand Semanticaquery_decisionsreturn complementary results -
export_graphauto-saves to.semantica/(per-session, timestamped) for AiRaccoon directory-watch ingestion