Skip to main content
Glama

🧠 SmartMemory

Give your LLM structured, verifiable memory β€” turn conversations into knowledge graphs your AI can reason over.

CAUTION

Proof of Concept. SmartMemory is an experimental implementation of a neuro-symbolic architecture, built to explore how LLMs can interact with knowledge graphs to learn and apply rules. It is not intended for production use β€” treat it as a research and learning playground.


Why SmartMemory?

LLMs are brilliant talkers with no real memory. Across a conversation they forget, they can't explain why they concluded something, and they happily state things that were never verified.

SmartMemory adds the missing half: a symbolic brain.

  • Facts you state are stored in an auditable knowledge graph (RDF), each with its provenance.

  • Logic is captured as explicit, inspectable rules (SPARQL/OWL) β€” not hidden in weights.

  • New conclusions are derived, traceable, and reversible β€” and ambiguous ones are sent back to you for validation.

The result is an assistant that doesn't just sound right β€” it can show its reasoning.


Related MCP server: dragon-brain

What it can do

SmartMemory turns your AI assistant into a domain expert that supports:

  • Asynchronous reasoning β€” deductions run in the background (InferenceManager) without slowing the conversation.

  • Uncertainty handling β€” ambiguous facts trigger a human-in-the-loop validation workflow.

  • Smart NLP extraction β€” handles complex sentences, coreferences, and direct Turtle notation.

  • Provenance & audit β€” every stored fact keeps its origin (UUID, source, timestamp).

  • Dynamic rule engine β€” learns and applies new SPARQL rules on the fly.


How it works

flowchart LR
    A["Natural-language<br/>conversation"] -->|LLM extraction| B["Facts"]
    B --> C[("Knowledge Graph<br/>RDF / Turtle")]
    C -->|SPARQL / OWL rules| D["Inference engine"]
    D -->|new deductions| C
    D -->|ambiguous?| E["Human-in-the-loop<br/>validation"]
    E -->|approve rule / fact| C
    C -->|provenance + audit| F["Verifiable answers"]

The LLM is the language cortex (understanding and extraction); the knowledge graph and rule engine are the symbolic memory (storage, logic, proof). Neither alone is enough β€” together they are neuro-symbolic.


Two ways to use it

πŸ’¬ Conversational Mode β€” the "Brain"

πŸ—οΈ Supervision Mode β€” the "Factory"

For

Individuals using an LLM client (Claude Desktop, etc.)

Teams, developers, heavy users

Goal

Let your assistant remember facts and learn logic as you chat

Extract thousands of rules from documents (PDFs) and visualize the graph

How

Configure it as an MCP server

Deploy the full dashboard via Docker

Setup

Jump to setup ↓

Jump to setup ↓


Quick start

I want to…

Go to

Get running in 5 minutes

Quick Start Guide

Try the advanced demo

Demo Procedure

Understand the internals

Architecture Β· Neuro-symbolic principles

Configure a provider

Configuration reference

Fix a problem

Troubleshooting

Browse all docs

Documentation index


Mode 1 β€” Conversational Setup (MCP)

Gives your LLM long-term memory and logical deduction.

No Python required. The image is published on GitHub Container Registry.

Claude Desktop β€” edit ~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "smart-memory": {
      "command": "docker",
      "args": ["run", "--rm", "-i", "ghcr.io/mauriceisrael/smart-memory:latest"]
    }
  }
}

The same block works for any MCP client (e.g. Cline) β€” just point it at your client's mcp_settings.json. Restart the client and you're done. βœ…

Option B β€” Local server (from source) πŸ”’

Best for developers and privacy-conscious users.

git clone https://github.com/MauriceIsrael/SmartMemory
cd SmartMemory
python3 -m venv venv
source venv/bin/activate
pip install -e .

Then point Claude Desktop at your local install:

