SmartMemory
Allows using Google's LLM models (e.g., Gemini) for extracting facts and rules from natural language and documents.
Allows using locally-hosted LLM models (e.g., Llama) via Ollama for extracting facts and rules.
Allows using OpenAI's LLM models (e.g., GPT-4) for extracting facts and rules from natural language and documents.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@SmartMemory Remember that the meeting is at 3pm on Fridays"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
π§ SmartMemory
Give your LLM structured, verifiable memory β turn conversations into knowledge graphs your AI can reason over.
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 |
Quick start
I want to⦠| Go to |
Get running in 5 minutes | |
Try the advanced demo | |
Understand the internals | |
Configure a provider | |
Fix a problem | |
Browse all docs |
Mode 1 β Conversational Setup (MCP)
Gives your LLM long-term memory and logical deduction.
Option A β Docker (recommended) π³
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 dashboardAdd
dashboardto start the web server; without it the container starts in MCP mode. The-vvolume persists your knowledge graph and rules. Open the dashboard athttp://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 |
| European, La Plateforme API |
Ollama (local, free) |
| Runs offline |
OpenAI |
| |
Anthropic |
| |
|
Extracting rules from documents
Upload a PDF (e.g.
Company_Policy.pdf).Pick a provider β the server needs an API key (or a local Ollama) to read the document.
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 toolsadd_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:
Fact is stored with confidence=1.0 (explicit user fact)
SPARQL inference rules automatically run in background
New facts may be inferred (e.g., symmetry, transitivity)
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:
The triple is removed from the graph
Its provenance reification nodes (source, timestamp, confidence) are also removed
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:
Parses the document
Stores metadata in the graph
Analyzes content with LLM to extract business rules
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):
User: 'Is Alice my friend?'
You think: 'Hmm, I see :User foaf:knows :Alice, so maybe friends?'
You call: verify_inference(':User', 'foaf:friend', ':Alice')
Result: 'Not formally proven'
You tell user: 'You know Alice, but friendship is not formally established. Should I create a rule?'
Example workflow 2 (Proactive rule learning):
User asks: 'Can Gilles vote?'
You query: ASK { :Gilles :canVote ?x } β False
You think: 'Voting requires age β₯ 18. Do I know Gilles' age? No.'
You query: ASK { :Gilles :hasDrivingLicense ?x } β True
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 }' )
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:
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?"
WAIT: Do NOT call
suggest_ruleuntil the user says YES.SUGGEST: Only after approval, call this tool.
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:
You: 'Voting implies age >= 18. Shall I formalize this?'
User: 'Yes'
YOU CALL: suggest_rule(...)
System: Previews inferences, adds to pending approval
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:
User asks: 'Is Alice my friend?'
You check: query_memory('ASK { :User foaf:knows :Alice }')
Result: True (they know each other)
Your soft reasoning: 'knows β maybe friends?'
YOU MUST CALL: verify_inference(':User', ':isFriendOf', ':Alice')
Result: 'Not proven'
You respond: 'You know Alice, but friendship isn't formally established.'
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
Scored across 14 tools
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.
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.
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.
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
AI memory governance & hallucination-blocking MCP server with verifiable knowledge cells.
An MCP memory server. One memory your agents share β across models, devices and apps.
Cloud-hosted MCP server for durable AI memory
Persistent memory, knowledge graph, task management and more for AI agents via MCP.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceA local MCP memory server giving LLMs a persistent, auditable memory fabric with temporal awareness, relationship tracking, and contradiction detection.1MIT
- AlicenseNot gradedqualityDmaintenanceOpen-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.51MIT
- FlicenseNot gradedqualityDmaintenanceAn 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-
- AlicenseNot gradedqualityDmaintenanceA 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.12MIT