ai-memory-mcp
by zhanpu89
README.md
# π§ AI Memory MCP
> Persistent session memory for AI assistants β store, search and retrieve conversation summaries via the [Model Context Protocol](https://modelcontextprotocol.io).
[](https://www.python.org/)
[](https://modelcontextprotocol.io)
[](LICENSE)
[](#testing)
---
## What is this?
AI assistants forget everything between sessions. **AI Memory MCP** solves that by giving your AI a structured long-term memory:
- π **Save** session summaries with status, tags, modules and file paths
- π **Search** by keyword, full-text (FTS5), or **semantic vector similarity**
- π **Restore context** at the start of each session with one tool call
- π **Generate weekly reports** from completed tasks automatically
- π·οΈ **Multi-project / multi-branch** support out of the box
Works with **Claude Desktop**, **Cursor**, **VS Code**, **Windsurf**, and any MCP-compatible client.
---
## Quick Start
### 1 β Install
```bash
# From PyPI (recommended)
pip install ai-memory-mcp
# With vector search support (adds ~500 MB for embedding model)
pip install "ai-memory-mcp[vector]"
# From source
git clone https://github.com/zhanpu89/ai-memory-mcp
cd ai-memory-mcp
pip install -e .
```
### 2 β Configure your AI client
Pick the config snippet for your tool and add it to its MCP settings file:
<details>
<summary><b>Claude Desktop</b> β <code>~/Library/Application Support/Claude/claude_desktop_config.json</code></summary>
```json
{
"mcpServers": {
"ai-memory": {
"command": "ai-memory-mcp"
}
}
}
```
</details>
<details>
<summary><b>Cursor</b> β <code>~/.cursor/mcp.json</code></summary>
```json
{
"mcpServers": {
"ai-memory": {
"command": "ai-memory-mcp"
}
}
}
```
</details>
<details>
<summary><b>VS Code (GitHub Copilot)</b> β <code>.vscode/mcp.json</code></summary>
```json
{
"servers": {
"ai-memory": {
"type": "stdio",
"command": "ai-memory-mcp"
}
}
}
```
</details>
<details>
<summary><b>Windsurf</b> β <code>~/.codeium/windsurf/mcp_config.json</code></summary>
```json
{
"mcpServers": {
"ai-memory": {
"command": "ai-memory-mcp"
}
}
}
```
</details>
<details>
<summary><b>HTTP mode</b> (remote / Docker / team)</summary>
Start the server:
```bash
ai-memory-mcp --http
# or: python service.py start
```
Then point your client at:
```json
{
"mcpServers": {
"ai-memory": {
"url": "http://localhost:8000/mcp"
}
}
}
```
</details>
> **All config snippets** are available in [`integrations/`](integrations/).
### 3 β Use it
At the start of every session, tell your AI:
```
Load my memory for project "my-project"
```
The AI will call `init_session` and restore your previous context automatically.
---
## Features
| Feature | Details |
|---|---|
| **Storage** | SQLite β zero external services, single file |
| **Full-text search** | SQLite FTS5 β fast, no extra deps |
| **Semantic search** | ChromaDB + `all-MiniLM-L6-v2` (optional) |
| **Multi-project** | Filter by `project_name` + `branch_name` |
| **Task lifecycle** | `pending β in_progress β completed / blocked / abandoned` |
| **Key decisions** | Attach architectural decisions to sessions |
| **Weekly reports** | Auto-generated Markdown report |
| **Transport** | stdio (local) or streamable-HTTP (remote) |
| **Docker** | Single-container deployment included |
---
## Architecture
```
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β AI Client (Claude / Cursor β¦) β
β MCP Protocol β
ββββββββββββββββββββββββ¬βββββββββββββββββββββββββββ
β stdio / HTTP
ββββββββββββββββββββββββΌβββββββββββββββββββββββββββ
β AiMemoryMcpServer (FastMCP) β
β β
β ββββββββββββββββ ββββββββββββββββββββββββ β
β β SQLite DB β β ChromaDB (optional) β β
β β FTS5 index β β Sentence-Transformersβ β
β ββββββββββββββββ ββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββ
```
**Data lives in `~/.ai-memory/`** β completely separate from your project files.
---
## Tool Reference
β See **[TOOLS.md](TOOLS.md)** for the full schema of all 10 tools.
| Tool | Description |
|---|---|
| `save_summary` | Persist a new session summary |
| `update_summary` | Update status / content |
| `add_decision` | Record a key technical decision |
| `search_summaries` | Keyword / FTS5 / vector search |
| `search_summaries_fts` | Dedicated FTS5 full-text search |
| `get_summary_by_id` | Exact lookup by session ID |
| `list_recent_sessions` | List latest sessions |
| `init_session` | Restore context at session start |
| `weekly_review` | Generate Markdown weekly report |
| `maintenance` | Rebuild index, VACUUM, persist vectors |
---
## Configuration
All settings are optional β sensible defaults work out of the box.
| Env var | Default | Description |
|---|---|---|
| `AI_MEMORY_DB_PATH` | `~/.ai-memory/ai_memory.db` | SQLite database path |
| `AI_MEMORY_MODEL_PATH` | `~/.ai-memory/models` | Embedding model cache |
| `AI_MEMORY_HOST` | `127.0.0.1` | HTTP server bind address |
| `AI_MEMORY_PORT` | `8000` | HTTP server port |
Create `~/.ai-memory/.env` to persist settings:
```env
AI_MEMORY_DB_PATH=/custom/path/ai_memory.db
AI_MEMORY_PORT=9000
```
---
## Docker
**Optimized for China:** Uses Tsinghua pip mirror + HuggingFace mirror for fast downloads.
```bash
# Option 1: Core-only (lightweight, ~200 MB image)
docker compose up -d
# Option 2: Full (with vector search)
# Step 1: Pre-download model to avoid large image
python3 scripts/download_model_for_docker.py --output ./models
# Step 2: Build with vector support (~700 MB image + 500 MB external model)
docker compose build --build-arg INSTALL_VECTOR=true
docker compose up -d
# View logs
docker compose logs -f
```
The MCP endpoint will be available at `http://localhost:8000/mcp`.
**π Full deployment guide:** See [DOCKER.md](DOCKER.md) for:
- Image size optimization strategies
- Chinese mirror configuration
- Model pre-downloading
- Production deployment examples
---
## Development
```bash
# Clone and install in editable mode with dev extras
git clone https://github.com/zhanpu89/ai-memory-mcp
cd ai-memory-mcp
pip install -e ".[dev]"
# Run tests
pytest
# Run tests with coverage
pytest --cov=src/mcp_server --cov-report=term-missing
# Start in HTTP mode for manual testing
ai-memory-mcp --http
```
### Project Structure
```
ai-memory-mcp/
βββ src/mcp_server/
β βββ __init__.py
β βββ server.py # All 10 MCP tools + server class
βββ tests/
β βββ unit/ # 24 unit tests
β βββ integration/
βββ scripts/
β βββ download_model.py # Manual model download
β βββ migrate_db.py # Database migration helper
β βββ migrate_vector.py # Vector store migration
βββ integrations/ # Ready-to-use MCP client configs
β βββ claude_desktop_config.json
β βββ cursor_mcp.json
β βββ vscode_mcp.json
β βββ windsurf_mcp.json
β βββ http_mode_config.json
βββ TOOLS.md # Full tool schema reference
βββ INSTALL.md # Detailed installation guide
βββ Dockerfile
βββ docker-compose.yml
βββ pyproject.toml
```
---
## Testing
```
24 passed in 7s
```
```bash
pytest tests/unit/test_mcp_server.py -v
```
All 24 unit tests cover: save/update/search/FTS/vector/decisions/maintenance/init/review/schema.
---
## Requirements
- Python 3.10+
- `mcp >= 1.6.0`
- `python-dotenv >= 1.0.0`
**Optional (vector search):**
- `chromadb >= 0.6.0`
- `sentence-transformers >= 3.0.0`
---
## License
[MIT](LICENSE) Β© AI Memory Team
TDQS
A3.8/5.0
Scored across 10 tools
Disambiguation4/5
Most tools serve distinct purposes, but search_summaries and search_summaries_fts overlap significantly, potentially confusing an agent about which to use for searching summaries.
Naming Consistency4/5
Names mostly follow verb_noun pattern (add_decision, save_summary) but include a few outliers like maintenance (noun) and longer phrases like get_summary_by_id, deviating from strict consistency.
Tool Count5/5
With 10 tools covering session initialization, CRUD, search, maintenance, and reporting, the count is well-scoped for an AI memory server without being overwhelming.
Completeness3/5
Covers saving, retrieving, updating, and searching summaries, but lacks delete functionality and has no dedicated tools for retrieving or removing decisions, leaving notable gaps.
Maintenance
ActivityInactive
ResponsivenessNo issues