{
  "mcpServers": {
    "smartmemory": {
      "command": "/absolute/path/to/SmartMemory/venv/bin/python",
      "args": ["-m", "smart_memory.server"]
    }
  }
}

Restart Claude and try: "I know Bob. He goes to work by car. Can he vote?" β€” see the demo below.


Mode 2 β€” Supervision Setup (Docker)

Runs the web dashboard and API server β€” ideal for visualizing the knowledge graph, extracting rules from PDFs, and hosting a shared memory for a team.

# Dashboard mode β€” example with Mistral
docker run -p 8080:8080 \
  -e LLM_PROVIDER=mistral \
  -e LLM_MODEL=mistral-large-latest \
  -e LLM_API_KEY=your-api-key \
  -v $(pwd)/brain:/app/data \
  ghcr.io/mauriceisrael/smart-memory:latest dashboard
# Dashboard mode β€” example with a local model (Ollama)
docker run -p 8080:8080 \
  -e LLM_PROVIDER=ollama \
  -e LLM_MODEL=llama3 \
  -e LLM_BASE_URL=http://172.17.0.1:11434 \
  -v $(pwd)/brain:/app/data \
  ghcr.io/mauriceisrael/smart-memory:latest dashboard

Add dashboard to start the web server; without it the container starts in MCP mode. The -v volume persists your knowledge graph and rules. Open the dashboard at http://localhost:8080.


LLM configuration

SmartMemory uses an LLM to extract facts and rules from natural language and documents. Configure it via the dashboard Admin page or via environment variables (-e LLM_PROVIDER=…).

Provider

Example models

Notes

Mistral

mistral-large-latest, mistral-small-latest

European, La Plateforme API

Ollama (local, free)

llama3, qwen2.5-coder, mistral

Runs offline

OpenAI

gpt-4, gpt-3.5-turbo

Anthropic

claude-3-5-sonnet

Google

gemini-1.5-pro

β†’ Full configuration guide

Extracting rules from documents

  1. Upload a PDF (e.g. Company_Policy.pdf).

  2. Pick a provider β€” the server needs an API key (or a local Ollama) to read the document.

  3. Review & approve β€” the system proposes rules; you accept them in bulk from the dashboard.


Interactive demo β€” from facts to rules

What happens in Conversational Mode:

> I know Bob
LLM: ✦ I've recorded the fact: I know Bob.

> He goes to work by car
LLM: ✦ Noted: Bob goes to work by car.

> Can Bob vote?
LLM: ✦ I can't conclude yet β€” but since he drives, he is likely an adult.
     May I add the rule "Drivers are adults"?

> yes
LLM: ✨ Rule 'drivers_are_adults' added.
     May I also add "Adults can vote"?

> yes
LLM: ✨ Rule 'adults_can_vote' added.
     ✦ Therefore, yes β€” Bob can vote. (derived from 2 rules)

Every step is stored, attributed, and replayable β€” that's the point.


Tech stack

  • Backend: Python 3.11+, RDFLib, FastAPI

  • Frontend: SvelteKit, TypeScript, TailwindCSS

  • Reasoning: Neuro-symbolic (LLM + SPARQL / OWL)

  • Protocol: Model Context Protocol (MCP)

  • Packaging & deploy: Docker, GitHub Container Registry, Google Cloud Run


Roadmap

  • Broaden document ingestion (DOCX, HTML, web pages)

  • Richer graph visualization and rule-conflict detection

  • First tagged release (v0.1.0)

Ideas and contributions welcome β€” see CONTRIBUTING.md.


License

MIT β€” see LICENSE.

Available Tools

14 tools
add_memoryA

Store a fact in semantic memory using RDF triple notation.

CRITICAL - ANTI-HALLUCINATION RULES: ❌ NEVER suggest example facts and then add them as if user confirmed ❌ NEVER assume user response validates your examples ❌ NEVER invent names, relationships, dates, or any entities ❌ NEVER add facts based on your assumptions or knowledge βœ“ ONLY add facts that user EXPLICITLY and UNAMBIGUOUSLY stated βœ“ If unsure what user meant, ASK for clarification before adding βœ“ If user says 'I don't know', do NOT add anything

