Qmemory
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
π§ Qmemory
Graph memory for AI agents β the agent that remembers everything, connects everything, and never forgets.
What it is: A graph-based context engine that gives AI agents persistent, cross-session intelligence. Every fact is a node. Every relationship is an edge. Nothing is forgotten.
Why it exists: The built-in context engine stores memories as flat files with no cross-session recall. Qmemory plugs into the same context-engine slot and adds graph relationships, salience scoring, temporal validity, and 4-tier hybrid search β so your agent remembers across sessions, topics, and channels.
Three ways to use it:
π OpenClaw context engine β deepest integration, full session lifecycle management
π₯οΈ MCP server for Claude Code β stdio transport, add to
~/.claude.jsonπ MCP server for Claude.ai β HTTP transport, connect via remote MCP
π Table of Contents
Related MCP server: mem0-mcp-selfhosted
π€ The Problem
Every AI agent session is an island. Your agent learns things in one conversation β decisions, preferences, project context β and then forgets everything the moment the session ends.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β THE FILING CABINET WITH LOCKED DRAWERS β
β β
β ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββ β
β β Topic 7 β β Topic 9 β β Cron β β Subagent β β
β β β β β β Job β β Task β β
β β "Budget β β "What β β β β β β
β β approvedβ β was the β β "Check β β "Deploy β β
β β at 500K"β β budget?"β β Railway β β to β β
β β β β π€· ??? β β status" β β prod" β β
β ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββ β
β π π π π β
β β
β Each drawer is LOCKED. Session 9 cannot see what Session 7 knew. β
β The cron job has no idea about the budget. The subagent is blind. β
β β
β ββββββββββββ ββββββββββββ β
β β Topic 12 β β DM β β Even direct messages are isolated β
β β "Railway β β "User β β
β β is on β β prefers β β
β β us-east" β β Arabic" β β
β ββββββββββββ ββββββββββββ β
β π π β
β β
β 6 sessions. 6 locked drawers. Zero shared knowledge. β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββThe result? You repeat yourself. The agent asks the same questions. Decisions made in Topic 7 are invisible in Topic 9. Your cron jobs operate without context. Subagents start from scratch every time.
This is how every AI assistant works by default β including OpenClaw's built-in context engine (which uses flat markdown files with no cross-session recall).
β¨ The Solution
Qmemory turns the filing cabinet into a connected graph. Every fact, every decision, every preference becomes a node β and they're all connected through typed relationships.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β THE CONNECTED GRAPH β QMEMORY IN ACTION β
β β
β ββββββββββββ ββββββββββββββββββββββββ ββββββββββββ β
β β Topic 7 ββββββββββΆβ π§ Qmemory Graph βββββββββ Topic 12 β β
β β "Budget β β β β "Railway β β
β β = 500K" β β ββββββββββββββββ β β us-east" β β
β ββββββββββββ β β memory:m001 β β ββββββββββββ β
β β β "Budget 500K β β β
β ββββββββββββ β β by team lead"β β ββββββββββββ β
β β Topic 9 ββββββββββΆβ ββββββββ¬ββββββββ βββββββββ Cron β β
β β β β βsupports β β Job β β
β β β
Knows β β ββββββββΌββββββββ β ββββββββββββ β
β β budget! β β β memory:m042 β β β
β ββββββββββββ β β "Railway on β β ββββββββββββ β
β β β us-east-1" β βββββββββ Subagent β β
β ββββββββββββ β ββββββββββββββββ β β β β
β β DM ββββββββββΆβ β β β
Knows β β
β β "Prefers β β All nodes linked. β β context! β β
β β Arabic" β β All sessions see. β ββββββββββββ β
β ββββββββββββ ββββββββββββββββββββββββ β
β β
β Topic 9 asks about the budget β Qmemory recalls it from Topic 7 β
β Subagent deploys β Qmemory tells it "Railway is on us-east-1" β
β Cron job runs β it knows the budget, the server, the preferences β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββEvery session sees every memory. Sorted by importance. Filtered by relevance. Connected through relationships the agent itself creates.
ποΈ What the Agent Sees
When Qmemory is active, it automatically injects relevant memories into the agent's system prompt before every response. Here's exactly what gets added:
## Cross-Session Memory (Qmemory)
_5 memories recalled, sorted by importance_
- [decision!] Budget approved at 500K SAR by team lead β final, no renegotiation
β³ Related: email in HEY (hey:inv-2026-003), task in Reminders
- [context!] Railway deployment on us-east-1, SurrealDB port must be 8000
β³ Related: entity "Railway" (deployment), entity "SurrealDB" (system)
- [preference] User prefers Arabic-first (RTL) with Cairo font across all projects
- [context] Acme CRM has 3 active clients: Waqf Fund, SRCA, Tamheer
β³ Scope: project:r-crm
- [decision] Use Hotwire (not React) for all new frontends β DHH philosophy
β³ Expires: 2027-01-01Key details:
The
!marker means salience β₯ 0.8 (critical facts β always recalled first)Memories are sorted by importance, not by date
External references (emails, tasks) are linked, not duplicated
Scope filtering means project-specific memories only appear in the right context
Expired facts are automatically filtered out
The injection respects a token budget (default 15% of context window) β it won't flood your prompt
ποΈ How It Works
Three Entry Points, One Core
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β ENTRY POINTS β
β β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β OpenClaw β β Claude Code β β Claude.ai β β
β β Plugin β β (stdio MCP) β β (HTTP MCP) β β
β β β β β β β β
β β Context β β 4 tools via β β 4 tools via β β
β β engine + β β FastMCP β β FastMCP β β
β β 5 tools + β β β β httpStream β β
β β linker + β β β β β β
β β graph UI β β β β β β
β ββββββββ¬ββββββββ ββββββββ¬ββββββββ ββββββββ¬ββββββββ β
β β β β β
β βΌ βΌ βΌ β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β SHARED CORE (src/core/) β β
β β β β
β β recall search save correct link β β
β β extract dedup embeddings migrate β β
β ββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββ β
β β β
β βΌ β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β SurrealDB 3.0+ β β
β β β β
β β βββββββ βββββββββββ ββββββββββ ββββββββββ β β
β β βsess-β β message β β memory β β entity β β β
β β βion β β β β β β β β β
β β ββββ¬βββ ββββββ¬ββββββ βββββ¬βββββ βββββ¬βββββ β β
β β β β β β β β
β β has_message extracted_from prev_version β β
β β relates (dynamic β ANY type) β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββThe Graph Schema
Qmemory's brain is a graph with 7 table types and 5 edge types:
ββββββββββββ ββββββββββββ
β session βββhas_messageβββΆβ message β
β β β β
β channel β β role β
β chat_typeβ β content β
β scope β β tokens β
ββββββββββββ βββββββ¬βββββ
β
extracted_from
β
ββββββββββββ βββββββΌβββββ
β entity ββββrelatesββββΆ β memory β
β β (dynamic) β β
β name β β content β
β type β β category β
β aliases β β salience βββprev_versionβββΆ (old memory)
β external β β scope β
β _source β β validity β
β _id β β active? β
β _url β β embeddingβ
ββββββββββββ ββββββββββββ
7 tables: session, message, memory, entity, tool_call, scratchpad, metrics
3 structural edges: has_message, extracted_from, prev_version (auto-created)
1 dynamic edge: relates (agent creates ANY relationship type)The relates edge is special β it accepts ANY relationship type as a string: supports, contradicts, manages, blocks, depends_on, caused_by, reports_to, or anything the agent decides fits. This means the graph grows organically based on your actual work, not a rigid predefined ontology.
π Features
Memory & Recall
4-tier hybrid recall β graph traversal β BM25 full-text β vector similarity β recent fallback
Salience scoring (0.0β1.0) β critical facts (
salience β₯ 0.8) are always recalled first7 memory categories β
style,preference,context,decision,idea,feedback,domainTemporal validity β facts can have
valid_fromandvalid_untildates; expired facts auto-filteredMemory scoping β
global,project:xxx, ortopic:xxxβ right memories in the right context
Deduplication & Accuracy
LLM-driven dedup β every new fact is checked against existing memories (ADD / UPDATE / NOOP)
Version chains β corrections create a
prev_versionedge; originals are never deleted (soft-delete only)Contradiction resolution β the reflect service auto-detects conflicting facts and deactivates the outdated one
Graph Intelligence
Dynamic relationships β the agent creates ANY edge type between any two nodes (
supports,contradicts,blocks, etc.)Connection hints in search β top 5 search results show graph edges (type, target name, reason) so the agent sees and follows connections like a mind map
Post-save nudges β after saving a memory, shows 2-3 nearby memories with
qmemory_link()suggestions to build connectionsBackground linker (every 5 min) β finds unlinked memories, asks the LLM to discover relationships, creates edges
Salience decay (every 5 min) β memories older than 7 days get salience *= 0.95 (floor 0.1), so old facts naturally fade unless recalled
Background reflect (every 30 min) β synthesizes insights across memories, resolves contradictions (inspired by Hindsight)
Auto graph structure β channel/topic/session hierarchy built automatically on bootstrap (no agent action needed)
12 lifecycle hooks β captures tool calls, cron outcomes, token usage, subagent relationships, sender identity, delivery routing, session lifecycle
Entity extraction β people, projects, orgs, concepts, and systems become first-class graph nodes
Book Library Ingestion
PDF + EPUB processing β standalone Python script ingests entire book libraries into the memory graph
Smart OCR β PyMuPDF native text first, Gemini Vision OCR fallback for scanned documents (Arabic-optimized)
Arabic-aware chunking β ~900 tokens per chunk, 15% overlap, sentence boundary detection (. Ψ ! \n\n)
Graph integration β books and authors become entity nodes, chunks become domain memories, all connected via
relatesedgesπ Library section in graph map β books shown separately in context injection with connection counts and search nudges
OpenClaw Deep Integration
Pre-compaction memory flush β at 70% context usage, Qmemory extracts memories before compaction fires (fixes OpenClaw #19488)
Post-compaction amnesia fix β high-salience memories are re-injected into the summary after compaction
Subagent memory sharing β when a subagent spawns, it receives relevant memories from the parent session
Token budget control β memory injection capped at 15% of context window (configurable)
External References
Linked entities β emails (HEY), tasks (Apple Reminders), Smartsheet rows, Railway deployments, calendar events
External IDs and URLs β each entity can reference its source system (
hey:12345,smartsheet:row:789)
Visualization & Tools
Graph viewer UI β interactive vis.js visualization at
/qmemory/graph(dark theme, Arabic-friendly)Graph API β JSON endpoint at
/qmemory/api/graphwith filters (category, scope, date range)Migration tool β import existing
MEMORY.mdandmemory/*.mdfiles from OpenClaw workspacesCLI β
qmemory status,qmemory schema,qmemory serve,qmemory serve-http
π Comparison with Other Solutions
Feature | Qmemory | OpenClaw Built-in | Mem0 | LanceDB-pro | Hindsight |
Storage | SurrealDB graph | Flat markdown files | Managed cloud | LanceDB (vector) | Custom graph |
Cross-session recall | β 4-tier hybrid | β Same-session only | β Vector search | β Vector search | β Graph + vector |
Graph relationships | β Dynamic (any type) | β None | β None | β None | β Fixed types |
Deduplication | β LLM-driven | β None | β Rule-based | β None | β LLM-driven |
Salience scoring | β 0.0β1.0 + decay | β No ranking | β No scoring | β No scoring | β Importance |
Temporal validity | β valid_from/until | β No expiry | β No expiry | β No expiry | β Time-aware |
Background linking | β Every 5 min | β None | β None | β None | β Periodic |
Reflection/synthesis | β Every 30 min | β None | β None | β None | β Periodic |
Version history | β prev_version chain | β Overwrite | β Overwrite | β Overwrite | β Versioned |
External references | β Email, tasks, etc. | β None | β None | β None | β None |
Self-hosted | β SurrealDB local | β Local files | β Cloud only | β Local | β Cloud only |
OpenClaw integration | β Context engine plugin | β Built-in | β MCP only | β MCP only | β Not compatible |
MCP support | β stdio + HTTP | β None | β stdio | β stdio | β None |
LongMemEval accuracy | β (pending) | ~40% | ~65% | ~60% | 91.4% (highest) |
Dependencies | 4 ( | 0 (built-in) | Managed service | 1 ( | Managed service |
License | MIT | MIT | Proprietary | Apache 2.0 | Proprietary |
Price | Free | Free | $$$$ | Free | $$$$ |
Why Qmemory over the others?
vs Built-in: Qmemory plugs into the same context-engine slot and adds cross-session recall, graph relationships, salience, and temporal validity β the built-in default stores flat files per session
vs Mem0: Qmemory is self-hosted, graph-based, and integrates as a full context engine β Mem0 is cloud-only vector search
vs LanceDB-pro: Qmemory has typed relationships and dedup β LanceDB is pure vector with no graph intelligence
vs Hindsight: Comparable features, but Qmemory is open-source, self-hosted, and runs as an OpenClaw context-engine plugin β Hindsight is proprietary cloud
π¦ Installation
Prerequisites
Node.js 22+ β
node --versionSurrealDB 3.0+ β Install SurrealDB
Option 1: OpenClaw Plugin (Full Power) π
This is the deepest integration. Qmemory registers as a context-engine plugin and manages the full session lifecycle.
Step 1: Install SurrealDB 3.0+
Important: Qmemory requires SurrealDB v3.0 or later. Older versions (v2.x) have incompatible syntax for schemas, FULLTEXT indexes, and record IDs. Check your version with
surreal version.
# macOS (installs latest v3)
brew install surrealdb/tap/surreal
# Linux (installs latest v3)
curl -sSf https://install.surrealdb.com | sh
# Verify version β must be 3.x
surreal version
# Expected: surreal 3.0.0 or higher
# Start the server (data persists to disk)
surreal start --user root --pass root file:~/.qmemory/data.dbStep 2: Install the plugin
# From npm (recommended)
npm install -g qmemory
# OR directly through OpenClaw
openclaw plugins install qmemory
# Install dependencies (required after openclaw plugins install)
cd ~/.openclaw/extensions/qmemory && npm install --omit=devStep 3: Set Qmemory as your context engine
openclaw config set plugins.slots.contextEngine "qmemory"Step 4: Enable plugin tools
The coding tool profile only includes core tools by default. Choose one:
# Minimal β only Qmemory tools
openclaw config set tools.alsoAllow '["qmemory"]'
# Recommended β all plugin tools (if you have other plugins too)
openclaw config set tools.alsoAllow '["group:plugins"]'Without this step, Qmemory's 6 tools will not appear in the agent's tool list.
"group:plugins"is recommended because it lets the agent use tools from ALL installed plugins β useful when Qmemory works alongside other plugins in group chats and topics.
Step 5: (Optional) Configure the plugin
# Set SurrealDB password (default: root)
openclaw config set plugins.config.qmemory.surrealdb_pass "your-password"
# Enable vector search (uses your existing OpenClaw embedding key)
openclaw config set plugins.config.qmemory.embedding_provider "auto"Step 6: Restart the gateway
openclaw gateway restartStep 7: Verify
openclaw plugins inspect qmemory
# Check the graph is working
qmemory statusYou should see:
Qmemory: connected
SurrealDB: ws://localhost:8000
Namespace: qmemory/main
Memories: 0
Entities: 0
Edges: 0
Sessions: 0Important: SurrealDB must be running before the OpenClaw gateway starts. If SurrealDB is down when the gateway boots, Qmemory runs in degraded mode (no memory operations, but no crash).
Option 2: Claude Code (MCP Server β stdio) π₯οΈ
Add Qmemory as an MCP server in your Claude Code configuration.
Step 1: Install
npm install -g qmemoryStep 2: Start SurrealDB 3.0+
# Install if needed (see Option 1 above for full instructions)
surreal version # Must be 3.x
surreal start --user root --pass root file:~/.qmemory/data.dbStep 3: Apply the schema
qmemory schemaStep 4: Add to Claude Code config
Add this to your ~/.claude.json (or your project's .claude.json):
{
"mcpServers": {
"qmemory": {
"command": "qmemory",
"args": ["serve"],
"env": {
"QMEMORY_SURREALDB_URL": "ws://localhost:8000",
"QMEMORY_SURREALDB_USER": "root",
"QMEMORY_SURREALDB_PASS": "root"
}
}
}
}Step 5: Restart Claude Code
Claude Code will now have 4 tools: qmemory_search, qmemory_save, qmemory_correct, qmemory_link.
Note: In Claude Code mode, you get 4 tools (no
qmemory_import). Auto-injection of memories into the system prompt requires the OpenClaw plugin mode.
Option 3: Claude.ai (MCP Server β HTTP) π
Run Qmemory as an HTTP MCP server and connect it to Claude.ai's remote MCP feature.
Step 1: Install and start
npm install -g qmemory
surreal start --user root --pass root file:~/.qmemory/data.db
qmemory schemaStep 2: Start the HTTP server
# Default port: 3777
qmemory serve-http
# Custom port
qmemory serve-http 4000You should see:
Qmemory MCP server running on http://localhost:3777/mcpStep 3: Connect from Claude.ai
In Claude.ai settings, add a remote MCP server pointing to http://localhost:3777/mcp (or your public URL if deployed).
Tip: For production, deploy Qmemory behind a reverse proxy with HTTPS. The MCP endpoint is at
/mcp.
βοΈ Configuration
OpenClaw Plugin Config
All options are set via openclaw config set plugins.config.qmemory.<key> <value>:
Option | Type | Default | Description |
| string |
| SurrealDB connection URL |
| string |
| SurrealDB username |
| string |
| SurrealDB password |
| string |
| SurrealDB namespace |
| string |
| SurrealDB database name |
| number |
| Trigger compaction at this % of context window (0β1) |
| integer |
| Number of recent messages protected from compaction |
| number |
| Max % of context window for memory injection (0β1) |
| string |
| Embedding provider: |
| string | β | Override API key for embeddings (leave empty to use OpenClaw's) |
| string | β | Override embedding model (leave empty to use OpenClaw's) |
| integer |
| Embedding vector dimension |
| integer |
| Background linker interval (default: 5 min) |
| integer |
| Background reflection interval (default: 30 min) |
| number |
| Minimum salience to include in recall results |
| string |
| Model for background LLM tasks (dedup, extract, link). Use cheap models like |
| string |
| Adaptive extraction preset: |
| boolean |
| Enable debug logging |
Environment Variables (CLI / MCP mode)
When running as a standalone MCP server, configure via environment variables:
Variable | Default | Description |
|
| SurrealDB connection URL |
|
| SurrealDB username |
|
| SurrealDB password |
|
| SurrealDB namespace |
|
| SurrealDB database name |
|
|
|
| β | API key for embedding provider |
|
| Enable debug logging |
π§ Tools Reference
Qmemory exposes 6 tools in OpenClaw mode and 4 tools in MCP mode.
qmemory_search
Search cross-session memory AND tool call history. Top 5 results are enriched with graph connection hints β the agent sees linked books, people, and other memories, encouraging exploration through the knowledge graph.
Parameter | Type | Required | Description |
| string | No | Search by meaning (BM25 full-text + vector similarity) |
| string[] | No | Filter: |
| string | No | Filter: |
| number | No | Max results, 1β50 (default: 10) |
| boolean | No | Also search the |
| string | No | Filter tool calls by name (e.g., |
Examples:
qmemory_search({ query: "Railway deployment", categories: ["context", "decision"], limit: 5 })
qmemory_search({ include_tool_calls: true, tool_name: "exec" })
qmemory_search({ query: "Railway", include_tool_calls: true })Returns:
[mem001] [context, salience:0.9] Railway deployment on us-east-1, SurrealDB port must be 8000
[mem042] [decision, salience:0.8] Use Railway free tier for staging, upgrade for productionqmemory_save
Save a fact to cross-session memory. Runs dedup automatically.
Parameter | Type | Required | Description |
| string | Yes | The fact to remember (one clear statement) |
| string | Yes |
|
| number | No | Importance 0.0β1.0 (default: 0.5). Use 0.8+ for critical facts |
| string | No |
|
Example:
qmemory_save({
content: "Budget approved at 500K SAR by team lead β final decision",
category: "decision",
salience: 0.9,
scope: "project:acme"
})Returns: ADD: memory:mem1710864000abc [decision, salience:0.9]
If a similar memory already exists, the system may return UPDATE (merged) or NOOP (already known).
qmemory_correct
Fix, update, delete, or unlink memories. 4 actions available.
Parameter | Type | Required | Description |
| string | Yes | The memory ID (e.g., |
| string | Yes |
|
| string | Only for | The corrected content |
| number | Only for | New importance score (0.0β1.0) |
| string | Only for | New scope ( |
| string | Only for | Expiry date (ISO 8601) |
| string | Only for | The |
Examples:
// Fix wrong content (creates version chain)
qmemory_correct({ memory_id: "memory:mem001", action: "correct", new_content: "Actually 600K not 500K" })
// Update metadata (in-place, no new version)
qmemory_correct({ memory_id: "memory:mem001", action: "update", salience: 1.0 })
// Soft-delete
qmemory_correct({ memory_id: "memory:mem001", action: "delete" })
// Remove a relationship edge
qmemory_correct({ memory_id: "memory:mem001", action: "unlink", edge_id: "relates:r789" })Returns: Corrected: memory:mem001 β memory:mem002 (for correct action)
See Agent Memory Management for detailed explanation of all 4 actions.
qmemory_link
Create a relationship between any two nodes in the graph.
Parameter | Type | Required | Description |
| string | Yes | Source node ID (e.g., |
| string | Yes | Target node ID |
| string | Yes | Any relationship: |
| string | No | Why this relationship exists |
Example:
qmemory_link({
from_id: "memory:mem001",
to_id: "entity:ent_railway",
type: "deployed_on",
reason: "The application is hosted on Railway us-east-1"
})Returns: Linked: memory:mem001 β[deployed_on]β entity:ent_railway (relates:r789)
qmemory_import (OpenClaw only)
Import a markdown file into the memory graph.
Parameter | Type | Required | Description |
| string | Yes | Absolute path to the markdown file |
Example:
qmemory_import({ file_path: "~/.openclaw/workspace/memory/2026-03-14.md" })Returns: Imported: 12 facts extracted, 9 new memories created
π₯οΈ Graph Viewer UI
Qmemory includes an interactive graph visualization that shows your entire memory network β every fact, entity, and relationship as a live, explorable graph.
Access it at: http://localhost:<gateway-port>/qmemory/graph
For the default OpenClaw setup: http://127.0.0.1:18789/qmemory/graph
The viewer shows:
Memory nodes β facts with salience coloring (brighter = more important)
Entity nodes β people, projects, systems
Relationship edges β typed connections (supports, manages, blocks, etc.)
Filters β filter by category, scope, or date range
API endpoint: GET /qmemory/api/graph returns JSON { nodes, edges } with optional query params:
?category=contextβ filter by memory category?scope=globalβ filter by scope?from=2026-01-01&to=2026-03-18β filter by date range
No authentication needed on localhost. The graph viewer is read-only.
π§Ή Agent Memory Management
Qmemory gives the agent (and you) full control over its memory β not just saving and searching, but editing, updating, expiring, deleting, and unlinking memories. The qmemory_correct tool supports 4 distinct actions:
1. Correct β Fix wrong content (version chain)
When a fact is wrong, correct creates a new version while preserving the old one via a prev_version edge. Nothing is ever truly lost.
qmemory_correct({
memory_id: "memory:mem001",
action: "correct",
new_content: "Budget approved at 600K SAR (revised up from 500K)"
})Result: Old memory soft-deleted β new memory created β prev_version edge links them.
2. Update β Change metadata (no new version)
Update salience, scope, or expiry without creating a new version. Use this when the fact is right, but its importance or context changed.
// Make something critical
qmemory_correct({ memory_id: "memory:mem001", action: "update", salience: 1.0 })
// Set an expiry date
qmemory_correct({ memory_id: "memory:mem001", action: "update", valid_until: "2026-06-01T00:00:00Z" })
// Change scope from topic-specific to global
qmemory_correct({ memory_id: "memory:mem001", action: "update", scope: "global" })3. Delete β Soft-delete a memory
Marks the memory as is_active = false. It stays in the graph (for audit) but no longer appears in recall results.
qmemory_correct({ memory_id: "memory:mem001", action: "delete" })4. Unlink β Remove a relationship
Remove a relates edge between two nodes. The nodes themselves remain β only the connection is severed.
qmemory_correct({ memory_id: "memory:mem001", action: "unlink", edge_id: "relates:r789" })Summary Table
Action | What Changes | Creates New Version? | Old Data Preserved? |
| Content | Yes (new node + | Yes (soft-deleted, linked) |
| Salience, scope, expiry | No (in-place edit) | No (overwritten) |
|
| No | Yes (still in graph) |
| Removes edge | No | No (edge deleted) |
π€ For AI Agents β SKILL.md
Qmemory ships with a SKILL.md file β a comprehensive guide that teaches AI agents when and how to use Qmemory effectively. It covers:
When to save β decision guide ("Would this be useful in a FUTURE conversation?")
Salience scoring β what 0.3 vs 0.5 vs 0.8 vs 1.0 means with real examples
Category selection β which of the 7 categories fits each type of information
When to link β signals that indicate a relationship should be created
When to correct β user feedback signals ("That's wrong", "That's not important anymore", "Forget that")
Freeform relationship types β the agent can use any string as a relationship type
Background processes β what happens automatically so the agent doesn't need to do it
How to Use SKILL.md
Add a reference to SKILL.md in your agent's system prompt, SOUL.md, or configuration:
For OpenClaw β add to your agent's SOUL.md:
## Memory
This agent uses Qmemory for cross-session graph memory.
See SKILL.md in the Qmemory plugin for the full memory management guide.For Claude Code β add to your project's .claude/CLAUDE.md:
## Memory
This project uses Qmemory (MCP server) for persistent memory.
When the user shares important facts, decisions, or preferences, save them with qmemory_save.
When you need past context, search with qmemory_search.
See the Qmemory SKILL.md for detailed usage guidelines.The SKILL.md teaches the agent to be a responsible memory manager β saving important things, skipping trivial exchanges, and using the right category and salience for each fact.
πΈοΈ Graph Schema
The full SurrealDB schema lives in schema/qmemory.surql. Here's the visual overview:
ββββββββββββββββββββββββββββ NODES ββββββββββββββββββββββββββββ
β β
β SESSION MESSAGE MEMORY β
β ββββββββββββββββ ββββββββββββββββ βββββββββββββ β
β β session_key β β role β β content β β
β β channel β β content β β category β β
β β chat_type β β tool_calls β β salience β β
β β topic_id β β tool_name β β valid_fromβ β
β β group_id β β token_count β β valid_untilβ β
β β scope β β created_at β β scope β β
β β last_active β ββββββββββββββββ β is_active β β
β ββββββββββββββββ β confidenceβ β
β β source_typeβ β
β ENTITY β embedding β β
β ββββββββββββββββ βββββββββββββ β
β β name β β
β β type β Types: person, project, org, concept, β
β β aliases[] β system, email, task, event, document, β
β β external_id β smartsheet, deployment β
β β external_url β β
β β external_src β β
β β embedding β β
β ββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
ββββββββββββββββββββββββββββ EDGES ββββββββββββββββββββββββββββ
β β
β STRUCTURAL (auto-created by the system): β
β β
β session ββ[has_message]βββΆ message β
β memory ββ[extracted_from]βββΆ message β
β memory ββ[prev_version]βββΆ memory (version chain) β
β β
β DYNAMIC (created by agent, linker, reflect, or compact): β
β β
β (any) ββ[relates]βββΆ (any) β
β β
β relates.type: ANY string β
β "supports", "contradicts", "elaborates", β
β "depends_on", "caused_by", "blocks", β
β "manages", "reports_to", "deployed_on", β
β "synthesized_from", "follows", ... β
β β
β relates.confidence: 0.0β1.0 β
β relates.created_by: "agent"|"linker"|"compact"|"reflect"β
β relates.reason: optional explanation β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββIndexes
BM25 full-text search on
memory.content(primary search method)Standard indexes on
is_active,category,salience,scopeVector index (HNSW, optional) on
memory.embeddingwhen embeddings are enabledUnique index on
session.session_keyComposite index on
entity.external_source + external_id
π Migration (Import Old Memories)
Already have memory files from OpenClaw? Qmemory can import them.
Import an entire workspace
# Via the agent (OpenClaw mode β uses LLM for smart extraction)
> Import all my memory files into Qmemory
# The agent will call qmemory_import for each fileImport a single file
qmemory_import({ file_path: "/path/to/MEMORY.md" })How migration works
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β MIGRATION PIPELINE β
β β
β ~/.openclaw/workspace/ β
β βββ MEMORY.md β Long-term curated β
β βββ memory/ β
β βββ 2026-03-01.md β Daily snapshot β
β βββ 2026-03-02.md β
β βββ 2026-03-14.md β
β β
β β β
β βΌ β
β βββββββββββββββββββββββ β
β β Smart Extract β (with LLM) β
β β OR Simple Extract β (without LLM β fallback) β
β βββββββββββ¬ββββββββββββ β
β β β
β βΌ β
β βββββββββββββββββββββββ β
β β Dedup Pipeline β ADD / UPDATE / NOOP β
β βββββββββββ¬ββββββββββββ β
β β β
β βΌ β
β βββββββββββββββββββββββ β
β β Graph Nodes β + chronological edges β
β β (memory, entity) β (file A β file B) β
β βββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββTwo modes:
Smart import (with LLM): Extracts structured facts, categories, salience scores, and entities using a subagent
Simple import (without LLM): Each non-empty line becomes a memory with heuristic categorization
Files are processed oldest β newest, with follows edges linking them chronologically.
β‘ How Memory Updates
Qmemory has 6 trigger points where memories are created or updated:
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β 6 MEMORY UPDATE TRIGGERS β
β β
β β afterTurn β
β After every agent response, extract facts from the last β
β few messages. Runs in the background (non-blocking). β
β β
β β‘ Pre-compaction flush (70% context) β
β When context hits 70%, urgently extract memories β
β from older messages BEFORE compaction drops them. β
β Fixes OpenClaw #19488. β
β β
β β’ compact() β
β When context exceeds threshold (default 75%), extract β
β memories from old messages and drop them from context. β
β High-salience facts are re-injected (prevents amnesia). β
β β
β β£ qmemory_save (agent tool) β
β The agent explicitly saves a fact (e.g., user says β
β "remember this"). Goes through full dedup pipeline. β
β β
β β€ Background Linker (every 5 min) β
β Finds unlinked memories, asks LLM for relationships, β
β creates `relates` edges. Makes the graph smarter over time. β
β β
β β₯ Background Reflect (every 30 min) β
β Reviews recent memories, synthesizes insights, β
β resolves contradictions. Creates new "insight" memories β
β and deactivates outdated facts. β
β β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββπ External References
Entities in Qmemory can reference external systems. This means your agent can connect memories to real-world objects without duplicating data.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β EXTERNAL REFERENCES β
β β
β βββββββββββββββββββ βββββββββββββββββββ β
β β entity:ent001 β β memory:mem042 β β
β β β β "Invoice sent β β
β β name: "Invoice" ββββββββ to team lead" β β
β β type: "email" β βββββββββββββββββββ β
β β external_source:β β
β β "hey" β β Source system (HEY email) β
β β external_id: β β
β β "hey:inv-003" β β ID in source system β
β β external_url: β β
β β "https://app. β β Direct link to the email β
β β hey.com/..." β β
β βββββββββββββββββββ β
β β
β Supported sources: β
β ββββββββββββββββββββββββββββββββββββββββββββ β
β β hey β HEY email β β
β β apple-reminders β Apple Reminders tasks β β
β β smartsheet β Smartsheet rows β β
β β railway β Railway deployments β β
β β calendar β Calendar events β β
β ββββββββββββββββββββββββββββββββββββββββββββ β
β β
β The agent doesn't copy email content into memory. β
β It creates a LINK: "This decision relates to that email." β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββπ Community Issues Solved
Qmemory was built to fix real problems reported in the OpenClaw community:
Issue | Problem | How Qmemory Fixes It |
Pre-compaction flush never fires β memories lost during compaction | Pre-compaction flush at 70% context extracts facts before they're dropped | |
Post-compaction amnesia β agent forgets critical context after compaction | High-salience memories (β₯0.8) are re-injected into the summary | |
No cross-session memory β each topic is isolated | Full graph-based recall across all sessions, topics, and channels | |
Memory duplicates pile up β same fact stored 20 times | LLM-driven dedup pipeline: ADD / UPDATE / NOOP on every save | |
No way to correct wrong memories |
| |
Subagents have no context from parent |
|
π Troubleshooting
Agent can't see Qmemory tools
Symptom: Plugin loads (logs show "Qmemory plugin loaded") but agent lists only core tools (read, write, exec, etc.) β no qmemory_* tools.
Cause: OpenClaw's tools.profile: "coding" has a hardcoded allowlist of core tools. Plugin tools are filtered out unless explicitly allowed.
Fix:
openclaw config set tools.alsoAllow '["group:plugins"]'
openclaw gateway restartThis adds ALL plugin tools (not just Qmemory) to the agent's available tools. You only need to do this once.
SurrealDB not running
Symptom: Plugin loads but no memories are saved or recalled. Logs show "Cannot connect to SurrealDB" or agent runs in "degraded mode."
Fix:
# Start SurrealDB
surreal start --user root --pass root file:~/.qmemory/data.db
# Verify
qmemory status
# (Optional) Auto-start on macOS login
bash scripts/setup-surrealdb-launchagent.shSurrealDB must be running before the OpenClaw gateway starts. If you start SurrealDB after, restart the gateway:
openclaw gateway restart
Context engine not active
Symptom: Tools work but memories are not auto-injected into conversations. No compaction. No cross-session recall.
Cause: The context engine slot is not set to Qmemory.
Fix:
openclaw config set plugins.slots.contextEngine "qmemory"
openclaw gateway restartWrong SurrealDB version
Symptom: Schema fails to apply, FULLTEXT index errors, Cannot execute CREATE statement errors, or type::record parse errors.
Cause: SurrealDB v2.x has incompatible syntax. Qmemory requires v3.0+.
Fix:
# Check version
surreal version
# If 2.x, upgrade:
# macOS
brew upgrade surrealdb/tap/surreal
# Linux
curl -sSf https://install.surrealdb.com | sh
# Verify
surreal version
# Must show: 3.0.0 or higherSchema not applied
Symptom: SurrealDB is running but queries fail with "table not found" errors.
Fix: The schema is auto-applied on the first session (bootstrap()). If you need to apply it manually:
qmemory schema
# or
npx tsx src/cli.ts schemaPlugin not loaded
Symptom: No "Qmemory plugin loaded" message in logs.
Fix:
# Check plugin status
openclaw plugins list | grep qmemory
# Ensure it's enabled
openclaw config set plugins.entries.qmemory.enabled true
# Ensure it's in the allowlist
openclaw config set plugins.allow '["qmemory"]'
# Restart
openclaw gateway restartTools registered but returning errors
Symptom: Agent sees qmemory_* tools but they fail with connection errors.
Fix: Check that SurrealDB is running and accessible:
qmemory status
# Should show: Qmemory: connectedIf it shows "disconnected", restart SurrealDB and the gateway.
Quick diagnostic checklist
# 1. Is SurrealDB running?
qmemory status
# 2. Is the plugin loaded?
openclaw plugins list | grep qmemory
# 3. Is the context engine set?
openclaw config get plugins.slots.contextEngine
# Should show: "qmemory"
# 4. Are plugin tools allowed?
openclaw config get tools.alsoAllow
# Should include: "group:plugins"
# 5. Check logs for errors
openclaw logs --follow | grep -i "qmemory\|surreal\|error"π οΈ Development
Setup
git clone https://github.com/QusaiiSaleem/qmemory.git
cd qmemory
npm install
npm run buildLocal development
# Start SurrealDB
surreal start --user root --pass root file:~/.qmemory/data.db
# Apply schema
npx tsx src/cli.ts schema
# Check status
npx tsx src/cli.ts status
# Run MCP server (stdio β for testing with Claude Code)
npx tsx src/cli.ts serve
# Run MCP server (HTTP β for testing with Claude.ai)
npx tsx src/cli.ts serve-http 3777
# Interactive MCP inspector (great for debugging tools)
npm run dev
# Link as OpenClaw plugin (dev mode β no npm publish needed)
openclaw plugins install -l /path/to/qmemory
openclaw config set plugins.slots.contextEngine "qmemory"
openclaw config set tools.alsoAllow '["group:plugins"]'
openclaw gateway restartTesting
npm test # Run tests once
npm run test:watch # Watch modeDebugging
# OpenClaw logs (filter for Qmemory)
openclaw logs --follow | grep qmemory
# Direct SurrealDB queries
surreal sql -e http://localhost:8000 -u root -p root \
--namespace qmemory --database mainProject structure
src/
βββ core/ β SHARED logic (used by all entry points)
β βββ recall.ts β 4-tier hybrid recall pipeline
β βββ search.ts β BM25 + vector + graph search
β βββ save.ts β Save with dedup pipeline
β βββ correct.ts β Fix or soft-delete memories
β βββ link.ts β Create dynamic `relates` edges
β βββ extract.ts β LLM-driven fact extraction
β βββ dedup.ts β LLM-driven dedup (ADD/UPDATE/NOOP)
β βββ embeddings.ts β Embedding generation + config resolution
β βββ migrate.ts β Import old memory files
βββ db/
β βββ client.ts β SurrealDB connection + parameterized queries
β βββ queries.ts β Reusable query helpers
βββ openclaw/ β ENTRY 1: Context engine plugin
β βββ index.ts β Plugin registration (6 tools + engine + linker)
β βββ engine.ts β Full context engine (bootstrap/ingest/assemble/compact)
β βββ linker.ts β Background services (link + reflect)
βββ mcp/
β βββ server.ts β ENTRY 2: FastMCP server (4 tools, stdio + HTTP)
βββ cli.ts β ENTRY 3: CLI (serve, serve-http, status, schema)
βββ config.ts β Types, constants, formatMemories()
βββ ui/
βββ graph-handler.ts β HTTP handler for graph viewer + API
βββ graph.html β vis.js interactive graph (dark theme)Dependencies
Only 4 runtime dependencies β keeping it simple:
Package | Why |
| Official SurrealDB JavaScript SDK |
| MCP server framework (stdio + HTTP transports) |
| OpenClaw tool parameter schemas |
| MCP tool parameter schemas |
βοΈ Relationship Chains β The Power Feature
The relates edge connects ANY node to ANY node. The agent builds chains that map real-world workflows:
User says: "Ahmed needs the Q2 report by Thursday. Send it to his work email."
Agent builds this chain:
Session (Topic 9)
β has_message
βΌ
Message: "Ahmed needs the Q2 report by Thursday"
β extracted_from
βΌ
Memory: "Ahmed needs Q2 report by Thursday" (salience: 0.8)
β relates (assigned_to)
βΌ
Entity: "Ahmed" (type: person)
β has_identity
ββββΆ Contact: WhatsApp 966501234567
ββββΆ Contact: gmail ahmed@company.com β send here
ββββΆ Contact: Smartsheet user:12345More Real-World Chains
Decision Chain:
memory:"Budget approved" β approved_by β entity:manager
β communicated_via β entity:approval_email
β depends_on β memory:"Board meeting March 5"
Incident Chain:
memory:"Prod down 2 hours" β caused_by β memory:"Friday deploy broke auth"
β affected β entity:railway_prod
β resolved_by β entity:on_call_engineer
Task Chain:
entity:hire_developer β depends_on β memory:"Budget approved"
β blocks β memory:"Need 2 devs for Q3"
β assigned_to β entity:hr_managerPeople with Multiple Identities
qmemory_person({
name: "Ahmed",
aliases: ["Ψ£ΨΩ
Ψ―"],
contacts: [
{ source: "whatsapp", id: "966501234567" },
{ source: "gmail", id: "ahmed@company.com" },
{ source: "telegram", id: "ahmed_k" },
{ source: "smartsheet", id: "user:12345" }
]
})Later: qmemory_person({ name: "Ahmed", action: "find" }) returns the person + ALL contacts + ALL linked memories from any session.
Common Relationship Types
Type | Use For |
| Task β Person |
| Decision β Person |
| Incident β Root cause |
| Task β Prerequisite |
| Blocker β Blocked item |
| Person β Contact (auto) |
| Fact β Communication channel |
| Project β Manager |
| Session β System |
| Problem β Tool/Skill |
These are NOT fixed β use any word that describes the relationship.
π Wiki / Reference Files
File | What It Is | When to Read |
Agent guide β teaches AI agents when/how to save, search, link, correct, and manage memory | Setting up a new agent, customizing memory behavior | |
Developer reference β architecture, key patterns, gotchas, quick commands | Contributing to Qmemory, debugging, understanding the codebase | |
Full SurrealDB schema β 7 tables, 5 edge types, indexes, analyzers | Understanding the data model, writing custom queries | |
Plugin manifest β all config options with types, defaults, and UI hints | Configuring the OpenClaw plugin, understanding available settings | |
npm package β scripts, dependencies, entry points | Installing, building, understanding the project structure |
π License
MIT β use it however you want.
π Credits
Created by Qusai Abu Shanab.
Powered by SurrealDB β the multi-model database that makes graph + document + vector queries feel natural.
Built for the OpenClaw community β the open-source AI agent platform.
MCP integration via FastMCP β the simplest way to build MCP servers.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogβ¦
This server cannot be deployed
Maintenance
Related MCP Connectors
Persistent memory, hybrid search and a goal graph for AI agents, over stdio or remote HTTP.
Persistent memory for AI agents. Semantic search, memory graph, W3C DID identity.
Persistent memory and knowledge graphs for AI agents. Hybrid search, context checkpoints, and more.
Persistent memory for AI agents across Claude, ChatGPT and any MCP client.
Related MCP Servers
- FlicenseNot gradedqualityAmaintenanceEnables Claude Code to store and recall persistent cross-session memory backed by self-hosted Qdrant, Neo4j, and Ollama, using Anthropic or fully local Ollama as the LLM. Exposes tools for adding, searching, listing, updating, and deleting memories plus querying knowledge-graph entities and relationships, with optional session hooks for automatic context injection and saving.-
- FlicenseNot gradedqualityAmaintenanceEnables Claude Code to persist, search, update, delete, and graph-link memories across sessions using self-hosted Qdrant, Neo4j, and Ollama, with Claude or Ollama as the main LLM.-
- FlicenseNot gradedqualityAmaintenanceEnables Claude Code to store and recall persistent cross-session memories using a self-hosted stack of Qdrant, Neo4j, and Ollama, backed by Anthropic or a local LLM. Exposes 11 tools for adding, searching, updating, and deleting memories plus knowledge-graph entities, with optional session hooks that auto-inject context on startup and save summaries on exit.-
- FlicenseNot gradedqualityAmaintenanceEnables Claude Code to add, search, update, delete, and organize persistent memories across sessions using self-hosted Qdrant, Neo4j, and Ollama, with optional Anthropic or local LLM support. It also exposes tools for knowledge-graph entity relationship search and retrieval.-