# Longterm Memory

> Longterm Memory is an open-source MCP server for knowledge and memory. Local long-term memory for agents with semantic search, decay and secret filtering. It runs locally on your machine and is started by your AI client.

- **Kind:** MCP server
- **Pricing:** Open source
- **Platforms:** CLI, self-hosted, macOS, Windows, Linux
- **Repository:** https://github.com/marcelroozekrans/longtermmemory-mcp
- **MCP Registry name:** io.github.MarcelRoozekrans/longterm-memory
- **Categories:** [knowledge and memory](https://ai-powered.com/categories/knowledge-and-memory)
- **Listing updated:** 2026-11-18

## About

This server stores agent memories in a SQLite file on your machine and embeds them with a local all-MiniLM-L6-v2 transformer, so there are no API keys, cloud database or LLM dependency. Search is in-process cosine similarity, and the default database at ~/.longterm-memory-mcp/memories.db is shared by every project and client, though MEMORY_DB_PATH gives a project its own. Several sessions can use it at once through SQLite's WAL mode, and it needs Node.js 22.13 or later.

Each memory has a type (general, fact, preference, conversation, task, ephemeral) with its own decay half-life from 10 to 120 days, plus tags and an importance from 1 to 10. Decay is computed lazily on access, searching a memory raises its importance slightly, and the tags core, identity and pinned exempt it from decay. Identical content is rejected through a SHA-256 hash.

A content guard strips marked spans and refuses text that looks like a secret, such as private keys, GitHub tokens, sk- API keys, AWS key IDs, JWTs and Slack tokens, naming the pattern but never the value. A Claude Code plugin adds an automatic recall hook and a skill for when to save and recall.

## Features

- **Fully local:** SQLite storage and local embeddings with no cloud calls.
- **Typed memories with decay:** Half-lives from 10 to 120 days, with importance reinforcement.
- **Flexible search:** By meaning, type, tags or date range.
- **Deduplication:** Identical content is rejected by hash.
- **Secret rejection:** Refuses content that looks like keys or tokens.
- **Backups:** Manual database backup with JSON export.

## Good for

- Let an agent remember project decisions across sessions
- Keep personal preferences available in every project
- Recall earlier context at session start
- Keep memory private with no cloud service

## Install

### Claude Code (Terminal)

```sh
claude mcp add longterm-memory -- npx -y longterm-memory-mcp
```

### Claude Desktop (claude_desktop_config.json)

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

### Cursor (~/.cursor/mcp.json)

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

### VS Code (.vscode/mcp.json)

```json
{
  "servers": {
    "longterm-memory": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "-y",
        "longterm-memory-mcp"
      ]
    }
  }
}
```

### Windsurf (~/.codeium/windsurf/mcp_config.json)

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

### Other clients (your client's MCP settings (most use this shape))

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

## Tools

- `save_memory`: Store text with an embedding, tags, importance and type.
- `search_memory`: Find relevant memories using a natural-language query.
- `update_memory`: Modify an existing memory's content or metadata.
- `delete_memory`: Remove a memory by ID.
- `delete_all_memories`: Wipe all memories irreversibly.
- `get_all_memories`: List stored memories with pagination.
- `memory_stats`: Show memory count and database location.
- `search_by_type`: Filter memories by category.
- `search_by_tags`: Find memories matching any given tag.
- `search_by_date_range`: Find memories created within a date range.
- `create_backup`: Trigger a database backup with JSON export.

## FAQ

### Does it send data to the cloud?

No, storage and embeddings run entirely on your machine.

### Where are memories stored?

In ~/.longterm-memory-mcp/memories.db by default, or the path in MEMORY_DB_PATH.

### What Node version is needed?

Node.js 22.13 or later.

### Can it store API keys?

No, the content guard rejects text matching common secret patterns.

### Is Longterm Memory free?

Yes. Longterm Memory is open source, so you can use and self-host it for free.

### How do I add Longterm Memory to Claude Code?

Run this command in your terminal: claude mcp add longterm-memory -- npx -y longterm-memory-mcp

### What are the best alternatives to Longterm Memory?

The closest alternatives to Longterm Memory are Codebase Memory, XERJ, Claude Code Ultimate Guide, Nautilus Compass Memory and NeuroStack.

## Where this comes from

- Description: written from the project's README.
- Install steps: from the official MCP Registry entry.

## Alternatives

- [Codebase Memory](https://ai-powered.com/mcp/codebase-memory): Codebase Memory is an open-source MCP server for knowledge and memory.
- [XERJ](https://ai-powered.com/mcp/xerj): XERJ is an open-source MCP server for knowledge and memory.
- [Claude Code Ultimate Guide](https://ai-powered.com/mcp/claude-code-ultimate-guide): Claude Code Ultimate Guide is an open-source MCP server for ai models and llm tooling.
- [Nautilus Compass Memory](https://ai-powered.com/mcp/nautilus-compass-memory): Nautilus Compass Memory is an open-source MCP server for knowledge and memory.
- [NeuroStack](https://ai-powered.com/mcp/neurostack): NeuroStack is a freemium MCP server for knowledge and memory.
- [note1](https://ai-powered.com/mcp/note1): note1 is an MCP server for productivity.
- [Digitalnz](https://ai-powered.com/mcp/digitalnz): Digitalnz is a freemium MCP server for knowledge and memory.
- [Notion_connect](https://ai-powered.com/mcp/notion-connect): Notion_connect is a freemium MCP server for knowledge and memory.

---
Source: https://ai-powered.com/mcp/longterm-memory