Example of INCORRECT behavior (HALLUCINATION): User: 'Who is Alice's father?' You: 'I don't know. Can you tell me? Example: :Alice :hasFather :Bob' User: 'ok' [or any vague response] You: add_memory(':Alice :hasFather :Bob') ← WRONG! User never said this!

Example of CORRECT behavior: User: 'Alice's father is Bob' You: add_memory(':Alice :hasFather :Bob') ← CORRECT!

What happens when you add a fact:

  1. Fact is stored with confidence=1.0 (explicit user fact)

  2. SPARQL inference rules automatically run in background

  3. New facts may be inferred (e.g., symmetry, transitivity)

  4. Check get_pending_verifications() for inferred facts needing approval

Supported predicates:

  • foaf:knows, foaf:friend - Social relationships

  • schema:worksFor, schema:colleague - Work relationships

  • rdf:type - Classifications

  • :customPredicate - Any custom predicate (user namespace)

Format: ':Subject predicate:name :Object'

Examples: add_memory(':User foaf:knows :Alice') add_memory(':User :isFriendOf :Bob') # Custom predicate add_memory(':Charlie schema:worksFor :AcmeCorp')

Note: Use ':User' for current user, ':' prefix for all user entities.

Inputs: input (required).

approve_ruleA

Approve a pending rule and activate it in the inference engine. The rule will start inferring facts immediately.

SYSTEM: DO NOT CALL THIS AUTOMATICALLY. WAIT FOR USER INPUT. You CANNOT verify/approve your own rules. You must display the rule using suggest_rule, wait for the user to read it, and only call this if they strictly say 'Approved' or 'Yes'.

Inputs: rule_id (required).

forget_memoryA

Remove a fact from semantic memory, including its provenance metadata.

CRITICAL RULES: ❌ NEVER remove facts without explicit user instruction ❌ NEVER remove facts that are foundations for other inferences (check first with query_memory) βœ“ Use when user explicitly says 'forget', 'remove', 'that's wrong', 'delete that' βœ“ Always confirm with user before removing

What happens when you forget a fact:

  1. The triple is removed from the graph

  2. Its provenance reification nodes (source, timestamp, confidence) are also removed

  3. Facts inferred FROM this fact are NOT automatically removed β†’ Use query_memory to check if dependent facts exist before forgetting

Format: ':Subject predicate :Object'

Examples: forget_memory(':User foaf:knows :Alice') forget_memory(':Bob schema:worksFor :AcmeCorp')

Inputs: input (required).

get_graph_statsC

Retrieve statistics about the knowledge graph.

Inputs: no named parameters.

get_pending_rulesA

Get list of rules proposed by the LLM that are awaiting user approval. Use this after suggesting a rule to show the user what needs approval.

Inputs: no named parameters.

get_pending_verificationsA

List all pending verifications (uncertain inferences that need user confirmation). Returns a list of inferred triples with their confidence scores and source rules. Use verify_inference tool to accept or reject them.

Inputs: limit.

list_rulesB

Lists all available SPARQL inference rules, their sources, and their status.

Inputs: source.

load_custom_ruleA

Loads a new custom SPARQL CONSTRUCT rule from text.

The rule should be a SPARQL CONSTRUCT query that infers new triples.

PREFIX declarations are optional - common prefixes (rdf, schema, foaf, etc.) will be auto-added if not present.

Example rule content: CONSTRUCT { ?person rdf:type :Engineer . } WHERE { ?person schema:worksFor :Company . }

Inputs: rule_id (required), rule_content (required), description.

load_documentA

Load a document (PDF, Text, Markdown) into the knowledge graph and automatically extract business rules.

