io.github.MarcelRoozekrans/longterm-memory

Registre officiel Recherche et web

A fully local MCP server for long-term memory with semantic search

Installation

Ajoutez ceci à la configuration MCP de votre client (Claude Desktop : claude_desktop_config.json ; Cursor : .cursor/mcp.json ; VS Code et les autres utilisent la même forme « mcpServers »).

NPM package longterm-memory-mcp
Claude Code
claude mcp add longterm-memory -- npx -y longterm-memory-mcp@1.6.1
Configuration JSON (Claude Desktop, Cursor, VS Code)
{
    "mcpServers": {
        "longterm-memory": {
            "command": "npx",
            "args": [
                "-y",
                "longterm-memory-mcp@1.6.1"
            ]
        }
    }
}

Documentation

Tirée du README du projet sur GitHub, actualisée chaque semaine. Les liens ouvrent GitHub.

Sommaire
  1. LongtermMemory-MCP
  2. Tools
  3. Quick Start
  4. Configuration
  5. Database Location
  6. Memory Types
  7. Tags & Importance
  8. Decay & Reinforcement
  9. Content Deduplication
  10. Backups
  11. How It Works
  12. Architecture
  13. Benchmarks
  14. Development
  15. Contributing
  16. License

LongtermMemory-MCP

A fully local MCP server that gives AI agents persistent, semantic long-term memory — without any cloud dependencies.

Inspired by mcp-mem0, but runs 100% on your machine:

