Longmem

io.github.marerem由 GitHub 帳號 marerem 發布v0.2.1更新於 Oct 24, 2026

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

已驗證STDIO僅桌面知識與記憶開發者工具

概覽

AI 產生的概覽

為程式助理提供本機持久記憶,在從頭推理前先以語意檢索已解決的問題。

可以做什麼
Longmem 是一個本機 MCP 伺服器,會保存你已經解決過的問題解法,並跨專案、跨工作階段檢索。主要工具是 search_similar,對已存項目進行語意與關鍵字混合檢索;以及 confirm_solution,儲存解法並自動填入前一次檢索得到的问题中介資料。另外還提供 save_solution、correct_solution、enrich_solution、add_edge_case、search_by_project、delete_solution、rebuild_index、list_recent、stats 等工具,以及用於初始化、檢視、匯出與匯入的命令列工具。
適用情境
如果你在多個程式庫中使用 Cursor 或 Claude Code,而且反覆解決同樣的缺陷、樣板程式碼或模式,就值得加入。它在已有項目後才有價值,可先透過檢視流程或同事的匯出檔填充。團隊可共用同一個資料庫,讓知識能從每個程式庫被檢索到。
執行需求
以本機程序執行,透過 pipx 從 PyPI 安裝,僅支援桌面端。需要嵌入後端:本機 Ollama 執行個體與 nomic-embed-text 模型,或使用 OpenAI 嵌入並提供 API 金鑰。選用設定位於 ~/.longmem/config.toml,可指向共用路徑、S3 或 LanceDB Cloud。
安裝前請注意
儲存的解法會傳送給嵌入後端:本機 Ollama 保留在機器上,而 OpenAI 嵌入會傳送到外部 API。共用或雲端資料庫會讓所有有權限的人看到項目。工具可以刪除或更正已存項目,命令列還能匯入 JSON 匯出檔,因此共用知識在採信前應先檢視。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Longmem,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

[longmem]

Cross-project memory for AI coding assistants.
Stop solving the same problems twice.

[PyPI] [Python 3.11+] [License: MIT] [Tests] [Coverage] [Open Issues] [Closed Issues] [marerem/longmem MCP server]


Your AI solves the same bug in a different project six months later. Writes the same boilerplate. Explains the same pattern. You already knew the answer.

longmem gives your AI a persistent memory that works across every project and every session. Before reasoning from scratch, it searches what you've already solved. After something works, it saves it. The longer you use it, the less you repeat yourself.

You describe a problem        │        ▼  search_similar()  ┌─────────────────────────────────────────────────────┐  │  1. pre-filter by category (ci_cd / auth / db / …)  │  │  2. semantic search  (Ollama or OpenAI embeddings)   │  │  3. keyword search   (SQLite FTS5 exact match)       │  │  4. merge + rank results                             │  └─────────────────────────────────────────────────────┘        │                          │   score ≥ 85%               score < 85%        │                          │        ▼                          ▼  cached solution           AI reasons from scratch  + edge cases                      │  + team knowledge               "it works"  (any project)                     │                                    ▼                          confirm_solution()                          saved once — surfaces                          from every future project

Why longmem

longmemothers
CostFree — local Ollama embeddingsRequires API calls per session
PrivacyNothing leaves your machineSends observations to external APIs
ProcessStarts on demand, no daemonBackground worker + open port required
IDE supportCursor + Claude CodePrimarily one IDE
SearchHybrid: semantic + keyword (FTS5)Vector-only or keyword-only
TeamsExport / import / shared DB path / S3Single-user
LicenseMITAGPL / proprietary

Quickstart

1. Install

bash
pipx install longmem

2. Setup — checks Ollama, pulls the embedding model, writes your IDE config

bash
longmem init

3. Activate in each project — copies the rules file that tells the AI how to use memory

bash
cd your-projectlongmem install

4. Restart your IDE. Memory tools are now active on every chat.

Need Ollama? Install from ollama.com, then ollama pull nomic-embed-text. Or use OpenAI — see Configuration.


How it works

longmem is an MCP server. Your IDE starts it on demand. Two rules drive the workflow:

Rule 1 — search first. Before the AI reasons about any bug or question, it calls search_similar. If a match is found (cosine similarity ≥ 85%), the cached solution is returned with any edge-case notes. Below the threshold, the AI solves normally.

Rule 2 — save on success. When you confirm something works, the AI calls confirm_solution. One parameter — just the solution text. Problem metadata is auto-filled from the earlier search.

The rules file (longmem.mdc for Cursor, CLAUDE.md for Claude Code) wires this up automatically. No manual prompting.

AI forgot to save? Run longmem review — an interactive CLI to save any solution in 30 seconds.

Cold start — getting value from day one

longmem is most useful once it has entries. The fastest way to seed it:

Option 1 — review as you go. After every solved problem this week, run longmem review and describe what you fixed. Ten entries is enough to feel the difference.

Option 2 — team import. If a teammate already has entries, they export and you import:

bash
# teammatelongmem export team_knowledge.json
# youlongmem import team_knowledge.json

Option 3 — shared DB. Set db_path (or db_uri for S3/cloud) to the same location for the whole team. Every save is instantly available to everyone.