Usage:

  • Load a file: load_document(file_path='/path/to/rules.pdf')

  • Upload content: load_document(content='Rule 1:...', title='My Rules')

What it does:

  1. Parses the document

  2. Stores metadata in the graph

  3. Analyzes content with LLM to extract business rules

  4. Saves extracted rules as 'PENDING' for validation

Options:

  • store_content: Set to True to save full text in graph

Inputs: url, title, prefix, content, +3 more.

query_memoryA

Query the semantic memory graph using SPARQL. Returns ONLY facts that are formally proven (either explicitly added by user or inferred by SPARQL rules).

CRITICAL - Your Role as Assistant:

  • You can make SOFT deductions based on language understanding (e.g., 'knows β†’ probably acquaintances')

  • BUT you MUST distinguish between YOUR deductions and FORMALLY PROVEN facts

  • Use this tool to CHECK if your soft reasoning is formally proven

  • If not proven, use verify_inference() to confirm, then suggest_rule() to formalize

When to use:

  • To verify if a fact exists in the graph

  • To check what the system KNOWS FOR CERTAIN (not what you deduce)

  • To explore relationships and connections

Query Guidelines:

  • ALWAYS scope queries to user namespace with ':' prefix (e.g., ':User', ':Alice')

  • Use LIMIT to avoid overwhelming results (max 1000 auto-injected)

  • Common predicates: foaf:knows, schema:worksFor, schema:colleague, rdf:type

Example workflow 1 (Simple check):

  1. User: 'Is Alice my friend?'

  2. You think: 'Hmm, I see :User foaf:knows :Alice, so maybe friends?'

  3. You call: verify_inference(':User', 'foaf:friend', ':Alice')

  4. Result: 'Not formally proven'

  5. You tell user: 'You know Alice, but friendship is not formally established. Should I create a rule?'

Example workflow 2 (Proactive rule learning):

  1. User asks: 'Can Gilles vote?'

  2. You query: ASK { :Gilles :canVote ?x } β†’ False

  3. You think: 'Voting requires age β‰₯ 18. Do I know Gilles' age? No.'

  4. You query: ASK { :Gilles :hasDrivingLicense ?x } β†’ True

  5. YOU IMMEDIATELY CALL: suggest_rule( rule_id='driving_license_implies_adult', description='Having a driving license implies being an adult (β‰₯18)', sparql_pattern='CONSTRUCT { ?person :isAdult true } WHERE { ?person :hasDrivingLicense ?license }' )

  6. After user approves, you can then infer :Gilles :isAdult true β†’ can vote

Output format:

  • SELECT: Returns table of results as list of dicts

  • ASK: Returns boolean (True/False)

  • CONSTRUCT/DESCRIBE: Returns graph triples

Inputs: query (required), output_format.

reject_ruleA

Reject a pending rule. It will not be activated and will be removed from pending list.

Inputs: rule_id (required).

search_entityA

Search for entities in the knowledge graph by name or label. Returns matching entities with their types and key properties.

Inputs: search_term (required), limit, entity_type.

suggest_ruleA

IMPORTANT: USER APPROVAL REQUIRED / APPROBATION REQUISE Allows the LLM to propose SPARQL rules to formalize reasoning patterns.

CRITICAL WORKFLOW:

  1. EXPLAIN & ASK: You MUST explain the rule and ask for explicit permission FIRST.

    • En FranΓ§ais: "Puis-je ajouter cette rΓ¨gle d'infΓ©rence ?"

    • In English: "May I add this inference rule?"

  2. WAIT: Do NOT call suggest_rule until the user says YES.

  3. SUGGEST: Only after approval, call this tool.

  4. CONFIRM: The user must then approve the pending rule using approve_rule (which you CANNOT call yourself).


WHEN TO USE: βœ“ After verify_inference() returns 'not proven' for logical deduction βœ“ When user explicitly states a rule (e.g., 'friends know each other') βœ“ When detecting recurring patterns in conversation βœ“ To convert YOUR soft reasoning into FORMAL guarantees

