SimpleMem MCP Server
# SimpleMem MCP Server
A **Model Context Protocol (MCP)** server for [SimpleMem](https://github.com/AIMING-Lab/SimpleMem) - an efficient lifelong memory system for LLM agents based on semantic lossless compression.
## Overview
SimpleMem MCP Server exposes SimpleMem's powerful memory capabilities through the Model Context Protocol, enabling AI assistants like Claude to:
- **Store conversations** with semantic lossless compression
- **Retrieve memories** using three-stage hybrid retrieval (semantic + lexical + symbolic)
- **Answer questions** based on long-term memory with 43.24% F1 score on LoCoMo-10 benchmark
- **Manage atomic memory entries** with automatic coreference resolution and temporal anchoring
### Key Features
- **Three-Stage Memory Pipeline**:
1. **Semantic Structured Compression**: Converts dialogues → atomic, self-contained facts
2. **Multi-View Indexing**: Semantic (vector) + Lexical (BM25) + Symbolic (metadata)
3. **Adaptive Query-Aware Retrieval**: Planning-based decomposition + reflection mechanism
- **Advanced Processing**:
- Coreference resolution (he/she → actual names)
- Temporal anchoring (tomorrow → absolute timestamps)
- Parallel processing with configurable workers
- Windowed batch processing for efficiency
- **Performance**: 30× fewer tokens than full-context methods with superior retrieval accuracy
## Architecture
```
┌─────────────────────────┐
│ MCP Client │
│ (Claude, Cursor, etc) │
└───────────┬─────────────┘
│ stdio
▼
┌─────────────────────────────────┐
│ SimpleMem MCP Server (Node) │
│ - Tool handlers │
│ - Resource providers │
│ - Input validation (Zod) │
└───────────┬─────────────────────┘
│ spawn
▼
┌─────────────────────────────────┐
│ SimpleMem (Python) │
│ - Semantic compression │
│ - Hybrid retrieval │
│ - LanceDB vector store │
└─────────────────────────────────┘
```
## Prerequisites
1. **Node.js** 18+ and npm
2. **Python** 3.8+
3. **SimpleMem** installed and configured
4. **OpenAI API key** (or compatible LLM provider)
## Installation
### 1. Clone and Install
```bash
cd SimpleMem-MCP
npm install
npm run build
```
### 2. Configure SimpleMem
Make sure SimpleMem is properly set up:
```bash
# Navigate to SimpleMem directory
cd /path/to/SimpleMem
# Copy and configure config file
cp config.py.example config.py
# Edit config.py with your settings
# - OPENAI_API_KEY
# - LLM_MODEL (e.g., "gpt-4.1-mini")
# - EMBEDDING_MODEL (e.g., "Qwen/Qwen3-Embedding-0.6B")
# Install Python dependencies
pip install -r requirements.txt
```
### 3. Set Environment Variables
Create a `.env` file in SimpleMem-MCP directory:
```bash
cp .env.example .env
```
Edit `.env`:
```env
# Path to SimpleMem project directory
SIMPLEMEM_PATH=/Users/jiaqi/Myprojects/new/SimpleMem
# Path to LanceDB database directory (relative to SimpleMem)
SIMPLEMEM_DB_PATH=./lancedb_data
# Python executable (optional)
PYTHON_PATH=python3
```
## Usage
### Configuration for Claude Desktop
Add to your Claude Desktop configuration file:
**macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
**Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
```json
{
"mcpServers": {
"simplemem": {
"command": "node",
"args": ["/path/to/SimpleMem-MCP/dist/index.js"],
"env": {
"SIMPLEMEM_PATH": "/path/to/SimpleMem",
"SIMPLEMEM_DB_PATH": "./lancedb_data"
}
}
}
}
```
### Restart Claude Desktop
After saving the configuration, restart Claude Desktop to load the MCP server.
## Available Tools
### 1. `add_dialogue`
Add a single dialogue to the memory system.
**Parameters**:
- `speaker` (required): Name of the speaker
- `content` (required): What was said (max 200k chars)
- `timestamp` (optional): ISO 8601 timestamp (e.g., "2025-11-15T14:30:00")
**Example**:
```
User: "Remember this conversation. Alice said: 'Bob, let's meet at Starbucks tomorrow at 2pm.'"
```
### 2. `add_dialogues`
Batch add multiple dialogues (more efficient).
**Parameters**:
- `dialogues` (required): Array of dialogue objects
**Example**:
```json
{
"dialogues": [
{
"speaker": "Alice",
"content": "Bob, let's meet at Starbucks tomorrow at 2pm",
"timestamp": "2025-11-15T14:30:00"
},
{
"speaker": "Bob",
"content": "Sure, I'll bring the market analysis report",
"timestamp": "2025-11-15T14:31:00"
}
]
}
```
### 3. `finalize`
Process all buffered dialogues into memory entries. **Important**: Always call this after adding dialogues.
SimpleMem uses windowed processing (default: 40 dialogues per window), so this ensures all dialogues are processed.
### 4. `ask`
Ask a question to the memory system.
**Parameters**:
- `question` (required): Your question (max 10k chars)
**How it works**:
1. Analyzes query complexity
2. Generates targeted search queries (planning)
3. Retrieves from semantic + lexical + symbolic layers
4. Reflects on adequacy (optional iterative refinement)
5. Synthesizes concise answer
**Example**:
```
User: "When and where will Alice and Bob meet?"
Assistant: "16 November 2025 at 2:00 PM at Starbucks"
```
### 5. `search_memories`
Semantic search without answer synthesis (raw memory entries).
**Parameters**:
- `query` (required): Search query
- `top_k` (optional): Number of results (default: 10, max: 100)
**Use case**: Explore what the system remembers about a topic.
### 6. `get_all_memories`
Retrieve all atomic memory entries.
**Returns**: Complete list of memories with:
- Lossless restatement (self-contained fact)
- Keywords
- Timestamp (if available)
- Location (if mentioned)
- People involved
- Entities (companies, products, etc.)
- Topic
### 7. `clear_memories`
Clear all memories from the database. ⚠️ **Warning**: Cannot be undone!
## Available Resources
### 1. `simplemem://memories`
**Type**: JSON
**Description**: Complete list of all memory entries
**Access in Claude**:
```
User: "Can you show me all memories as JSON?"
```
### 2. `simplemem://stats`
**Type**: JSON
**Description**: System statistics and configuration
**Returns**:
```json
{
"total_memories": 42,
"db_path": "./lancedb_data",
"model": "gpt-4.1-mini",
"features": {
"planning_enabled": true,
"reflection_enabled": true,
"parallel_processing": true
}
}
```
## Example Workflow
```
# Step 1: Add conversations
User: "Remember this: Alice said to Bob, 'Let's meet at Starbucks tomorrow at 2pm to discuss the project.'"
Assistant: [Uses add_dialogue tool]
User: "Bob replied: 'Great, I'll bring the market analysis report.'"
Assistant: [Uses add_dialogue tool]
# Step 2: Finalize processing
Assistant: [Calls finalize tool automatically]
# Step 3: Query memories
User: "What did Alice and Bob plan?"
Assistant: [Uses ask tool] → "Alice and Bob plan to meet at Starbucks on 16 November 2025 at 2:00 PM to discuss the project. Bob will bring the market analysis report."
# Step 4: Explore memories
User: "Show me all memories about meetings"
Assistant: [Uses search_memories tool with query="meetings"]
```
## How SimpleMem Works
### Stage 1: Semantic Structured Compression
**Input** (dialogue):
```
Alice: "He'll meet Bob tomorrow at 2pm at the coffee shop"
```
**Output** (atomic memory entry):
```
{
"lossless_restatement": "John will meet Bob at Starbucks on 2025-11-16T14:00:00",
"persons": ["John", "Bob"],
"location": "Starbucks",
"timestamp": "2025-11-16T14:00:00",
"keywords": ["meet", "Bob", "John", "Starbucks"]
}
```
**Transformations**:
- Coreference resolution: "he" → "John"
- Temporal anchoring: "tomorrow at 2pm" → "2025-11-16T14:00:00"
- Location normalization: "coffee shop" → "Starbucks" (from context)
### Stage 2: Multi-View Indexing
Each memory is indexed across three dimensions:
| Layer | Type | Purpose |
|-------|------|---------|
| **Semantic** | Dense (1024-d) | Conceptual similarity |
| **Lexical** | Sparse (BM25) | Exact keyword matching |
| **Symbolic** | Metadata | Structured filtering |
### Stage 3: Adaptive Retrieval
**Simple Query** (low complexity):
```
"When will they meet?" → Single semantic search
```
**Complex Query** (high complexity):
```
"What projects did Alice and Bob discuss in November at Starbucks?"
→ Multi-query decomposition:
1. Semantic: "Alice Bob projects discuss"
2. Symbolic: persons=["Alice","Bob"], location="Starbucks", time=November
3. Keyword: ["projects", "discuss"]
→ Reflection: Check if results adequate, generate follow-up if needed
→ Synthesis: Combine results and generate answer
```
## Performance Benchmarks
**LoCoMo-10 Dataset** (GPT-4.1-mini):
- **F1 Score**: 43.24%
- **Token Usage**: ~550 tokens (30× fewer than full-context)
- **Retrieval Time**: 388.3s for full benchmark
**Comparison**:
- Mem0: 34.20% F1, 1350.9s construction
- A-Mem: 32.58% F1, 5140.5s construction
- LightMem: 24.63% F1, 577.1s retrieval
## Configuration Options
SimpleMem behavior is controlled via `config.py` in the SimpleMem directory:
```python
# Core Models
LLM_MODEL = "gpt-4.1-mini" # or "qwen-max", "gpt-4"
EMBEDDING_MODEL = "Qwen/Qwen3-Embedding-0.6B"
# Processing
WINDOW_SIZE = 40 # Dialogues per processing window
OVERLAP_SIZE = 2 # Window overlap for context
# Retrieval
SEMANTIC_TOP_K = 25 # Vector search results
KEYWORD_TOP_K = 5 # BM25 results
STRUCTURED_TOP_K = 5 # Metadata filter results
# Advanced Features
ENABLE_PLANNING = True # Multi-query decomposition
ENABLE_REFLECTION = True # Iterative refinement
MAX_REFLECTION_ROUNDS = 2 # Max reflection iterations
ENABLE_PARALLEL_PROCESSING = True
MAX_PARALLEL_WORKERS = 16 # Memory building workers
ENABLE_PARALLEL_RETRIEVAL = True
MAX_RETRIEVAL_WORKERS = 8 # Retrieval workers
```
## Troubleshooting
### Server doesn't start
**Check**:
1. Node.js version: `node --version` (should be 18+)
2. TypeScript compiled: `npm run build`
3. Environment variables set correctly
4. SimpleMem path exists and is accessible
### Python execution fails
**Check**:
1. Python version: `python3 --version` (should be 3.8+)
2. SimpleMem dependencies installed: `pip install -r requirements.txt`
3. `config.py` exists and has valid API key
4. PYTHONPATH includes SimpleMem directory
### No memories returned
**Common causes**:
1. Forgot to call `finalize` after adding dialogues
2. Database path incorrect
3. Embedding model not downloaded (first run may take time)
4. LanceDB database corrupted (try clearing and re-adding)
### Slow performance
**Optimization**:
1. Use smaller LLM for compression (e.g., "qwen2.5-1.5b")
2. Reduce `SEMANTIC_TOP_K` for faster retrieval
3. Disable reflection: `ENABLE_REFLECTION = False`
4. Increase parallel workers (if you have cores available)
## Development
### Build
```bash
npm run build
```
### Watch mode (for development)
```bash
npm run dev
```
### Testing manually
```bash
# Start server (outputs to stderr for debugging)
node dist/index.js
# The server expects JSON-RPC messages on stdin
# Use MCP Inspector for interactive testing:
npx @modelcontextprotocol/inspector node dist/index.js
```
## Project Structure
```
SimpleMem-MCP/
├── src/
│ ├── index.ts # Main MCP server (tools, resources, handlers)
│ ├── simplemem-client.ts # Python SimpleMem wrapper
│ └── types.ts # TypeScript interfaces
├── dist/ # Compiled JavaScript (generated)
├── package.json # Dependencies and scripts
├── tsconfig.json # TypeScript configuration
├── .env.example # Environment template
├── .gitignore
└── README.md # This file
```
## References
- **SimpleMem Paper**: [arXiv:2601.02553](https://arxiv.org/abs/2601.02553)
- **SimpleMem GitHub**: [AIMING-Lab/SimpleMem](https://github.com/AIMING-Lab/SimpleMem)
- **MCP Documentation**: [Model Context Protocol](https://modelcontextprotocol.io)
- **MCP SDK**: [@modelcontextprotocol/sdk](https://github.com/modelcontextprotocol/typescript-sdk)
## License
MIT License - See SimpleMem project for details.
## Citation
If you use SimpleMem in your research, please cite:
```bibtex
@misc{simplemem2026,
title={SimpleMem: Efficient Lifelong Memory for LLM Agents via Semantic Lossless Compression},
author={AIMING Lab},
year={2026},
eprint={2601.02553},
archivePrefix={arXiv}
}
```
## Support
- **SimpleMem Issues**: [GitHub Issues](https://github.com/AIMING-Lab/SimpleMem/issues)
- **MCP Issues**: [MCP GitHub](https://github.com/modelcontextprotocol)
---
Built with ❤️ using the Model Context Protocol
TDQS
Scored across 7 tools
Most tools target clearly distinct operations: adding dialogues, finalizing, asking, searching, retrieving all, and clearing. The only mild overlap is between add_dialogue and add_dialogues (single vs batch) and, to a lesser extent, ask versus search_memories, but the descriptions make the distinction clear.
Five of seven tools follow a clear verb_noun pattern (clear_memories, add_dialogue, add_dialogues, search_memories, get_all_memories). The bare verbs 'ask' and 'finalize' are minor deviations but remain readable and verb-first.
Seven tools is a well-scoped set for a memory management server, covering ingestion, processing, retrieval, question answering, and clearing without unnecessary surface area.
The surface covers the core lifecycle: add dialogues, finalize processing, search/retrieve memories, ask questions, and clear all memories. It lacks targeted update or delete of individual memories and direct lookup by ID, which are minor but noticeable gaps.