๐ง Memoria
July 21, 2026 ยท View on GitHub
Independent memory center for AI agents. Built in Rust. MCP-native. Zero external dependencies.
AI agents shouldn't forget you every time they restart. Memoria is a standalone memory service โ conversations, decisions, preferences โ unified across all your AI tools.
Not bound to any software. Serving only you.
Why Memoria?
Every AI product has its own memory silo. Switch from Claude to DeepSeek? Your context is gone. Switch from ChatGPT to a local model? Start from scratch.
Memoria fixes this by being the memory layer, not a feature of any particular AI client. Any MCP-compatible agent can plug in and share the same memory.
Agent (Claude Desktop / Jan / OpenClaw / ...)
โ
โผ MCP Protocol (JSON-RPC over HTTP)
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Memoria (:9003) โ
โ โโโโโโโโโโโ โโโโโโโโ โโโโโโโโโโโโ โ
โ โ SQLite โ โ FTS5 โ โ HNSW โ โ
โ โ(structured)โ(full-text)โ(vector)โ โ
โ โโโโโโโโโโโ โโโโโโโโ โโโโโโโโโโโโ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ 5-Signal Hybrid Search (RRF) โโ
โ โ Keyword+Semantic+Temporal โโ
โ โ +Importance+Category โโ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ Auth + Audit + Namespace โโ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Features
๐ 5-Signal Hybrid Search
- Keyword โ FTS5 full-text (jieba-rs Chinese tokenization)
- Semantic โ HNSW vector search (hnsw_rs)
- Temporal โ Time decay weighting
- Importance โ Memory priority scoring (1-5)
- Category โ Intent classification filter
- RRF Fusion โ Reciprocal Rank Fusion across all 5 signals
๐ง Semantic Search (optional)
- The Semantic signal (HNSW vector search) is off by default. When
MEMORIA_EMBEDDING_URLis empty, Memoria silently degrades to keyword-only fusion (FTS5 + temporal + importance + category) โ see runtime/health(embedโwarn: ่ฏญไนๆฃ็ดข้็บงไธบ FTS/ๆถ้ดไฟกๅท). - Capability gap: with embeddings off you lose semantic / paraphrase recall โ queries that don't share keywords with stored memories may return nothing. With embeddings on, Memoria gains true semantic recall across rephrasings and synonyms. (For a concrete example, try querying a stored memory with different wording before vs after enabling embeddings.)
- Wiring: start the bundled embed server and point Memoria at it:
The embed server (sentence_transformers, offline CPU, modelpython embed_server.py # listens 127.0.0.1:8777/embed # then set in .env: MEMORIA_EMBEDDING_URL=http://127.0.0.1:8777/embedshibing624/text2vec-base-chinese) is documented inembed_server.py. It is loopback-only and optional; Memoria runs fully without it.
๐ Identity & Audit
- Namespace isolation โ Multi-tenant data separation
- Badge token auth โ SHA-256 token-based authentication
- Weekly partitioned audit logs โ Auto-rotating, 90-day retention
- Independent audit DB โ No lock contention with main DB
๐ค A2A Agent Communication
- Agent-to-Agent message routing
- Approval workflows & task coordination
- Cross-agent knowledge sharing
๐ Web Dashboard
- Search, timeline browse, graph visualization
- CRUD API: create, read, update, delete, import, export, backup
Performance
| Metric | Python (original) | Rust | Improvement |
|---|---|---|---|
| Avg search latency | 410ms | 112ms | 3.7x |
| P50 search latency | 182ms | 99ms | 1.8x |
| Zero-result rate | 32.2% | 0% | โ |
Measured on x86_64 Linux, Rust release build, 2026-07. The Python column is the pre-Rust baseline for relative comparison only.
Testing & CI
cargo testpasses on all platforms (ubuntu / windows / macos) via GitHub Actions (.github/workflows/ci.yml).- As of 2026-07-13: 41 integration + unit tests covering core search, quota (P2-2), entity graph (P2-3), and import/export (P2-4).
Quick Start
Build & Run
git clone https://github.com/jiayan-xu/memoria.git
cd memoria
cargo build --release
./target/release/memoria-server
ๆๅก้ป่ฎคไป
็ๅฌๆฌๆบๅ็ฏ http://127.0.0.1:9003๏ผๅฎๅ
จ้ป่ฎค๏ผใ
Web ไปช่กจ็๏ผhttp://127.0.0.1:9003/appใ
ๅฆ้ๆด้ฒๅฐๅฑๅ็ฝ๏ผ่ฎพ็ฝฎ MEMORIA_HOST=0.0.0.0๏ผ่ชๆ
้ฃ้ฉ๏ผใ
Docker (loopback)
cp .env.example .env # ็ผ่พๅกซๅ
ฅ MEMORIA_ADMIN_KEY
docker compose up -d --build
ไป
ๆฌๆบ 127.0.0.1:9003 ๅฏ่ฎฟ้ฎ๏ผไธๆด้ฒๅฐ็ฝ็ปใ่ฏฆ่ง docker-compose.yml ไธ docs/ROADMAP.mdใ
Config & Examples
- ๆๆ็ฏๅขๅ้่ง
.env.example๏ผๅ ไฝ็ฌฆ๏ผๆ ็ๅฎๅฏ้ฅ๏ผใ - MCP ๅฎขๆท็ซฏ้
็ฝฎๆ ทไพ่ง
examples/๏ผclaude-desktop.json/cursor.json/python-minimal-client.pyใ
Environment Variables
| Variable | Default | Description |
|---|---|---|
MEMORIA_DB_PATH | data/memoria.db | Main database path |
MEMORIA_PORT | 9003 | Server port |
MEMORIA_HOST | 127.0.0.1 | Bind address (loopback by default) |
MEMORIA_ADMIN_KEY | (required) | Admin token; refuse to start if unset/empty |
MEMORIA_AUTH_DB_PATH | <data>/audit.db | Audit database path |
MEMORIA_BACKUP_DIR | data/backups | GFS backup directory |
MEMORIA_BACKUP_INTERVAL_HOURS | 24 | Backup interval |
MEMORIA_WORKER_THREADS | 4 | Async worker threads |
MEMORIA_MAX_BLOCKING_THREADS | 512 | Max blocking threads |
MEMORIA_NEAR_DUP_ENABLED | true | Near-duplicate dedup (P1-3) |
MEMORIA_NEAR_DUP_THRESHOLD | 0.92 | Dedup cosine threshold |
MEMORIA_QUOTA_WRITES_PER_DAY | 1000 | Write quota per ns/day (P2-2) |
MEMORIA_QUOTA_SEARCHES_PER_MIN | 120 | Search quota per ns/min (P2-2) |
MEMORIA_QUOTA_BACKUPS_PER_HOUR | 10 | Backup quota per ns/hour (P2-2) |
MEMORIA_DREAM_COOLDOWN_DEFAULT | 300 | Dream cooldown seconds (P1-4) |
MEMORIA_DREAM_COOLDOWN_DECAY | 60 | Decay-phase cooldown seconds |
AGENT_CORE_LOG / RUST_LOG | info | Log level (P2-1 tracing) |
MEMORIA_EMBEDDING_URL | (empty) | Embed server URL; if empty, semantic search degrades to FTS-only (optional). See "Semantic Search" above. |
MCP Client Configuration
Add Memoria to any MCP-compatible client:
{
"mcpServers": {
"memoria": {
"url": "http://127.0.0.1:9003/mcp",
"transport": "http"
}
}
}
MCP Tools
| Tool | Description |
|---|---|
memory_search | Keyword + semantic hybrid search |
memory_search_v2 | 5-signal RRF fusion search |
memory_remember | Store memory (SHA-256 dedup) |
memory_observe | Store low-priority observation |
memory_user_prefs | Query user preference block |
memory_recent_decisions | Recent decision records |
memory_export | Streamed JSONL export of a namespace (P2-4) |
memory_import | Idempotent import into a namespace (P2-4) |
memory_migration_manifest | Cross-machine migration checksum manifest (admin, P2-4) |
memory_quota_status | Current quota usage & limits (P2-2) |
memory_backup / memory_backup_list | GFS backup trigger / list |
memory_health | Full health check report |
memory_decay | Run decay loop |
memory_graph | Build memory relation graph |
memory_dedup_chain | Query superseded chain of a memory |
memory_merge | Merge two near-duplicate memories (admin) |
memory_fetch_unconsolidated | Fetch raw observations for nightly consolidation |
dream_state_get / dream_state_update | Consolidation cursor state (P1-4) |
entity_upsert / entity_add_mention / entity_add_edge | Entity graph write (P2-3) |
entity_search | Entity search (incl. mention context, P2-3) |
register_agent / agent_list / agent_revoke | Agent registry (admin key) |
register_user / login_user | Local account login |
import_install_memories | Migrate a namespace (admin) |
get_allowed_ns | Return caller's authorized namespaces |
audit_query / db_stats | Audit log query / DB stats |
a2a_send / a2a_recv | A2A messaging |
skill_market_* | Skill marketplace (5 tools) |
Tech Stack
| Component | Technology |
|---|---|
| Language | Rust (2021 edition) |
| Web framework | axum + tower-http |
| Structured storage | SQLite + r2d2 connection pool |
| Full-text search | FTS5 + jieba-rs |
| Vector search | hnsw_rs (HNSW) |
| Hybrid ranking | RRF 5-signal fusion |
| Protocol | MCP (JSON-RPC over HTTP) |
| Binary size | ~8 MB (release, stripped) |
System Requirements
- OS: Windows 10+ / Linux / macOS
- RAM: โฅ 64 MB idle, โฅ 256 MB under load
- Disk: โฅ 100 MB (excluding database)
- Rust toolchain: Only needed for building
Project Structure
memoria/
โโโ src/
โ โโโ main.rs # Binary entry point
โ โโโ lib.rs # Library (optional PyO3 bindings)
โ โโโ mcp_server.rs # MCP JSON-RPC handler
โ โโโ auth.rs # Identity + audit + weekly partitioning
โ โโโ web_api.rs # HTTP API + static file serving
โ โโโ session_watcher.rs # Session lifecycle tracking
โ โโโ search/
โ โ โโโ rrf.rs # 5-signal RRF fusion + graph expansion
โ โ โโโ keyword.rs # FTS5 keyword search
โ โ โโโ semantic.rs # HNSW semantic search
โ โ โโโ temporal.rs # Time decay
โ โ โโโ importance.rs # Importance scoring
โ โ โโโ hybrid.rs # Search orchestration
โ โโโ storage/
โ โ โโโ sqlite.rs # Connection pool + schema init
โ โ โโโ fts5.rs # jieba-rs tokenizer
โ โ โโโ models.rs # Data models
โ โโโ vector/
โ โ โโโ hnsw.rs # HNSW index wrapper
โ โ โโโ embedding.rs # Embedding client + LRU cache
โ โโโ tools/
โ โโโ remember.rs # Memory storage
โ โโโ observe.rs # Observation storage
โ โโโ prefs.rs # User preferences
โ โโโ decay.rs # Memory decay
โ โโโ graph.rs # Relation graph
โโโ web/ # Web dashboard (static HTML/CSS/JS)
โโโ Cargo.toml
โโโ Cargo.lock
โโโ README.md
References
Papers
- MAGMA (ACL 2026) โ Multi-graph memory architecture, RRF fusion
- Reciprocal Rank Fusion (Cormack et al., SIGIR 2009) โ Ranking fusion
- HNSW (Malkov & Yashunin, 2016) โ Approximate nearest neighbor search
Projects
- hnsw-rs โ Rust HNSW implementation
- jieba-rs โ Chinese segmentation
- rusqlite โ SQLite bindings
- axum โ Rust web framework
Comparisons
| System | vs Memoria |
|---|---|
| Mem0 | In-memory layer, needs external vector DB; Memoria ships HNSW + SQLite |
| MemGPT | Virtual context management for LLM windows; Memoria focuses on persistent memory |
| LangChain Memory | Framework-locked; Memoria is protocol-level independent service |
License
MIT