WORKFLOW EXAMPLE:

  1. You: 'Voting implies age >= 18. Shall I formalize this?'

  2. User: 'Yes'

  3. YOU CALL: suggest_rule(...)

  4. System: Previews inferences, adds to pending approval

  5. STOP: You wait for user to review.

CRITICAL - DO NOT BYPASS THIS TOOL: ❌ NEVER edit .rq files directly ❌ NEVER create rules outside this workflow βœ“ ALWAYS use suggest_rule() β†’ user approves β†’ system activates

Best Practices:

  • Use descriptive rule_id (snake_case)

  • SPARQL must be CONSTRUCT query

  • Set confidence < 1.0 for uncertain rules

  • Preview shows what WOULD be inferred

Rule goes to PENDING - User must approve!

Inputs: rule_id (required), description (required), sparql_pattern (required), confidence.

verify_inferenceA

Verify if a fact is FORMALLY PROVEN in the knowledge graph. This is THE KEY TOOL for collaborative LLM-Formal reasoning.

WHEN TO USE (CRITICAL): βœ“ BEFORE stating a deduction as fact βœ“ When user asks 'Is X true?' or 'Does Y hold?' βœ“ After making a soft reasoning step βœ“ To distinguish your intuition from formal proof

WORKFLOW:

  1. User asks: 'Is Alice my friend?'

  2. You check: query_memory('ASK { :User foaf:knows :Alice }')

  3. Result: True (they know each other)

  4. Your soft reasoning: 'knows β†’ maybe friends?'

  5. YOU MUST CALL: verify_inference(':User', ':isFriendOf', ':Alice')

  6. Result: 'Not proven'

  7. You respond: 'You know Alice, but friendship isn't formally established.'

  8. If user confirms: Call suggest_rule() to formalize

Returns:

  • If proven: Source (user/rule), confidence, explanation, rule name

  • If not proven: Suggestion to either add explicitly or create rule

Example: verify_inference(subject=':Alice', predicate='foaf:knows', object=':User') β†’ Returns proof chain if fact is formally established

Inputs: action, object, triple, subject, +1 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.7/5.0

    Scored across 14 tools

    Disambiguation3/5

    Most tools are clearly distinct, but load_custom_rule and suggest_rule both add SPARQL rules with different approval paths, creating ambiguity. Additionally, verify_inference's description mentions accepting/rejecting pending verifications, overlapping with get_pending_verifications and approve_rule.

    Naming Consistency3/5

    All names use snake_case, but retrieval verbs are mixed (list, get, search, query) and rule-related tools use inconsistent actions (load, suggest, approve, reject). The naming is readable but not fully predictable.

    Tool Count5/5

    14 tools is within the ideal 3-15 range and each serves a distinct role in the memory and rule management workflows. The count is well-scoped for the server's purpose.

    Completeness4/5

    Core memory operations (add, remove, query, search) and rule lifecycle (suggest, approve, reject, list) are covered. Minor gaps include no explicit update/merge operation for facts and potential confusion around handling rules extracted by load_document.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      A local MCP memory server giving LLMs a persistent, auditable memory fabric with temporal awareness, relationship tracking, and contradiction detection.
      1
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Open-source MCP server that gives any LLM long-term memory using a knowledge graph and vector search hybrid. It stores entities, observations, and relationships, enabling semantic recall across sessions with automatic clustering and fail-loud infrastructure.
      51
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      An MCP server that implements a heavily typed knowledge graph memory system with AI-powered entity and relation extraction, enabling structured knowledge storage and retrieval from unstructured text using predefined or custom ontologies.
      9
      -
    • A
      license
      Not graded
      quality
      D
      maintenance
      A lightweight MCP server that provides long-term memory for LLMs by storing and retrieving important facts, decisions, and preferences through smart semantic search and automatic organization.
      12
      MIT