memory-v2
# Memory v2.1
[](https://github.com/DonParalon85/memory-v.2-alpha/actions/workflows/ci.yml)
[](https://github.com/DonParalon85/memory-v.2-alpha/releases)
[](LICENSE)
[](https://www.python.org/)
**Local-first long-term memory for AI agents and long-running projects.**
Memory v2.1 stores projects, conversation branches, messages and durable facts in
a single SQLite database. It is built for people who want their agent memory to
stay on their own machine: no cloud account, no vendor lock-in, no telemetry.
> **Status:** `2.1.0-alpha.2`. The core API, MCP server, web UI and offline
> installers are working and tested. Expect rough edges; back up your database.
## Why
Long agent sessions get lost when a workspace is recreated, a model is switched,
or a chat is closed. Memory v2.1 keeps the whole branch, not just a summary:
- one project can contain dozens of branches;
- a branch can be restored with one request;
- durable facts survive across sessions;
- full-text search covers both facts and messages;
- the database is a plain SQLite file you can copy and inspect.
## Features
- **Projects → branches → messages.** One project, many conversations, shared
logic and search.
- **Durable memories.** Facts, decisions, constraints and preferences with
importance, confidence, status and supersede links.
- **Message provenance.** Every message keeps its original source fingerprint;
edits create revisions instead of silently changing the archive. Soft-deleted
messages stay recoverable and are excluded from search.
- **Large branches.** Paginated message loading, load-earlier, in-branch search
and jump-to-message; role editing and edit history are built in.
- **Full-text search.** SQLite FTS5 plus Russian morphology (`pymorphy3`);
search memories and messages, optionally inside one project.
- **Idempotent archive.** Re-sending the same branch appends only new messages;
duplicates are skipped.
- **Web UI.** Projects, branches, messages, memory cards, search, triggers,
settings and first-run onboarding. No Node.js build step.
- **MCP server.** Seven tools for Claude Desktop, Claude Code, Cursor, Cline,
Continue, Windsurf, Zed and other MCP clients.
- **Browser extension.** Save selected text or the current page from
Chrome/Edge/Chromium and Firefox (experimental): context menu, `mem` + Tab, or
the toolbar popup.
- **Offline installers.** Windows and Linux packages with Python 3.12 and all
wheels included. A visible status window/stage progress shows what is
happening; no internet is needed during installation.
- **Local-first.** SQLite file, loopback-only by default, no cloud services.
- **Backups and diagnostics.** One-click SQLite backup API, JSON project export,
log rotation and `/diagnostics`.
## How it compares
Memory v2 is not a vector store and not an agent framework. It is a small,
inspectable archive that an agent can query over MCP.
| | Memory v2 | Hosted memory services (mem0, Zep Cloud) | Agent frameworks (Letta) | Markdown notes (basic-memory) | Plain files |
|---|---|---|---|---|---|
| Data location | one SQLite file on your disk | vendor cloud | your server | Markdown files | anywhere |
| Account required | no | yes | no | no | no |
| MCP server | built in (7 tools) | usually separate | yes | yes | no |
| Editable history | revisions + soft delete | limited | limited | git | manual |
| Search | FTS5 + morphology | embeddings | embeddings | Markdown/grep | none |
| Works offline | yes, installers included | no | partial | no | yes |
| License | MIT | mixed | Apache-2.0 | MIT | — |
Details for the other projects change quickly — check their docs. The point here
is the trade-off: hosted services give you convenience and sync, Memory v2 gives
you a file you own, no account, and no network dependency.
## Install
### Windows (recommended: offline installer)
1. Download `MemoryV2-v2.1.0-alpha.2-Windows-x64.zip` from **Releases**.
2. Extract it to any folder.
3. Run `windows\install-memory.bat`.
4. The app installs per user to `%LOCALAPPDATA%\MemoryV2`, starts at logon and
opens `http://127.0.0.1:8002/ui/`.
No administrator rights and no internet connection are required. Windows may
show a SmartScreen warning because the installer is not code-signed yet.
Details: [`docs/installers.md`](docs/installers.md).
### Linux (recommended: offline installer)
1. Download `MemoryV2-v2.1.0-alpha.2-Linux-x64.zip` from **Releases**.
2. Extract it.
3. Run:
```sh
bash linux/install.sh
```
The installer puts the app in `~/.local/share/memoryv2`, creates a user systemd
service (or a nohup fallback), and starts it on
`http://127.0.0.1:8002/ui/`.
Python 3.12 is required. The installer can install it via the system package
manager if it is missing; the Python packages themselves are bundled offline
(`cp312`, x86_64).
### Docker (from source)
```sh
cp .env.example .env
mkdir -p data
docker compose up -d --build
```
Open `http://127.0.0.1:8002/ui/`.
### Manual native install (development)
```sh
python3.12 -m venv .venv
. .venv/bin/activate
pip install -r api/requirements.txt
pip install -r mcp/requirements.txt
cp .env.example .env
python api/init_db.py
python start_memory.py
```
See [`README-WINDOWS.md`](README-WINDOWS.md) for the Windows native path.
## First run
- The API listens on `127.0.0.1:8002` by default.
- If `MEMORY_API_TOKEN` is empty, only loopback clients are accepted.
- The onboarding wizard offers language (RU/EN), an optional AI agent, and
browser-extension installation.
- The demo seed is optional and fictional:
```sh
MEMORY_API=http://127.0.0.1:8002 python3 examples/seed_demo.py
```
## Browser extension
The extension is included in both offline installers and in the app's first-run
wizard. Standalone packages are attached to each release:
```text
MemoryV2-v2.1.0-alpha.2-browser-extension.zip # Chrome/Edge/Chromium
MemoryV2-v2.1.0-alpha.2-firefox-extension.zip # Firefox
```
Chrome/Edge/Chromium:
1. Open `chrome://extensions` (Edge: `edge://extensions`).
2. Enable **Developer mode**.
3. Choose **Load unpacked** and select the `memory-v2-extension` folder.
4. Pin the icon and check the API URL in the extension settings.
Firefox (experimental):
1. Unpack the Firefox ZIP.
2. Open `about:debugging#/runtime/this-firefox`.
3. Choose **Load Temporary Add-on** and select `manifest.json`.
4. For a permanent install, submit the ZIP to `addons.mozilla.org` (AMO);
Firefox does not install unsigned XPI permanently.
5. If Firefox asks for access to `127.0.0.1:8002`, allow it.
Usage:
- select text → right click → **Memory v2.1** → project;
- type `mem`, press Tab, then `проект Home: text` or
`save this page to project Home`;
- click the toolbar icon for a popup with selection/page capture.
> A search query typed into Google/Yandex goes to the search engine, not to
> Memory. Use the context menu, `mem` + Tab, or the popup instead.
> Firefox is experimental: use the separate Firefox ZIP; permanent install requires AMO signing.
See [`extension/README.md`](extension/README.md).
## MCP
The MCP server lives in `mcp/`. It speaks stdio and uses the Memory HTTP API; it
never opens the SQLite file directly.
Published on PyPI as [`memory-v2-mcp`](https://pypi.org/project/memory-v2-mcp/):
```sh
uvx memory-v2-mcp # run without installing
pip install memory-v2-mcp # or install the console script
```
From the source tree:
```sh
python3.12 -m venv .venv-mcp
. .venv-mcp/bin/activate
pip install -r mcp/requirements.txt
python mcp/server.py
```
Tools:
| Tool | Purpose |
|---|---|
| `memory_health` | Check API availability |
| `memory_list_projects` | List projects |
| `memory_project_context` | Restore a project and its branches |
| `memory_search` | Search memories and messages |
| `memory_archive_conversation` | Archive a branch idempotently |
| `memory_upsert` | Store a fact, decision, constraint or preference |
| `memory_deprecate` | Retire an old memory, optionally with a replacement |
Client configs (Claude Desktop, Claude Code, Cursor, Docker-only) are in
[`mcp/README.md`](mcp/README.md) and `mcp/examples/`.
## API at a glance
```http
GET /health
GET /projects
POST /projects
GET /projects/{id}/context
POST /conversations/archive
GET /memories/search?q=...&include_messages=true
POST /memories/upsert
POST /memories/{id}/deprecate
POST /capture
GET /settings
PUT /settings
POST /triggers/preview
POST /triggers/apply
GET /diagnostics
```
Interactive API reference: `http://127.0.0.1:8002/docs`.
Archive requests are idempotent; use a stable `external_id`:
```json
{
"project_id": 1,
"title": "Demo / FastAPI async session debugging",
"source": "demo",
"external_id": "demo:fastapi:async-session:001",
"messages": [
{"role": "user", "content": "..."},
{"role": "assistant", "content": "..."}
]
}
```
## Data model
| Table | Purpose |
|---|---|
| `projects` | Shared project container |
| `conversations` | A dialog branch |
| `messages` | User/assistant messages |
| `memories` | Durable facts, decisions, constraints, preferences |
| `events` | Reserved for future timeline events |
| `settings` | Language, AI agent, onboarding, triggers, extension status |
SQLite FTS5 indexes (`memories_fts_norm`, `messages_fts`) are kept in sync by
triggers. The schema is in [`migrations/schema.sql`](migrations/schema.sql).
## Configuration
| Variable | Default | Meaning |
|---|---|---|
| `MEMORY_DB` | `data/memory_v2.db` | SQLite database path |
| `MEMORY_SCHEMA` | `migrations/schema.sql` | Schema for first init |
| `MEMORY_HOST` | `127.0.0.1` | Listen address |
| `MEMORY_PORT` | `8002` | Listen port |
| `MEMORY_API_TOKEN` | empty | Bearer token; empty means loopback-only |
| `MEMORY_TRUST_BRIDGE` | empty | Set to `1` only for a loopback-published Docker port |
| `MEMORY_LANGUAGE` | `ru` | Initial UI language (`ru`/`en`) |
| `MEMORY_LOG_DIR` | `logs` | Log directory |
If you expose the API to a LAN, set `MEMORY_API_TOKEN` and use a reverse proxy
with HTTPS. Never expose an unauthenticated instance to the internet.
## Development
```sh
python3.12 -m venv .venv
. .venv/bin/activate
pip install -r api/requirements.txt
pip install -r mcp/requirements.txt
sh scripts/ci_integration.sh
```
The integration script creates a clean database, starts the API on
`127.0.0.1:8002`, seeds the fictional demo project and runs the 13-check MCP
stdio test. The GitHub Actions workflow runs the same script on Python 3.12.
Repository layout:
```text
api/ FastAPI application, auth, search, archive, capture, settings
mcp/ MCP stdio server, HTTP client, 13-check smoke test
web/ Static UI (HTML/CSS/JS, no build step)
extension/ Chrome/Edge MV3 extension
connectors/ OpenCode sync (Windows/Linux) and generic import
migrations/ SQLite schema and notes
install/ Docker/venv developer installers
scripts/ CI, backup, search and health helpers
docs/ Architecture, testing, integrations, installers
examples/ Fictional demo seed
```
## Backup
The database is the source of truth. Use the SQLite backup API while the API is
running, or copy the file while it is stopped.
```sh
python3 - <<'PY'
import sqlite3
src = sqlite3.connect("data/memory_v2.db")
dst = sqlite3.connect("data/backup.db")
src.backup(dst)
dst.close()
src.close()
PY
```
## Security
- Loopback-only by default; empty token means non-local clients get `401`.
- Optional bearer token for LAN/reverse-proxy deployments.
- Connectors redact common token patterns before archiving, but this is not a
guarantee. Do not put secrets into prompts or conversation text.
- Keep backups and restrict file permissions.
## Roadmap
- [x] Projects, branches, messages, durable memories.
- [x] FTS5 + Russian morphology.
- [x] Idempotent archive.
- [x] Web UI with manual CRUD, triggers, settings and onboarding.
- [x] MCP server for agent integrations.
- [x] Chrome/Edge extension.
- [x] Offline Windows and Linux installers.
- [x] Firefox extension (experimental; temporary load or AMO signing).
- [ ] Importers for ChatGPT/Claude/Markdown exports.
- [ ] Alembic migrations and schema version history.
- [ ] Code-signed native Windows `.exe` (the current installer is unsigned).
## License
MIT. See [`LICENSE`](LICENSE). The license can be switched to Apache-2.0 before
a stable release.
TDQS
Scored across 7 tools
Each tool has a clearly distinct target: health check, project listing, project context restoration, search, conversation archiving, memory upsert, and deprecation. Although project_context and search both retrieve information, their boundaries are clear because one restores a full project snapshot and the other performs targeted full-text lookup.
All tools share the memory_ prefix, and most use predictable verb-based names such as memory_search, memory_upsert, and memory_deprecate. Minor deviations are memory_health and memory_project_context, which are noun phrases rather than verb_noun forms, but the set remains readable and consistent overall.
Seven tools is well-scoped for a memory management server, with each tool covering a distinct operational need. There is no obvious filler or redundant surface area.
The set covers the core memory lifecycle: health, project listing, context restoration, search, conversation archiving, upsert, and deprecation. Minor gaps exist, such as explicit project creation/update or hard deletion/get-by-id, but these are not likely to block typical agent workflows.