๐Ÿง  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.

ไธญๆ–‡ๆ–‡ๆกฃ | Evolution Log


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

  • 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_URL is 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:
    python embed_server.py                       # listens 127.0.0.1:8777/embed
    # then set in .env:
    MEMORIA_EMBEDDING_URL=http://127.0.0.1:8777/embed
    
    The embed server (sentence_transformers, offline CPU, model shibing624/text2vec-base-chinese) is documented in embed_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

MetricPython (original)RustImprovement
Avg search latency410ms112ms3.7x
P50 search latency182ms99ms1.8x
Zero-result rate32.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 test passes 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

VariableDefaultDescription
MEMORIA_DB_PATHdata/memoria.dbMain database path
MEMORIA_PORT9003Server port
MEMORIA_HOST127.0.0.1Bind address (loopback by default)
MEMORIA_ADMIN_KEY(required)Admin token; refuse to start if unset/empty
MEMORIA_AUTH_DB_PATH<data>/audit.dbAudit database path
MEMORIA_BACKUP_DIRdata/backupsGFS backup directory
MEMORIA_BACKUP_INTERVAL_HOURS24Backup interval
MEMORIA_WORKER_THREADS4Async worker threads
MEMORIA_MAX_BLOCKING_THREADS512Max blocking threads
MEMORIA_NEAR_DUP_ENABLEDtrueNear-duplicate dedup (P1-3)
MEMORIA_NEAR_DUP_THRESHOLD0.92Dedup cosine threshold
MEMORIA_QUOTA_WRITES_PER_DAY1000Write quota per ns/day (P2-2)
MEMORIA_QUOTA_SEARCHES_PER_MIN120Search quota per ns/min (P2-2)
MEMORIA_QUOTA_BACKUPS_PER_HOUR10Backup quota per ns/hour (P2-2)
MEMORIA_DREAM_COOLDOWN_DEFAULT300Dream cooldown seconds (P1-4)
MEMORIA_DREAM_COOLDOWN_DECAY60Decay-phase cooldown seconds
AGENT_CORE_LOG / RUST_LOGinfoLog 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

ToolDescription
memory_searchKeyword + semantic hybrid search
memory_search_v25-signal RRF fusion search
memory_rememberStore memory (SHA-256 dedup)
memory_observeStore low-priority observation
memory_user_prefsQuery user preference block
memory_recent_decisionsRecent decision records
memory_exportStreamed JSONL export of a namespace (P2-4)
memory_importIdempotent import into a namespace (P2-4)
memory_migration_manifestCross-machine migration checksum manifest (admin, P2-4)
memory_quota_statusCurrent quota usage & limits (P2-2)
memory_backup / memory_backup_listGFS backup trigger / list
memory_healthFull health check report
memory_decayRun decay loop
memory_graphBuild memory relation graph
memory_dedup_chainQuery superseded chain of a memory
memory_mergeMerge two near-duplicate memories (admin)
memory_fetch_unconsolidatedFetch raw observations for nightly consolidation
dream_state_get / dream_state_updateConsolidation cursor state (P1-4)
entity_upsert / entity_add_mention / entity_add_edgeEntity graph write (P2-3)
entity_searchEntity search (incl. mention context, P2-3)
register_agent / agent_list / agent_revokeAgent registry (admin key)
register_user / login_userLocal account login
import_install_memoriesMigrate a namespace (admin)
get_allowed_nsReturn caller's authorized namespaces
audit_query / db_statsAudit log query / DB stats
a2a_send / a2a_recvA2A messaging
skill_market_*Skill marketplace (5 tools)

Tech Stack

ComponentTechnology
LanguageRust (2021 edition)
Web frameworkaxum + tower-http
Structured storageSQLite + r2d2 connection pool
Full-text searchFTS5 + jieba-rs
Vector searchhnsw_rs (HNSW)
Hybrid rankingRRF 5-signal fusion
ProtocolMCP (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

Systemvs Memoria
Mem0In-memory layer, needs external vector DB; Memoria ships HNSW + SQLite
MemGPTVirtual context management for LLM windows; Memoria focuses on persistent memory
LangChain MemoryFramework-locked; Memoria is protocol-level independent service

License

MIT