CLI

CommandWhat it does
longmem initOne-time setup: Ollama check, model pull, writes IDE config
longmem installCopy rules into the current project
longmem statusConfig, Ollama reachability, entry count, DB size
longmem export [file]Dump all entries to JSON — backup or share
longmem import <file>Load a JSON export — onboard teammates or migrate machines
longmem reviewManually save a solution when the AI forgot

longmem with no arguments starts the MCP server (used by your IDE).


Configuration

Config lives at ~/.longmem/config.toml. All fields are optional — defaults work with a local Ollama instance.

Switch to OpenAI embeddings

toml
embedder       = "openai"openai_model   = "text-embedding-3-small"openai_api_key = "sk-..."   # or set OPENAI_API_KEY

Install the extra: pip install 'longmem[openai]'

Team shared database

Point every team member's config at the same path:

toml
# NFS / shared drivedb_path = "/mnt/shared/longmem/db"

Or use cloud storage:

toml
# S3 (uses AWS env vars)db_uri = "s3://my-bucket/longmem"
# LanceDB Clouddb_uri = "db://my-org/my-db"lancedb_api_key = "ldb_..."   # or set LANCEDB_API_KEY

No shared mount? Use longmem export / longmem import to distribute a snapshot.

Team knowledge base

Save facts that are true across your whole stack under project="shared" so they surface from any repo:

save_solution(  problem="why oauth2-proxy uses port 4181 not default 4180",  solution="General: 4180 is the oauth2-proxy default. 4181 means something else already occupies 4180.\n\nThis team's setup: Sinfonia always runs on 4180. Every other project uses 4181+ by convention.",  project="shared",  category="networking",  tags=["oauth2-proxy", "ports", "nginx"])

search_similar searches all projects — a shared entry surfaces automatically from any repo without needing search_by_project.

Three-layer solution format — write solutions so they work for anyone who finds them:

LayerScopeHow to save
1. General patternUniversal — any teamalways include in solution text
2. Team-wide factYour whole stackproject="shared"
3. Project detailOne repo onlyproject="<repo>" + enrich_solution

Tuning

toml
similarity_threshold = 0.85   # minimum score to surface a cached result (default 0.85)duplicate_threshold  = 0.95   # minimum score to block a save as a near-duplicate (default 0.95)

MCP tools

The server exposes 11 tools. The two you interact with most:

  • search_similar — semantic + keyword hybrid search. Returns ranked matches with similarity scores, edge cases, and a keyword_match flag when the hit came from exact text rather than vector similarity.
  • confirm_solution — saves a solution with one parameter. Problem metadata auto-filled from the preceding search.

Full list: save_solution, correct_solution, enrich_solution, add_edge_case, search_by_project, delete_solution, rebuild_index, list_recent, stats.

Call rebuild_index once you reach 256+ entries to compact the database and build the ANN index for faster search.


Category reference

Categories pre-filter before vector search — keeps retrieval fast at any scale.

CategoryUse for
ci_cdGitHub Actions, Jenkins, GitLab CI, build failures
containersDocker, Kubernetes, Helm, OOM kills
infrastructureTerraform, Pulumi, CDK, IaC drift
cloudAWS/GCP/Azure SDK, IAM, quota errors
networkingDNS, TLS, load balancers, timeouts, proxies
observabilityLogging, metrics, tracing, Prometheus, Grafana
auth_securityOAuth, JWT, RBAC, secrets, CVEs
data_pipelineAirflow, Prefect, Dagster, ETL, data quality
ml_trainingGPU/CUDA, distributed training, OOM
model_servingvLLM, Triton, inference latency, batching
experiment_trackingMLflow, W&B, DVC, reproducibility
llm_ragChunking, embedding, retrieval, reranking
llm_apiRate limits, token cost, prompt engineering
vector_dbPinecone, Weaviate, Qdrant, LanceDB
agentsLangChain, LlamaIndex, tool-calling, agent memory
databaseSQL/NoSQL, migrations, slow queries
apiREST, GraphQL, gRPC, versioning
async_concurrencyRace conditions, event loops, deadlocks
dependenciesVersion conflicts, packaging, lock files
performanceProfiling, memory leaks, caching
testingFlaky tests, mocks, integration vs unit
architectureDesign patterns, service boundaries, refactoring
otherWhen nothing above fits

Contributing

Contributions are very welcome — this project grows with the community that uses it.

Whether it's a bug fix, a new feature, better docs, or just sharing your use case — all of it helps. If you're unsure whether an idea fits, open an issue first and we'll figure it out together.

Getting started:

bash
git clone https://github.com/marerem/longmemcd longmemuv sync --group devuv run pytest

Good first contributions:

  • New category suggestions
  • Edge cases you hit in real projects
  • IDE integrations (JetBrains, VS Code, Neovim, etc.)
  • Better error messages
  • Seed datasets — export your own entries and share them as a starter pack

Ways to contribute without code:

  • Star the repo if you find it useful
  • Share it with your team
  • Open an issue if something is confusing — unclear UX is a bug

License

MIT — see LICENSE.

mcp-name: io.github.marerem/longmem

來源:README.md,提交 b43dc04

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v0.2.1最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分