๐ง Memory Engine MCP
Local-first, graph-aware long-term memory for AI assistants.
SQLite + semantic search + knowledge graph + MCP tools for agents that need continuity.
Works with Claude Desktop ยท Claude Code ยท Cursor ยท Cline ยท Windsurf ยท OpenClaw ยท any MCP client
Why Memory Engine?
Most MCP memory servers are either simple key-value stores or plain text search wrappers.
Memory Engine is different: it models memory as typed atoms connected by typed bonds, then retrieves context with a hybrid ranking pipeline that combines:
- full-text search (SQLite FTS5)
- semantic similarity via local Ollama embeddings
- confidence, recency, and weight
- graph expansion from related memories
The goal is not just storage. The goal is a memory system that can recall, connect, decay, curate, and learn over time.
Highlights
- Local-first โ SQLite database, optional local embeddings via Ollama, no required cloud API.
- MCP-native โ exposes 31 tools through FastMCP.
- Graph-aware recall โ expands top hits through bidirectional bonds for richer context.
- Semantic search โ meaning-based retrieval with
nomic-embed-text.
- Markdown coexistence โ import existing notes one-way without replacing your human-readable memory.
- Error memory โ remembers mistakes and corrections, with auto-promotion to preferences after repeated failures.
- Cognitive curator โ non-destructive maintenance pass for compaction, bond suggestions, duplicate detection, and isolated atom classification.
- Session watcher โ optional OpenClaw JSONL ingestion with short-lived raw messages and permanent session digests.
Architecture
AI assistant / MCP client
โ
โผ
FastMCP server โ 31 tools
โ
โผ
Memory engine โ hybrid ranking, graph recall, decay, learning
โ
โโโ SQLite โ atoms, bonds, FTS5, JSON metadata, versions
โโโ Ollama โ optional local embeddings
โโโ Curator โ conservative maintenance
โโโ Session watcher โ optional OpenClaw session ingestion
Memory
| Tool | Purpose |
|---|
remember | Create or update an atom |
recall | Smart hybrid recall with graph expansion |
working_set | Build a task-oriented context pack |
semantic_search | Pure semantic search |
get_atom | Read one atom with bonds |
list_atoms | Browse atoms by domain/type/status |
merge_atoms | Merge duplicate atoms |
export_atom | Export one atom as markdown |
Knowledge graph
| Tool | Purpose |
|---|
link / unlink | Create or remove typed bonds |
search_graph | Traverse the graph from one atom |
suggest_bonds | Suggest bonds for one atom |
suggest_bonds_all | Suggest or create bonds in bulk |
Learning and maintenance
| Tool | Purpose |
|---|
curator_run | Conservative curation pass |
cognitive_status | Graph and memory health metrics |
learning_run | Detect contradictions, weak atoms, merge candidates, gaps |
ask_pending / answer_human | Human-in-the-loop clarification |
decay_run | Run decay cycle |
cleanup_sessions | Remove expired session atoms |
cleanup_duplicates | Remove duplicate session atoms |
reindex_embeddings | Rebuild embeddings |
Error memory and preferences
| Tool | Purpose |
|---|
error_check | Check past failures before doing a task |
error_log | Record a mistake and the correction |
error_list | Browse unresolved/resolved errors |
preference_search | Search structured preferences |
Import and introspection
| Tool | Purpose |
|---|
import_markdown | Import markdown notes into atoms |
memory_summary | 3-level summary: global โ domain โ detail |
stats | Database statistics |
version | Server version |
recall_session | Search one OpenClaw session |
session_summary | Summarize one OpenClaw session |
Quick start with Docker
git clone https://github.com/SimoneB79/memory-engine-mcp.git
cd memory-engine-mcp
cp docker-compose.yml docker-compose.local.yml
docker compose -f docker-compose.local.yml up -d --build
Default endpoint:
http://localhost:8085/sse
Example MCP client config:
{
"mcpServers": {
"memory-engine": {
"url": "http://localhost:8085/sse",
"transport": "sse"
}
}
}
See docs/INSTALL.md for Docker, local Python, Claude Desktop, Cursor, and OpenClaw examples.
Local Python
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
python server.py
Configuration
Main configuration file: config.json
Important environment variables:
| Variable | Default | Purpose |
|---|
MEMORY_DB_PATH | /data/memory.db | SQLite database path |
MARKDOWN_SOURCE | /workspace/memory | Markdown directory for import |
MEMORY_HOST | 0.0.0.0 | Server bind address |
MEMORY_PORT | 8085 | SSE port |
OPENCLAW_SESSIONS_DIR | /sessions | Optional OpenClaw sessions directory |
SESSION_DIGEST_DIR | /data/session_digests | Optional session digest output |
Semantic search requires Ollama reachable from the container or host. Default:
{
"ollama": {
"enabled": true,
"host": "http://ollama:11434",
"model": "nomic-embed-text"
}
}
If you do not use Ollama, set ollama.enabled to false; FTS recall still works.
Memory model
Atoms have:
title
body
type: fact, decision, event, preference, log, procedure, note, etc.
domain: project or topic namespace
confidence
weight
tags
- optional TTL
Bonds connect atoms with relation types:
is_a ยท part_of ยท depends_on ยท contradicts ยท refines ยท derived_from ยท detail_of ยท related_to
Example usage
remember(
title="Use PostgreSQL for analytics",
body="SQLite is kept for local memory, PostgreSQL is used for multi-user analytics.",
type="decision",
domain="project:analytics",
confidence=0.9,
tags=["database", "architecture"]
)
recall(query="what database did we choose for analytics?", limit=5)
working_set(
query="continue the analytics backend work",
domain="project:analytics",
limit=8,
graph_depth=1
)
Publishing and registries
This repository is prepared for MCP discovery:
- MCP Registry name:
io.github.simoneb79/memory-engine-mcp
- Registry metadata:
server.json
- Docker/OCI verification label: included in
Dockerfile
- Client config example:
mcp.json
See docs/PUBLISHING.md for the publication checklist.
Repository status
License
MIT โ see LICENSE.
Made with ๐ง by SimoneB79