Featuremcp-mem0This project
StoragePostgreSQL / SupabaseSQLite (Node's built-in node:sqlite)
EmbeddingsOpenAI APILocal transformer (all-MiniLM-L6-v2)
Vector searchCloud vector DBIn-process cosine similarity
LLM dependencyOpenAI / OpenRouter / OllamaNone
SetupDatabase + API keysnpx longterm-memory-mcp

Tools

Core
ToolDescription
save_memoryStore text with auto-generated semantic embedding, tags, importance, and type
search_memoryFind relevant memories using natural language queries (cosine similarity)
update_memoryModify an existing memory's content, metadata, tags, importance, or type
delete_memoryRemove a specific memory by ID
delete_all_memoriesWipe all memories (irreversible)
get_all_memoriesList all stored memories (paginated)
memory_statsGet count and database location
ToolDescription
search_by_typeFilter memories by category (general, fact, preference, conversation, task, ephemeral)
search_by_tagsFind memories matching any of the provided tags
search_by_date_rangeFind memories created within a specific date range (ISO format)
Maintenance
ToolDescription
create_backupManually trigger a database backup with JSON export

Quick Start

Install via the Claude Code marketplace — this sets up both the MCP server and a companion skill that teaches Claude how to use memory effectively:

/plugin marketplace add MarcelRoozekrans/LongtermMemory-MCP
/plugin install longterm-memory@longterm-memory-marketplace

This automatically:

  • Configures the MCP server (no manual JSON editing)
  • Installs the long-term-memory skill (Claude learns to recall context at session start, save insights after tasks, and deduplicate memories)
Use with npx (no install needed)
npx longterm-memory-mcp
Or install globally
npm install -g longterm-memory-mcp
longterm-memory-mcp
Or from source
git clone https://github.com/MarcelRoozekrans/LongtermMemory-MCP.git
cd LongtermMemory-MCP
npm install && npm run build
npm start

Configuration

Claude Code

If you installed via the plugin marketplace, the MCP server is already configured. For manual setup, add to your MCP settings (~/.claude/settings.json or project .claude/settings.json):

{
  "mcpServers": {
    "longterm-memory": {
      "command": "npx",
      "args": ["-y", "longterm-memory-mcp"]
    }
  }
}
Claude Desktop

Add to claude_desktop_config.json:

{
  "mcpServers": {
    "longterm-memory": {
      "command": "npx",
      "args": ["-y", "longterm-memory-mcp"]
    }
  }
}
Agent Instructions

The repo includes agent instructions that teach AI agents how to use memory effectively (automatic recall, save patterns, deduplication):

FilePurpose
skills/long-term-memory/SKILL.mdSelf-contained skill — auto-loaded by Claude Code plugin, can be referenced from any MCP client

Database Location

By default, memories are stored in a shared, user-scoped location:

~/.longterm-memory-mcp/memories.db

This means every project and every MCP client shares the same memory pool — you save a memory in one project and it's available everywhere.

Several sessions can use the same database at once. Each server process reads and writes the shared file directly (SQLite in WAL mode), so a memory saved in one session is visible to every other session right away, and no session overwrites what another saved. Requires Node.js 22.13 or later.

Databases from older releases open unchanged. A database from v1.0–1.3, which has no schema_meta table, is migrated in place with all its memories kept; a copy named memories.db.pre-migration-<timestamp>.bak is written next to it first.

Upgrading from 1.4 or earlier: stop every running session that uses the old version before starting one with the new version. Older releases keep the whole database in memory and rewrite the file on each save, so an old process left running would overwrite what new sessions saved.

Per-project database

To isolate memories for a specific project, set the MEMORY_DB_PATH environment variable:

{
  "mcpServers": {
    "longterm-memory": {
      "command": "npx",
      "args": ["-y", "longterm-memory-mcp"],
      "env": {
        "MEMORY_DB_PATH": "/path/to/project/memories.db"
      }
    }
  }
}

Memory Types

Each memory has a memory_type that determines how it's categorized and how quickly it decays:

TypeDescriptionDecay half-life
generalDefault catch-all60 days
factVerified information120 days
preferenceUser/project preferences90 days
conversationConversation context45 days
taskTask-related notes30 days
ephemeralShort-lived context10 days

Tags & Importance

  • Tags: Categorize memories with string tags (e.g. ["auth", "backend"]). Search with search_by_tags.
  • Importance (1–10): Controls how resistant a memory is to decay. Default is 5. Higher importance decays more slowly.
  • Protected tags: Memories tagged with core, identity, or pinned skip decay entirely.

Decay & Reinforcement

Memories decay over time to keep the store relevant:

  • Decay: Each memory type has a half-life (see table above). Importance decreases exponentially based on time since last access, with a floor that prevents full deletion.
  • Reinforcement: Every time a memory is accessed via search, its importance increases by +0.1 (up to a max of 10). Frequently accessed memories stay important.
  • Lazy evaluation: Decay is calculated on access, not on a timer — no background processes needed.

Content Deduplication

Memory content is hashed (SHA-256) on save. If identical content already exists, the save is rejected with a reference to the existing memory ID. This prevents duplicate entries automatically.

Backups

Backups are managed automatically and can also be triggered manually via the create_backup tool.

  • Auto-backup: Triggers every 24 hours or when the memory count reaches a multiple of 100.
  • Retention: The last 10 backups are kept; older ones are pruned automatically.
  • Format: Each backup is a timestamped directory containing a consistent snapshot of the SQLite database and a JSON export of all memories.
  • Location: ~/.longterm-memory-mcp/backups/ by default, or set MEMORY_BACKUP_PATH:
{
  "mcpServers": {
    "longterm-memory": {
      "command": "npx",
      "args": ["-y", "longterm-memory-mcp"],
      "env": {
        "MEMORY_BACKUP_PATH": "/path/to/backups"
      }
    }
  }
}

How It Works

  1. Save: Text is embedded locally using all-MiniLM-L6-v2 (384-dim vectors) and stored in SQLite alongside the raw content, metadata, tags, importance, and type. Content is deduplicated via SHA-256 hash.
  2. Search: Your query is embedded with the same model, then compared against every stored memory using cosine similarity. Results above the threshold are returned ranked by relevance. Accessed memories are reinforced automatically.
  3. Decay: Over time, unused memories lose importance based on their type's half-life. Protected and frequently accessed memories resist decay.
  4. Persist: Every change is written straight to the SQLite database on disk, so concurrent sessions share one consistent store. No background processes, no servers to maintain.

The embedding model (~30MB quantized) is downloaded once on first use and cached locally.

Architecture

src/                           — MCP server source
  index.ts                     — Entry point (stdio transport, DB/backup path resolution)
  server.ts                    — MCP server factory + 11 tool definitions
  memory-store.ts              — SQLite storage + vector search + decay integration
  embeddings.ts                — Local embedding engine (Xenova/transformers)
  decay.ts                     — DecayEngine (lazy decay, reinforcement, protected tags)
  backup.ts                    — BackupManager (auto-backup, JSON export, pruning)
  types.ts                     — TypeScript interfaces (Memory, Embedder, config types)

skills/                        — Claude Code plugin skill
  long-term-memory/SKILL.md    — Self-contained agent instructions + skill

.claude-plugin/                — Plugin & marketplace metadata
  plugin.json                  — Plugin manifest
  marketplace.json             — Marketplace manifest
.mcp.json                      — Auto-configures MCP server on plugin install
.vscode/mcp.json               — VS Code MCP server config

Benchmarks

Run with npm run bench. Results from an in-memory store using mock embeddings (isolates store/SQLite performance from model latency):

Cosine Similarity
OperationThroughputNotes
Single computation (384-dim)~4.2M ops/sMatches real embedding dimensions
128 dimensions~8.6M ops/s
768 dimensions~2.4M ops/s
1536 dimensions~1.3M ops/sScales linearly with dimensions
Memory Store Operations
OperationThroughputNotes
Save (single)~1,120 ops/sIncludes embed + SQLite insert + dedup check
Save 100 batch~18 ops/s~55ms per batch of 100
Save 1000 batch~0.3 ops/s~3.1s per batch of 1000
Update (content, re-embed)~155 ops/s
Update (metadata only)~344 ops/s2.2x faster than content update
Delete~469 ops/s
Search (semantic, at scale)
Store SizeOperationNotes
10 memoriessearch (limit=5)Full scan + cosine similarity per memory
100 memoriessearch (limit=5)
500 memoriessearch (limit=5)
1000 memoriessearch (limit=5)Linear scan — scales with store size
Decay Engine
OperationThroughput
Single decay computation~21M ops/s
Single reinforcement~25.7M ops/s
shouldProtect (tag check)~22M ops/s

Development

npm install          # Install dependencies
npm run build        # Compile TypeScript
npm test             # Run all tests
npm run bench        # Run benchmarks
npm run test:watch   # Watch mode
npm run test:coverage # Coverage report

Contributing

This project uses Conventional Commits and semantic-release for automated versioning.

Commit message format
<type>(<optional scope>): <description>

[optional body]

[optional footer(s)]
TypePurposeVersion bump
featNew featureMinor (0.x.0)
fixBug fixPatch (0.0.x)
docsDocumentation onlyNo release
styleFormatting, whitespaceNo release
refactorCode restructuringNo release
testAdding/updating testsNo release
choreMaintenance, depsNo release
ciCI/CD changesNo release

Breaking changes: Add ! after the type (e.g., feat!: remove deprecated API) or include a BREAKING CHANGE: footer. This triggers a major version bump.

Examples
git commit -m "feat: add memory tagging support"
git commit -m "fix: handle empty search query gracefully"
git commit -m "feat!: change default database location"
git commit -m "docs: update configuration examples"

Commit messages are validated locally via commitlint + husky git hooks. Non-conforming messages will be rejected.

Releases

Releases are fully automated. When commits are pushed to main:

  1. semantic-release analyzes commit messages
  2. Determines the next version (major / minor / patch)
  3. Generates release notes from commits
  4. Updates CHANGELOG.md
  5. Publishes to npm
  6. Creates a GitHub Release

No manual version bumps or tags needed.

Dependency Updates

Dependencies are managed automatically by Renovate. Patch and minor devDependency updates are auto-merged after CI passes. Major updates create PRs for manual review.

License

MIT

Questions fréquentes

Qu'est-ce que io.github.MarcelRoozekrans/longterm-memory ?

A fully local MCP server for long-term memory with semantic search

Comment installer io.github.MarcelRoozekrans/longterm-memory ?

Il s'exécute sur votre machine. Dans Claude Code : claude mcp add longterm-memory -- npx -y longterm-memory-mcp@1.6.1. Pour les autres clients, collez la configuration JSON de cette page dans leurs réglages MCP.

Faut-il une clé API pour io.github.MarcelRoozekrans/longterm-memory ?

Son entrée au registre n'indique aucune clé ni secret obligatoire. Certaines fonctions peuvent tout de même demander un compte auprès du service auquel il se connecte.

io.github.MarcelRoozekrans/longterm-memory est-il open source ?

Oui. Son code est sur GitHub sous licence MIT.

Qui maintient io.github.MarcelRoozekrans/longterm-memory ?

Il est publié par MarcelRoozekrans. AI.tn le référence sans le maintenir ni le recommander.

Issu du registre MCP officiel. Être listé n'est pas une recommandation : vérifiez le code et les permissions d'un serveur avant de lui donner accès à vos données.