Memorium
Enables AI assistants to have persistent long-term memory by automatically storing and retrieving important information via MCP tools.
README
Memorium
Persistent Memory Infrastructure for AI Agents
Memorium is an open-source, self-hostable Model Context Protocol (MCP) server that gives AI assistants persistent long-term memory. Install once, connect to any MCP-compatible client (Claude Desktop, Cursor, etc.), and your AI finally remembers you.
flowchart LR
A[AI Assistant] -- MCP stdio --> B[Memorium]
B --> C[(SQLite / PostgreSQL)]
B --> D[(Qdrant Vector DB)]
B --> E[Memory Engine]
E --> F[Extraction]
E --> G[Scoring]
E --> H[Dedup]
E --> I[Conflict Resolution]
Features
- Automatic Memory - AI detects and stores important information without manual commands
- 7 MCP Tools -
remember,search_memory,retrieve_context,update_memory,forget_memory,list_memories,memory_stats - MCP Resources - Expose memories as readable resources (
memora://default/context,memora://default/memories) - Context Injection - Auto-inject relevant memories as context before answering
- Intelligent Pipeline - Extraction → Classification → Importance Scoring → Dedup → Conflict Resolution → Storage
- 6 Memory Types - Profile, Preference, Semantic, Episodic, Procedural, Project
- Hybrid Search - Keyword + tag + importance + recency ranking
- Memory Consolidation - Background merging of related memories, cleanup of expired entries
- Duplicate Detection - Automatic detection and skipping of duplicate information
- Conflict Resolution - Detects contradictions, marks outdated information while keeping history
- Sensitive Data Protection - Automatically detects and blocks passwords, API keys, tokens
- Local-First - All data stored locally by default, no external APIs required
- Privacy-First - You own all your data. Encryption option available.
Installation
pip install memorium
Or with uvx (no install needed):
uvx memorium
Optional Dependencies
# PostgreSQL support
pip install memorium[postgres]
# Qdrant vector search
pip install memorium[qdrant]
# Redis caching
pip install memorium[redis]
# Neo4j graph memory
pip install memorium[neo4j]
# LLM providers
pip install memorium[ollama,openai,gemini]
# Everything
pip install memorium[all]
Quick Start
1. Initialize configuration
memorium init
This creates ~/.memorium/config.yaml with default settings.
2. Start the MCP server
memorium serve
3. Connect to your AI assistant
Claude Desktop
Add to your claude_desktop_config.json:
{
"mcpServers": {
"memora": {
"command": "uvx",
"args": ["memorium"]
}
}
}
Cursor
Add to Cursor MCP configuration:
{
"mcpServers": {
"memora": {
"command": "uvx",
"args": ["memorium"]
}
}
}
How It Works
When you chat with your AI:
- You share information naturally
- The AI calls
remember()to store important details - Before answering, the AI calls
retrieve_context()to fetch relevant memories - Memories are automatically extracted, classified, scored, deduplicated, and stored
User: "My name is Khalid and I prefer Python for AI projects."
AI detects important information → calls remember()
Memory stored:
{
"type": "preference",
"content": "User prefers Python for AI projects",
"importance": 0.9
}
Later:
User: "What programming language do I prefer for AI?"
AI calls retrieve_context("programming language preference")
→ retrieves memory → answers correctly
Configuration
Configuration is stored in ~/.memorium/config.yaml:
storage:
type: sqlite # sqlite | postgres
sqlite_path: ~/.memorium/memora.db
embedding:
provider: ollama # ollama | openai | gemini
model: nomic-embed-text
llm:
provider: openai # ollama | openai | gemini
model: gpt-4o-mini
vector:
provider: qdrant # optional: qdrant
url: http://localhost:6333
cache:
provider: redis # optional: redis
url: redis://localhost:6379/0
graph:
provider: neo4j # optional: neo4j
uri: bolt://localhost:7687
security:
encryption_enabled: false
All settings can also be set via environment variables:
export MEMORIUM_STORAGE__TYPE=postgres
export MEMORIUM_STORAGE__POSTGRES_DSN=postgresql://user:pass@localhost:5432/memorium
export MEMORIUM_EMBEDDING__PROVIDER=openai
export MEMORIUM_EMBEDDING__API_KEY=sk-...
CLI Reference
| Command | Description |
|---|---|
memorium init |
Create default configuration |
memorium serve |
Start the MCP server |
memorium status |
Show database and memory statistics |
memorium export |
Export all memories (JSON/YAML) |
memorium delete |
Delete all memories |
MCP API
Tools
| Tool | Description | Key Inputs |
|---|---|---|
remember |
Store a new memory | content (required), memory_type, user_id |
search_memory |
Search relevant memories | query (required), limit, memory_type |
retrieve_context |
Get context for answering | query (required) |
update_memory |
Modify existing memory | memory_id (required), content |
forget_memory |
Delete a memory | memory_id (required) |
list_memories |
List stored memories | user_id, memory_type, limit, offset |
memory_stats |
Show analytics | user_id |
consolidate |
Merge related memories | user_id, dry_run |
Resources
| URI | Description |
|---|---|
memorium://default/context |
Active memory context (markdown) |
memorium://default/memories |
All stored memories list (markdown) |
Architecture
User Message
│
▼
┌──────────────┐
│ Extractor │ Extract structured memories from conversation
│ │ Classify into type, detect sensitive data
└──────┬───────┘
▼
┌──────────────┐
│ Scorer │ Score importance (0-1) based on:
│ │ - Explicit "remember" cues
│ │ - Personal relevance
│ │ - Future usefulness
└──────┬───────┘
▼
┌──────────────┐
│ Classifier │ Assign memory type:
│ │ profile, preference, semantic,
│ │ episodic, procedural, project
└──────┬───────┘
▼
┌──────────────┐
│ Deduplicator│ Check for exact/near-duplicate memories
└──────┬───────┘
▼
┌──────────────┐
│ Conflict │ Detect contradictions with existing memories
│ Resolver │ Mark outdated memories, keep history
└──────┬───────┘
▼
┌──────────────┐
│ Storage │ SQLite (default) / PostgreSQL / Qdrant
└──────────────┘
Memory Types
| Type | Description | Examples |
|---|---|---|
| Profile | User identity | Name, location, occupation |
| Preference | User preferences | Likes Python, prefers dark mode |
| Semantic | Facts and knowledge | "RAG systems use retrieval" |
| Episodic | Past events | "Last week we discussed..." |
| Procedural | User workflows | "I always deploy with Docker" |
| Project | Current projects | "Building a RAG system" |
Docker
# Start all services
docker compose up -d
# Or just the memorium server
docker build -t memorium .
docker run -v ~/.memora:/root/.memora memorium
Development
# Clone the repository
git clone https://github.com/yourusername/memorium
cd memorium
# Install in dev mode
pip install -e ".[all]"
# Run linting
ruff check src/
# Run type checking
mypy src/
# Run tests
pytest
# Run benchmarks
python tests/benchmark.py
Benchmark Results
Run the built-in benchmark suite:
python tests/benchmark.py
Measures:
- Storage throughput (ops/sec)
- Search latency (p50/p95/p99)
- Retrieval recall@k
- Duplicate detection accuracy
- Conflict resolution accuracy
- Extraction throughput
- Consolidation efficiency
Security
- Sensitive data detection - Passwords, API keys, tokens are never stored
- Encryption - Optional encryption at rest
- User isolation - Memories are scoped by
user_id - Local-first - No external API calls required by default
License
MIT
Roadmap
- [ ] Embedding-based vector search (built-in, no external deps)
- [ ] Web UI for browsing memories
- [ ] Memory graph visualization
- [ ] Multi-user server mode
- [ ] Plugin system for custom extractors
- [ ] Cloud sync option (end-to-end encrypted)
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。