# longmem [Health: Active]

**Category:** 🧠 Knowledge & Memory  
**Repository:** https://github.com/marerem/longmem  
**GitHub Stars:** 1  
**Views:** 0  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/longmem

## Description
Persistent cross-project memory for Cursor and Claude Code using local semantic search.

## Tools
Capabilities this server exposes over MCP:

- **search_similar**
- **keyword_match**
- **confirm_solution**

## Claude Desktop Quick Installation
No generated config for this server: it installs through its own setup steps.

The project's own setup steps (from https://github.com/marerem/longmem), copied verbatim. Follow them in order; they are not an mcpServers config.

1. Install:

```sh
pipx install longmem
```

2. Install:

```sh
git clone https://github.com/marerem/longmem
```

## Documentation

## What longmem MCP server does

The longmem MCP server stores solved problems and their solutions so coding assistants can retrieve them in later sessions or different repositories. It is designed for Cursor and Claude Code, with a workflow that searches existing knowledge before the assistant reasons from scratch and records a solution after the user confirms that it works.

Entries can include a project, category, tags, edge cases, and solution text. A `shared` project value can hold facts intended to surface across repositories. Project-specific information can be added later with `enrich_solution`.

## How it works

The longmem MCP server runs when the IDE starts it; it does not require a background daemon. Searches first narrow candidates by category, then combine embedding-based similarity with exact keyword matches from SQLite FTS5. Embeddings use a local Ollama model by default, with OpenAI available as an alternative. Results are merged and ranked, and exact-text hits are identified with a `keyword_match` flag.

The default similarity threshold is 0.85. A result at or above that level is intended to provide a cached solution, while lower-scoring searches leave the assistant to solve the issue normally. The default duplicate threshold is 0.95, which helps prevent near-identical entries from being saved.

Rules installed for each supported IDE direct the assistant to use this workflow. Cursor receives `longmem.mdc`; Claude Code receives `CLAUDE.md`. If the assistant fails to save a result, `longmem review` provides an interactive way to record it manually.

## Setup and configuration

Install the package with `pipx install longmem`, then run `longmem init`. Initialization checks Ollama, pulls the embedding model, and writes IDE configuration. In each project, run `longmem install` to copy the relevant rules file, then restart the IDE. Ollama can use `nomic-embed-text`; OpenAI embeddings require the package’s `[openai]` extra and an API key in configuration or `OPENAI_API_KEY`.

Configuration is stored in `~/.longmem/config.toml`. A team can point `db_path` at a shared filesystem location, use an S3 or LanceDB Cloud `db_uri`, or exchange snapshots with `longmem export` and `longmem import`. LanceDB Cloud authentication can use `LANCEDB_API_KEY`.

## Tools and capabilities

The main MCP tools are `search_similar` and `confirm_solution`. The first returns ranked hybrid-search matches, scores, edge cases, and keyword-match information. The second saves a confirmed solution while filling problem metadata from the preceding search.

Additional tools include `save_solution`, `correct_solution`, `enrich_solution`, `add_edge_case`, `search_by_project`, `delete_solution`, `rebuild_index`, `list_recent`, and `stats`. Run `rebuild_index` after reaching 256 or more entries to compact the database and create an ANN index for faster retrieval. CLI commands also report status, export and import data, and support manual review.

## Limitations and notes

The default setup depends on a reachable local Ollama installation and its embedding model. OpenAI embeddings send embedding requests to that provider instead, so they are not equivalent to the local-only default. Shared databases require a common path or supported cloud configuration; otherwise, export and import provide snapshot-based sharing rather than live synchronization.

The server starts with no stored knowledge, so useful results require saved entries. Search behavior is affected by the similarity and duplicate thresholds, which can be changed in the TOML configuration. The documented IDE workflow targets Cursor and Claude Code.

_Full upstream README: https://allmcps.com/mcp/longmem/readme_

