Skip to main content

主动式记忆伙伴

Project description

MEMOS — Active Memory System for AI Coding Assistants

Python License Version

📖 中文文档

MEMOS is a lightweight RAG engine designed for AI coding assistants. It provides cross-session memory — remembering technical decisions, bug fixes, user preferences, and code conventions from past conversations. Built on ChromaDB + bge-large-zh-v1.5 with a built-in MCP server.

Features

  • 🧠 Cross-Session Memory — Captures knowledge from conversations, retrieves it across sessions
  • 🔌 MCP Server — 12 tools for AI assistant integration (Claude Code, etc.)
  • 🔍 Hybrid Search — Vector similarity (1024-dim) × BM25 keyword scoring, time-decay ranking
  • 📊 Web Dashboard — Browse, search, manage memories; visual configuration editor
  • 🏗️ 4 Pipelines — AI-suggested + direct-write + auto-harvest + manual curation
  • 🗂️ Multi-Project — Scoped by working directory, contexts stay separate
  • ⚡ Lightweight — Local-only, single process, no external services

Prerequisites

  • Python 3.12+Download
  • pip — included with Python (verify: python --version)

Create and activate a virtual environment (recommended):

# Windows
python -m venv venv
venv\Scripts\activate

# Linux / macOS
python3 -m venv venv
source venv/bin/activate

Quick Start

pip install memomate
memos init --force
memos dashboard

Open http://127.0.0.1:8000

Windows: If model download stalls, set $env:HF_ENDPOINT = "https://hf-mirror.com" before memos init.

Claude Code Integration

MEMOS provides two ways to connect with Claude Code.

Option 1: Hook (recommended)

Automatically reads and writes memories during conversations:

memos hook install

Option 2: Manual MCP registration

Register the MCP server in your project's .mcp.json:

{
  "mcpServers": {
    "memos": {
      "command": "python",
      "args": ["-m", "memos.server"],
      "env": {}
    }
  }
}

Or via Claude Code CLI:

claude mcp add --scope project memos -- python -m memos.server

Why MEMOS?

Existing memory solutions for AI coding assistants typically:

  • ❌ Store flat text without semantic search
  • ❌ Require external services (PostgreSQL, Redis, cloud APIs)
  • ❌ Lack cross-project isolation
  • ❌ Don't handle time-based memory decay

MEMOS addresses these with a self-contained, local-first architecture designed specifically for the AI-assisted coding workflow.

Architecture

graph LR
    subgraph AI Assistant
        A[Claude Code]
    end
    subgraph MEMOS
        B[MCP Server<br/>12 tools]
        C[Engine<br/>Retrieval + Extraction]
        D[Vector Store<br/>ChromaDB]
        E[Embedding Model<br/>bge 1024-dim]
        F[Web Dashboard<br/>FastAPI + Jinja2]
        G[Hybrid Search<br/>BM25 + Vector]
    end
    A <-->|stdio JSON-RPC| B
    B --> C
    C --> D & E & G
    F --> C

Project Structure

memos/
├── src/memos/
│   ├── config/      Pydantic models, loading chain, prompts
│   ├── storage/     Vector store abstraction (ChromaDB)
│   ├── engine/      Core: memory CRUD, extraction, review, BM25
│   ├── server/      MCP server (12 tools, FastMCP stdio)
│   ├── web/         FastAPI + Jinja2 dashboard
│   ├── cli/         argparse CLI (15+ commands)
│   ├── features/    Backup, daily review, notifications, wizard
│   └── hooks/       Claude Code hook scripts (prompt/stop)
├── memdb/           ChromaDB persistent data
├── model/           Local embedding models (~1.3GB)
└── etc/             Configuration files + i18n locales

MCP Tools (for AI Assistants)

Tool Pipeline Description
remember(text, metadata) A Buffer → LLM extraction
save_knowledge(text, type) B Direct write to store
recall(query, top_k, ...) Semantic + hybrid search
list_memories(type, limit) Paginate project memories
create_todo(content, priority, due_date) Create an action item
list_todos(status, limit) List pending action items
update_todo(id, status) Change todo status
delete_memory(memory_id) Delete by ID
update_memory(id, text, meta) Update content/metadata
force_extract() A Trigger immediate extraction
set_project_id(pid) Switch project scope
log_complete_turn(user, asst) A Log a conversation round

CLI Commands

Command Description
init First-time setup wizard
dashboard Launch web UI
server Start MCP server (stdio)
status View system health
doctor Diagnose and troubleshoot
config show / set / validate Manage configuration
export Export memories to JSONL
import Import from JSONL
backup / restore Full database backup
hook install / uninstall / status Claude Code hook management
auth regen Regenerate dashboard token
vacuum Reclaim deleted document space
reindex Rebuild BM25 index

Configuration

All settings in etc/config.json. Key sections:

{
  "llm": {
    "endpoints": [
      {"name": "default", "api_base": "http://localhost:11434/v1"}
    ],
    "active": "default"
  },
  "model": {"name": "bge-large-zh-v1.5", "vector_dim": 1024},
  "memory": {"decay_lambda": 0.02, "default_top_k": 5},
  "suggestion": {"active_suggestion_threshold": 0.65}
}

Override any field via MEMOS_{SECTION}_{FIELD} environment variables.

Requirements

  • Python 3.12+
  • ~2GB disk (bge-large-zh-v1.5 model ~1.3GB)
  • Windows / Linux / macOS

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

memomate-0.4.9.tar.gz (368.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

memomate-0.4.9-py3-none-any.whl (280.2 kB view details)

Uploaded Python 3

File details

Details for the file memomate-0.4.9.tar.gz.

File metadata

  • Download URL: memomate-0.4.9.tar.gz
  • Upload date:
  • Size: 368.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for memomate-0.4.9.tar.gz
Algorithm Hash digest
SHA256 b476ade5c7db9435182076599bad36089f33c960c0e622b2dac27d0c50b6d7b8
MD5 c9a156317d2c1a428393213708926745
BLAKE2b-256 c5a693782599a5e06586eb5a38f78f13001dd1f27e3fccfff3f9942c03f821bb

See more details on using hashes here.

File details

Details for the file memomate-0.4.9-py3-none-any.whl.

File metadata

  • Download URL: memomate-0.4.9-py3-none-any.whl
  • Upload date:
  • Size: 280.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for memomate-0.4.9-py3-none-any.whl
Algorithm Hash digest
SHA256 a93acd02117bf798ce8bc691dd674c2dffbc570875ae5a7e69ded9b0fee8f71e
MD5 ff889c0c6fb2cd681fd41b505a482c7c
BLAKE2b-256 1b875908cacb907ce317d5ecf17ba38c582b675b4151fc9eb0086621a0e278b9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page