DEV Community

Derek
Derek

Posted on

Local-First MCP Memory Without Vector Databases or Embedding Fees for Claude Code and Cursor

When developers wire persistent memory into Claude Code, Cursor, or local CLI agents, the default pattern is usually the same: spin up a vector database, send repository notes to an external embedding API, and hope top-k cosine similarity brings back the right paragraph next week.

In real multi-week engineering work, that stack breaks down in three predictable ways:

  1. Stale architecture collisions: After migrating a service port or deprecating a legacy route, cosine similarity keeps returning the old decision right next to the new one.
  2. Exact-identifier blindness: Embeddings smooth over exact part numbers, database column names, error codes, and CLI flags—the exact tokens engineers care about.
  3. Recurring overhead and privacy friction: Re-embedding on every repo update costs money and pushes proprietary engineering context into third-party clouds.

A Smaller, Deterministic Alternative (~3.1 MB, embedded_models=false)

When building LongMemOS, we took the opposite architecture path: a local-first MCP memory runtime shipped as a ~3.1 MB standalone package with embedded_models=false (strictly model-agnostic, no bundled model weights, zero GPU reservation, and zero external embedding API fees).

Instead of relying on opaque vector blobs, three mechanics do the heavy lifting:

1. Deterministic Lexical + Structural Indexing

Exact identifiers (ticket IDs, file paths, config keys, SKU/model codes) stay exact. Agents querying for an environment variable or schema constraint receive deterministic matches rather than approximate semantic neighbors.

2. Temporal Supersession

Engineering truth changes over time. Rather than deleting history or letting conflicting notes tie in vector space, every update can mark a previous fact as superseded while preserving the full audit timeline. By default, queries return active truth; debugging tools can still inspect what changed and when.

3. O13 Source-Line Evidence Replay

Every recalled memory entry remains bound to its exact file path and source line range. When Claude Code or Cursor pulls a constraint before editing a module, it receives verifiable evidence pointers rather than an ungrounded summary.

Minimal Local MCP Setup

Both Claude Code and Cursor can attach to the same local MCP server while keeping repositories separated by namespace:

{
  "mcpServers": {
    "longmemos": {
      "command": "longmemos-mcp",
      "args": [
        "--workspace", "/abs/path/to/project",
        "--namespace", "backend-core",
        "--evidence-mode", "o13-strict"
      ]
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

With this contract, memory_put records verified decisions with source anchors, memory_query returns active facts plus line-level citations, and memory_timeline replays chronological state changes across sessions.

Internal Benchmark Note

In internal testing on the 500-question LongMemEval benchmark, LongMemOS scored 463/500 (92.6%) while keeping all memory data strictly on local storage with zero external embedding calls. As with any memory engine, actual recall performance depends on your workspace structure and prompt discipline, so we always recommend validating on a representative repository slice first.

If you are building multi-session coding workflows or air-gapped enterprise agents, dropping the vector cluster in favor of deterministic local indexing, temporal supersession, and source-line evidence replay dramatically cuts both operational complexity and hallucination surface area.

Top comments (0)