Memex
Enables searching and retrieving Claude Code conversation history that would otherwise expire after 30 days. Supports full-text search, semantic search, and session management with automatic backup of all conversations.
README
Memex
A session history management system for Claude Code. Never lose your conversations again.
Why Memex?
Claude Code's local conversation data expires after 30 days, causing:
- Loss of important technical decision records
- Difficulty searching historical conversations
- Knowledge cannot be accumulated and reused
Memex solves these problems:
- ✅ Automatic backup of all Claude Code sessions
- ✅ Powerful full-text and semantic search
- ✅ MCP protocol support for searching history directly in Claude
- ✅ Web UI for browsing and managing sessions
Features
Data Collection & Backup
- Automatically scans all sessions under
~/.claude/projects/ - Parses JSONL format conversation content
- Stores in SQLite database
- Supports daily incremental backups
Search Capabilities
- Full-text Search: Fast keyword search based on SQLite FTS5
- Semantic Search: Semantic understanding using Ollama + LanceDB
- Hybrid Retrieval: RRF fusion ranking combining keyword and semantic relevance
- Advanced Filtering: Filter by project, time range, Session ID prefix
MCP Integration
Search historical conversations in Claude Code via MCP protocol:
search_history- Search historical conversationsget_session- Get session details (supports pagination and in-session search)get_recent_sessions- Get recent sessionslist_projects- List all projects
Web UI
- Cyberpunk-style interface
- Project list and session browsing
- Quick lookup by Session ID prefix
- Supports full-text/semantic/hybrid search
Tech Stack
- Backend: NestJS (DDD architecture)
- Database: SQLite + FTS5 (full-text search)
- Vector Store: LanceDB
- LLM Runtime: Ollama (local)
- Frontend: Vue 3
- Communication: HTTP + JSON-RPC (MCP)
Quick Start (Docker)
The fastest way to get started - no Node.js or build tools required.
# One command to start
docker run -d \
--name memex \
-p 3000:3000 \
-v ~/.claude/projects:/claude-sessions:ro \
-v memex-data:/data \
ghcr.io/vimo-ai/memex:latest
# Or use docker-compose
curl -sL https://raw.githubusercontent.com/vimo-ai/memex/main/docker-compose.yml -o docker-compose.yml
docker-compose up -d
Then visit http://localhost:3000
What's included
- Web UI for browsing sessions
- Full-text search (FTS5)
- MCP endpoint at
/api/mcp - Auto-import from
~/.claude/projects/
Optional: Enable Semantic Search
For semantic search and RAG, you need Ollama running on your host:
# Install Ollama and pull models
ollama pull bge-m3
ollama pull qwen3:8b
# Run Memex with Ollama access
docker run -d \
--name memex \
-p 3000:3000 \
-v ~/.claude/projects:/claude-sessions:ro \
-v memex-data:/data \
-e OLLAMA_API=http://host.docker.internal:11434/api \
ghcr.io/vimo-ai/memex:latest
Installation (From Source)
If you want to build from source or do development, follow these steps.
Prerequisites
- Node.js >= 18
- pnpm (recommended)
- Ollama (required for semantic search and RAG)
Ollama Models
| Model | Size | Purpose | Required |
|---|---|---|---|
bge-m3 |
1.2 GB | Embedding (1024 dim) | Yes, for semantic search |
qwen3:8b |
5.2 GB | Chat / RAG Q&A | Yes, for Ask AI feature |
# Install Ollama
curl -fsSL https://ollama.com/install.sh | sh
# Pull required models
ollama pull bge-m3 # Embedding model
ollama pull qwen3:8b # Chat model for RAG
Note: Without Ollama models, full-text search still works. Semantic search and RAG require the models above.
Install Project
# Clone project
git clone <repository-url>
cd memex
# Install dependencies
pnpm install
# Web UI dependencies
cd web
pnpm install
cd ..
Configuration
Copy and edit the configuration file:
cp .env.example .env
Main configuration options:
# Server port
PORT=10013
# Data storage directory
MEMEX_DATA_DIR=~/memex-data
# Backup directory
MEMEX_BACKUP_DIR=~/memex-data/backups
# Claude Code data source path
CLAUDE_PROJECTS_PATH=~/.claude/projects
# Ollama API address
OLLAMA_API=http://localhost:11434/api
# Embedding model
EMBEDDING_MODEL=bge-m3
# Chat model for RAG
CHAT_MODEL=qwen3:8b
Running
Development Mode
# Start backend
pnpm dev
# Start frontend (new terminal)
cd web
pnpm dev
Production Mode
# Build backend
pnpm build
# Build frontend
cd web
pnpm build
cd ..
# Start service
pnpm start:prod
MCP Configuration
Memex provides MCP service via HTTP protocol with simple configuration.
Option 1: mcp-router Configuration (Recommended)
Edit mcp-router configuration file:
{
"mcpServers": {
"memex": {
"type": "http",
"url": "http://127.0.0.1:10013/api/mcp"
}
}
}
Option 2: Claude Code Direct Configuration
Add to Claude Code's MCP settings:
{
"mcpServers": {
"memex": {
"type": "http",
"url": "http://127.0.0.1:10013/api/mcp"
}
}
}
Verify MCP Connection
After starting Claude Code, verify with:
Search for my recent discussions about DDD architecture
If MCP is configured correctly, Claude will call the memex/search_history tool.
API Endpoints
Project Management
GET /api/projects- Get all projects listGET /api/projects/:id- Get project details (including session list)
Session Management
GET /api/sessions/:id- Get session details (full conversation content)GET /api/sessions/search?idPrefix=xxx- Search by Session ID prefix
Search
-
GET /api/search?q=xxx&projectId=yyy- Full-text search- Query parameters:
q: Search keywordsprojectId: Project filter (optional)startDate: Start date (optional)endDate: End date (optional)limit: Result limit, default 20
- Query parameters:
-
GET /api/search/semantic?q=xxx&mode=hybrid- Semantic search- Query parameters:
q: Search contentmode: Search modesemantic: Pure semantic searchhybrid: Hybrid search (keyword + semantic)
projectId: Project filter (optional)limit: Result limit, default 10
- Query parameters:
RAG Q&A
POST /api/ask- Ask questions based on history- Request body:
question: The question to askcwd: Current working directory for project filtering (optional)contextWindow: Context messages before/after, default 3 (optional)maxSources: Max source references, default 5 (optional)
- Response:
{ answer, sources, model, tokensUsed }
- Request body:
MCP
POST /api/mcp- MCP JSON-RPC endpointGET /api/mcp/info- Get MCP tools information
Usage Examples
Web UI
Visit http://localhost:10013 to use the web interface.
Main features:
- Browse all projects and sessions
- Quick lookup by Session ID prefix
- Full-text search conversation content
- Semantic search related discussions
- Filter by project and time
Command Line Search
# Full-text search
curl "http://localhost:10013/api/search?q=authentication"
# Semantic search
curl "http://localhost:10013/api/search/semantic?q=how+to+design+domain+models&mode=hybrid"
# Search by project
curl "http://localhost:10013/api/search?q=bug&projectId=xxx"
MCP Usage
Ask directly in Claude Code:
Search for previous discussions about NestJS dependency injection
Find sessions from the last week and see what we worked on
Get the full session content about database design
Data Directory Structure
~/memex-data/
├── memex.db # SQLite database
├── vectors/ # LanceDB vector storage
│ └── messages/
└── backups/ # Backup files
└── memex-2025-01-15.db
FAQ
Q: How to trigger initial data import?
A: The service automatically scans ~/.claude/projects/ and imports all sessions on startup. You can also trigger manually via API:
curl -X POST http://localhost:10013/api/backup
Q: Semantic search not working?
A: Ensure:
- Ollama service is running:
ollama serve - Model is downloaded:
ollama pull bge-m3 OLLAMA_APIis configured correctly in.env
Q: How to clear and rebuild index?
A: Delete the data directory and restart the service:
rm -rf ~/memex-data
pnpm start
Q: MCP connection failed?
A: Check:
- Memex service is running at
http://localhost:10013 - MCP configuration path is correct
- Node.js version is >= 18
Development
Project Structure
memex/
├── src/
│ ├── context/ # DDD contexts
│ │ └── brain/ # Core context
│ │ ├── api/ # API layer
│ │ ├── application/ # Application services
│ │ ├── domain/ # Domain models
│ │ └── infrastructure/ # Infrastructure
│ └── main.ts # Application entry
├── web/ # Vue frontend
└── DESIGN.md # Architecture design document
Running Tests
pnpm test
Roadmap
- [x] Phase 0: Data collection and backup
- [x] Phase 1: SQLite + FTS5 full-text search
- [x] Phase 2: Semantic search (Ollama + LanceDB)
- [x] Phase 3: MCP integration
- [x] Web UI
- [x] Phase 4: RAG Q&A
Phase 5: Knowledge distillation(Not planned - RAG already covers most use cases)
Possible Future Enhancements
- Session export (Markdown/PDF)
- Bookmark/tagging system
- Claude Hooks integration (near real-time indexing)
License
MIT
Acknowledgments
Thanks to Claude Code for providing such an excellent development experience.
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。