Longmem logo

Longmem

Persistent cross-project memory for Cursor and Claude Code with hybrid semantic and keyword search.

Install Longmem

Run the project’s own setup commands, in order.

Setup steps from the project

longmem installs with its own steps rather than a config we can generate, so these are copied as-is. Follow them in order and run the commands in a terminal. Source: github.com

  1. 1. Install
    pipx install longmem
    
  2. 2. Install
    git clone https://github.com/marerem/longmem
    

Overview

The longmem MCP server gives Cursor and Claude Code persistent memory across projects and sessions. It stores solutions locally and combines semantic embeddings from Ollama or OpenAI with SQLite FTS5 keyword search, then ranks the results. Agents can search before solving a problem and save confirmed solutions for later reuse. Reach for it when recurring debugging knowledge, team facts, or project-specific fixes should remain available across repositories.

Use cases

  • Search previous fixes before debugging a recurring issue
  • Save confirmed solutions for reuse across repositories
  • Share team knowledge through a common database
  • Export and import memory when onboarding teammates
  • Review and record solutions the assistant forgot to save

Key features

  • Hybrid semantic and SQLite FTS5 keyword search
  • Local Ollama or OpenAI embeddings
  • Cross-project solution storage
  • Shared databases and JSON export/import
  • Project, category, tag, and edge-case metadata
  • MCP tools for saving, correcting, enriching, and searching solutions

Tools3

What Longmem lets your agent do. Expand a tool for its parameters.

Self-reported~11 tokens of context

Security & health

What it can reach and how reliably it runs — from our own checks, not the maintainer’s claims.

ActiveLast checked

Recent health check succeeded.

13/13 checks healthy over the last 51d

Adoption & maintenance

Factual signals from GitHub, npm, and our automated checks — not a rating.

GitHub stars1Stargazers on the source repository.
Last commit7mo agoMost recent push to the default branch.
Tools exposed3Callable tools this server registers over MCP.

How Longmem works

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.

Written by AllMCPs with AI assistance from the project’s README and listing data. How we build listings

Reviews

No reviews yet — be the first to share how it worked for you.

Frequently Asked Questions about Longmem

longmem is an MCP server that connects Cursor and Claude Code to a persistent local memory database. Its main tools, search_similar and confirm_solution, help assistants retrieve prior solutions across projects and save confirmed fixes for future sessions. It combines semantic embeddings with SQLite FTS5 keyword search.

Install it with pipx install longmem, then run longmem init. Initialization checks Ollama, retrieves the embedding model, and writes IDE configuration. Run longmem install inside each project, restart the IDE, and the memory rules become active.

Yes, longmem works with Cursor. Run longmem install in the project to copy the longmem.mdc rules file, then restart Cursor so its MCP workflow can search and save memory.

Yes, longmem works with Claude Code. The project installation places a CLAUDE.md rules file in the repository, which instructs the assistant to search existing memory and save confirmed solutions.

Yes, OpenAI embeddings are supported. Install the openai extra, set embedder to openai and choose an OpenAI model in ~/.longmem/config.toml, then provide the key there or through OPENAI_API_KEY.

Related MCP servers

Add a badge to your READMEShow it’s listed — live SVG, Markdown or HTML.

AllMCPs Directory Badge

Full Badge Customizer

Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.

Badge Style:
Live Dynamic SVG PreviewLongmem AllMCPs Directory Badge
Markdown (GitHub README)
[![AllMCPs](https://allmcps.com/api/badge/longmem?style=directory)](https://allmcps.com/mcp/longmem)
HTML Embed
<a href="https://allmcps.com/mcp/longmem"><img src="https://allmcps.com/api/badge/longmem?style=directory" alt="Longmem on AllMCPs" /></a>