Easy Memory MCP
by ibb-net
README.md
# Easy Memory MCP
**English** | [中文](README_CN.md)
A lightweight, local-first personal memory center for AI agents, powered by **LanceDB** and the **Model Context Protocol (MCP)**.
Multiple agents (Claude Code, OpenClaw, Cursor, etc.) connect to this single MCP server to store and retrieve long-term memories via semantic vector search — no external database process required.
## Features
- **Semantic Search** — vector similarity search powered by LanceDB, not just keyword matching
- **Zero Infrastructure** — LanceDB is embedded, no separate DB server to run
- **Multi-Agent Shared Memory** — one memory store, many agents
- **Namespace Isolation** — memories are scoped per project or agent to prevent bleed-through
- **Chinese & English** — uses `BAAI/bge-m3` for high-quality bilingual embeddings
- **Local-First & Private** — all data stays on your machine at `~/memory-mcp/`
- **Deduplication** — automatic similarity check on save to avoid redundant memories
- **Memory Consolidation** — merge similar memories to keep the store clean
## Architecture
```
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ Claude Code │ │ OpenClaw │ │ Cursor ... │
└──────┬───────┘ └──────┬──────┘ └──────┬───────┘
│ MCP (stdio/SSE)│ │
└─────────┬─────────┘───────────────┘
│
┌─────────▼──────────┐
│ Easy Memory MCP │
│ (Python + FastMCP) │
├────────────────────┤
│ Memory Manager │ ← dedup / consolidate / decay
│ Embedding Engine │ ← local model or API
│ Namespace Router │ ← multi-project isolation
└─────────┬──────────┘
│
┌─────────▼──────────┐
│ LanceDB │
│ ~/memory-mcp/ │
│ (embedded, local) │
└────────────────────┘
```
## Use Cases
Easy Memory MCP is designed for AI agents that need persistent, searchable memory. Here are some common scenarios:
- **Personal Dev Assistant** — Claude Code remembers your coding preferences, project decisions, and technical context across sessions. No more repeating yourself.
- **Multi-Agent Knowledge Sharing** — Multiple agents (Claude Code, Cursor, custom bots) share one memory store. Knowledge learned by one agent is available to all via namespace isolation.
- **Project Context Persistence** — Architecture decisions, API contracts, and deployment notes survive beyond a single session. Come back weeks later and your agent already knows the project.
- **Feedback Loop** — The agent saves corrections ("don't use `any` in TypeScript") and avoids repeating mistakes in future sessions.
- **Reference Library** — Build a searchable knowledge base of solutions, snippets, and debugging tips discovered during development.
See [Use Cases](docs/use-cases.md) for detailed walkthroughs with code examples.
## Quick Start
### One-Click Install (Recommended)
```bash
git clone https://github.com/ibb-net/easy_memory_mcp.git
cd easy_memory_mcp
bash install.sh
```
The interactive installer handles: package install, Claude Code MCP registration, systemd service setup, and embedding model download.
Non-interactive:
```bash
bash install.sh --install # full install
bash install.sh --download-model # download embedding model
bash install.sh --status # show status
```
### Manual Install
```bash
pip install easy-memory-mcp
```
Or from source:
```bash
git clone https://github.com/ibb-net/easy_memory_mcp.git
cd easy_memory_mcp
pip install -e ".[dev]"
```
### Run
```bash
# stdio transport (default, for Claude Code / Cursor)
python -m easy_memory_mcp
# SSE transport (persistent service, recommended)
python -m easy_memory_mcp --transport sse --port 8135
# Streamable HTTP transport (newest, recommended for remote)
python -m easy_memory_mcp --transport streamable-http --port 8135
```
The SSE/HTTP transports preload the embedding model at startup, so the first tool call responds immediately.
### Register in MCP Clients
**Claude Code** (SSE, recommended — via `claude` CLI):
```bash
claude mcp add memory -s user --transport sse http://localhost:8135/sse
```
**Claude Code** (stdio — via config file `~/.claude.json` or `.mcp.json`):
```json
{
"mcpServers": {
"memory": {
"command": "python",
"args": ["-m", "easy_memory_mcp"],
"env": {
"MEMORY_MCP_PATH": "/home/you/memory-mcp"
}
}
}
}
```
**Cursor / Windsurf** (`.cursor/mcp.json`):
```json
{
"mcpServers": {
"memory": {
"url": "http://localhost:8135/sse"
}
}
}
```
**Remote access** (via HTTPS with reverse proxy):
```json
{
"mcpServers": {
"memory": {
"url": "https://your-domain.com/sse"
}
}
}
```
### Health Check
```bash
curl http://localhost:8135/health
# {"status":"ok","uptime_seconds":123.4,"namespace":"default","storage_path":"/home/you/memory-mcp"}
```
## Agent Prompt Templates
To get the best results, configure your AI agent's system prompt / rules so it automatically retrieves and stores memories. Ready-to-use templates are in the [`prompts/`](prompts/) folder:
### Claude Code
Copy the content from [`prompts/claude-code-memory.md`](prompts/claude-code-memory.md) into your project's `CLAUDE.md` (or `~/.claude/CLAUDE.md` for global effect).
### Cursor
Cursor uses [Rules](https://docs.cursor.com/context/rules) — project-level prompt files that are injected into every conversation.
Copy the `.mdc` file into your project's `.cursor/rules/` directory:
| File | Description |
|------|-------------|
| [`cursor-memory-light.mdc`](prompts/cursor-memory-light.mdc) | Lightweight — search before answering, save when valuable |
| [`cursor-memory-strict.mdc`](prompts/cursor-memory-strict.mdc) | Strict SOP — mandatory search, explicit save conditions |
| [`cursor-memory-light-cn.mdc`](prompts/cursor-memory-light-cn.mdc) | 轻量版(中文) |
| [`cursor-memory-strict-cn.mdc`](prompts/cursor-memory-strict-cn.mdc) | 严格版(中文) |
```bash
# Example: install the light version
mkdir -p .cursor/rules
cp prompts/cursor-memory-light.mdc .cursor/rules/memory-workflow.mdc
```
The `alwaysApply: true` frontmatter ensures the rule is active in every conversation.
### Other Agents
For any agent that supports system prompts, the key instructions are:
1. **Before answering** — call `memory_search(query=<user request>, top_k=5)`
2. **When saving** — call `memory_save(content=..., type=..., tags=[...], importance=...)`
3. **Never save** credentials, one-time info, or unconfirmed assumptions
## MCP Tools
| Tool | Description |
|---|---|
| `memory_save` | Store a new memory with auto-embedding and dedup check |
| `memory_search` | Semantic similarity search with optional type/tag/namespace filters |
| `memory_get` | Retrieve a memory by ID |
| `memory_update` | Update content or tags (re-embeds automatically) |
| `memory_delete` | Remove a memory by ID |
| `memory_list` | List memories with filtering by type, tags, or namespace |
| `memory_consolidate` | Merge similar memories to reduce redundancy |
### Example Usage (from an agent)
```
# Save a memory
memory_save(content="User prefers concise responses without emoji", type="feedback", tags=["style"], namespace="default")
# Search memories
memory_search(query="user communication preferences", top_k=5)
# List all feedback memories
memory_list(type="feedback", limit=20)
```
## Data Model
Each memory record contains:
| Field | Type | Description |
|---|---|---|
| `id` | string | UUID, auto-generated |
| `content` | string | The memory text |
| `type` | string | `user` / `feedback` / `project` / `reference` / `conversation` |
| `tags` | list[string] | Searchable tags |
| `namespace` | string | Project or agent scope (default: `"default"`) |
| `source` | string | Which agent created it (e.g. `"claude-code"`) |
| `importance` | float | 0–1 score, used for ranking and decay |
| `access_count` | int | Tracks how often this memory is retrieved |
| `created_at` | datetime | Creation timestamp |
| `updated_at` | datetime | Last modification timestamp |
| `last_accessed_at` | datetime | Last retrieval timestamp |
## Configuration
All configuration is via environment variables:
| Variable | Default | Description |
|---|---|---|
| `MEMORY_MCP_PATH` | `~/memory-mcp` | Directory for LanceDB data files |
| `MEMORY_MCP_EMBEDDING_MODEL` | `BAAI/bge-m3` | Sentence-transformers model name |
| `MEMORY_MCP_EMBEDDING_DIM` | `1024` | Embedding vector dimension |
| `MEMORY_MCP_DEDUP_THRESHOLD` | `0.95` | Similarity threshold for dedup (0–1) |
| `MEMORY_MCP_NAMESPACE` | `default` | Default namespace for memories |
| `MEMORY_MCP_EMBEDDING_BACKEND` | `local` | `local` or `openai` |
| `OPENAI_API_KEY` | _(unset)_ | Set to use OpenAI embeddings instead of local model |
| `MEMORY_MCP_OPENAI_MODEL` | `text-embedding-3-small` | OpenAI embedding model (if using API) |
| `HF_HUB_OFFLINE` | _(unset)_ | Set to `1` to prevent HuggingFace online checks (recommended for service) |
## Tech Stack
- **[MCP Python SDK](https://github.com/modelcontextprotocol/python-sdk)** — Model Context Protocol server framework
- **[LanceDB](https://lancedb.com/)** — Embedded vector database (no server process)
- **[sentence-transformers](https://www.sbert.net/)** — Local embedding models (default: BGE-M3)
- **[PyArrow](https://arrow.apache.org/docs/python/)** — LanceDB schema and data handling
## Comparison with Alternatives
| Feature | Easy Memory MCP | Official MCP Memory | mcp-memory-service | Mem0 |
|---|---|---|---|---|
| Vector semantic search | Yes | No (keyword only) | Yes | Yes |
| Zero external deps | Yes (embedded DB) | Yes (JSON file) | No (ChromaDB) | No (Qdrant) |
| Chinese support | Yes (BGE-M3) | N/A | No | No |
| Namespace isolation | Yes | No | No | Weak |
| Memory consolidation | Yes | No | Yes | Yes |
| Local-first | Yes | Yes | Yes | Optional |
## Roadmap
- [x] Phase 1 — Core: LanceDB store, embedding engine, 7 MCP tools, tests
- [x] Phase 2 — Enhanced: namespace isolation, dedup, consolidation, health endpoint
- [ ] Phase 3 — Ecosystem: auth & multi-user, Web UI, import/export, importance decay
## Demo
A standalone demo script shows the core API in action — save, search, dedup, update, delete:
```bash
pip install -e ".[dev]"
python examples/demo.py
```
See [`examples/demo.py`](examples/demo.py) for the full source.
## Contributing
Contributions are welcome! See [CONTRIBUTING.md](CONTRIBUTING.md) for:
- Development setup and code style
- How to add new MCP tools or embedding backends
- Commit message conventions and PR guidelines
- Issue reporting guidelines
## License
MIT
This server cannot be deployed
Maintenance
ActivityInactive
ResponsivenessNo recent community issues