非线性内存OS 是 AI Skill Hub 本期精选MCP工具之一。综合评分 7.5 分,整体质量较高。我们推荐使用将其纳入你的 AI 工具库,帮助提升工作效率。
非线性内存OS 是一款遵循 MCP(Model Context Protocol)标准协议的 AI 工具扩展。通过 MCP 协议,它可以让 Claude、Cursor 等主流 AI 客户端直接访问和操作外部工具、数据源和服务,实现 AI 能力的无缝扩展。无论是文件操作、数据库查询还是 API 调用,都可以通过自然语言在 AI 对话中直接触发,极大提升生产效率。
非线性内存OS 是一款遵循 MCP(Model Context Protocol)标准协议的 AI 工具扩展。通过 MCP 协议,它可以让 Claude、Cursor 等主流 AI 客户端直接访问和操作外部工具、数据源和服务,实现 AI 能力的无缝扩展。无论是文件操作、数据库查询还是 API 调用,都可以通过自然语言在 AI 对话中直接触发,极大提升生产效率。
# 方式一:通过 Claude Code CLI 一键安装
claude skill install https://github.com/pbmagnet4/nlm-memory
# 方式二:手动配置 claude_desktop_config.json
{
"mcpServers": {
"-----os": {
"command": "npx",
"args": ["-y", "nlm-memory"]
}
}
}
# 配置文件位置
# macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
# Windows: %APPDATA%/Claude/claude_desktop_config.json
# 安装后在 Claude 对话中直接使用 # 示例: 用户: 请帮我用 非线性内存OS 执行以下任务... Claude: [自动调用 非线性内存OS MCP 工具处理请求] # 查看可用工具列表 # 在 Claude 中输入:"列出所有可用的 MCP 工具"
// claude_desktop_config.json 配置示例
{
"mcpServers": {
"_____os": {
"command": "npx",
"args": ["-y", "nlm-memory"],
"env": {
// "API_KEY": "your-api-key-here"
}
}
}
}
// 保存后重启 Claude Desktop 生效
<p align="center"> <picture> <source media="(prefers-color-scheme: dark)" srcset="assets/banner-dark.svg" /> <source media="(prefers-color-scheme: light)" srcset="assets/banner-light.svg" /> <img alt="nlm-memory — Local-first non-linear memory OS" src="assets/banner-light.svg" width="720" /> </picture> </p>
<p align="center"> <a href="https://www.npmjs.com/package/nlm-memory"><img src="https://img.shields.io/npm/v/nlm-memory?color=CB3837&label=npm&logo=npm" alt="npm version" /></a> <a href="https://github.com/pbmagnet4/nlm-memory/actions/workflows/ci.yml"><img src="https://github.com/pbmagnet4/nlm-memory/actions/workflows/ci.yml/badge.svg?branch=main" alt="CI status" /></a> <a href="https://github.com/pbmagnet4/nlm-memory/blob/main/LICENSE"><img src="https://img.shields.io/github/license/pbmagnet4/nlm-memory?color=blue" alt="License: Apache 2.0" /></a> <a href="https://nodejs.org"><img src="https://img.shields.io/node/v/nlm-memory?color=brightgreen" alt="Node 20+" /></a> <img src="https://img.shields.io/badge/tests-2%2C000%2B%20passing-success" alt="2,000+ tests passing" /> <img src="https://img.shields.io/badge/MCP-9%20runtimes-8A2BE2" alt="MCP across 9 runtimes" /> <img src="https://img.shields.io/badge/hooks-4%20runtimes-7B2CBF" alt="Hooks on 4 runtimes" /> <img src="https://img.shields.io/badge/telemetry-none-informational" alt="Zero telemetry" /> </p>
<p align="center"> <a href="#install">Install</a> · <a href="#quick-start">Quick Start</a> · <a href="#runtimes">Runtimes</a> · <a href="#how-recall-works">How recall works</a> · <a href="#agent-self-improvement-signals">Signals</a> · <a href="#mcp-tools">MCP</a> · <a href="#rest-api">REST API</a> · <a href="#daily-digest">Digest</a> · <a href="#configuration">Config</a> · <a href="#security">Security</a> · <a href="#vs-alternatives">vs Alternatives</a> </p>
---
nlm-memory is a local-first memory layer for AI coding agents. It indexes every session from Claude Code, Codex CLI, OpenCode, Cursor, Windsurf, Hermes WebUI, Hermes Agent, Aider, and pi across nine runtimes into a single searchable store on your machine. Three properties no other memory layer ships together:
Install-and-recovery validation. A context-free agent ("the stranger") with no knowledge of NLM internals installed from HEAD and answered "Why pgvector over Qdrant, and was anything reconsidered?" correctly in under 6 minutes, recovering the full decision arc including a superseded session. See reports/stranger-sim/2026-06-10-recovery-simulation.md.
Everything stays on your machine by default. No telemetry, no account. The classifier defaults to local (Ollama); if you opt into a cloud classifier (DeepSeek, OpenAI, Anthropic, OpenRouter, or any OpenAI-compatible endpoint), session transcripts are sent to that provider — see Security for the exact data-flow.
---
Open http://localhost:3940/ui after the daemon starts.
| Page | What it shows |
|---|---|
| **Live** | Sessions being written in real time, recent reads, recent decisions |
| **Pulse** | System health — coherence, runtimes, stale entities, recent sessions |
| **River** | Full session timeline with density controls + superseded-lane visualization |
| **Thread** | Per-entity conversation history with runtime filters and ←/→ navigation |
| **Search** | Keyword, semantic, or hybrid recall with match snippets and field-origin tags |
| **Recall** | Adoption telemetry — useful_hit_rate, source breakdown, query log |
| **Settings** | Sources, providers, classifier, data backup/restore |
---
npm install -g nlm-memory
nlm setup
nlm setup is the interactive first-run wizard. It picks your classifier + model, wires the runtimes you actually use, generates an NLM_MCP_TOKEN, hardens permissions on ~/.nlm/, and installs the daemon supervisor for your platform. For headless environments (servers, CI, agents), use nlm start directly after initial setup — it boots the daemon without interactive prompts.
| Platform | Daemon | Notes |
|---|---|---|
| **macOS** | LaunchAgent at ~/Library/LaunchAgents/com.github.pbmagnet4.nlm-memory.plist | Auto-starts on login |
| **Linux** | systemd user unit at ~/.config/systemd/user/nlm.service | Headless servers: loginctl enable-linger $USER so the daemon survives logout |
| **Windows** | Manual nlm start for now | Hook + MCP install paths are platform-aware; supervisor lands next release |
Stop or remove: nlm uninstall.
---
After nlm setup finishes, open http://localhost:3940/ui — the daemon is running. (If you changed NLM_PORT, substitute your port in all examples below.) A 30-second sanity check:
nlm recall "what was that pgvector decision" # one-shot search from the shell
nlm digest # yesterday's activity at a glance
nlm --version
---
| Var | Default | What |
|---|---|---|
NLM_SIGNALS_ENABLED | 1 (on) | Set to 0 to disable signal ingest entirely |
NLM_SIGNAL_RETENTION_DAYS | 90 | Raw signals older than this are pruned |
Signals are local-only. They are stamped with a per-install ID from ~/.nlm/install-id and never leave the machine.
| Var | Default | What |
|---|---|---|
NLM_PORT | 3940 | Daemon bind port (loopback only) |
NLM_DB_PATH | ~/.nlm/canonical.sqlite | SQLite canonical store location |
NLM_HOOK_MODE | live | live injects pointer block; shadow logs without injecting |
NLM_HOOK_RECALL_TIMEOUT_MS | 4000 | Hook-side budget for the daemon recall call. Must stay below NLM_HOOK_DEADLINE_MS and above the daemon's embed deadline or the pointer block silently empties (#396). |
NLM_HOOK_DEADLINE_MS | 6000 | Outer wall-clock deadline for the recall + gate stages of a hook fire. Fail-open on expiry. |
NLM_HOOK_PROMPT_RECALL | (unset = off) | Per-prompt ambient recall. Off by default (pull-first); set on to inject a pointer block on every prompt. off disables explicitly. |
NLM_HOOK_LOG | ~/.nlm/hook-log.jsonl | Hook fire log; powers digest's liveness alert |
NLM_USEFUL_HIT_LOG | ~/.nlm/useful-hit-log.jsonl | Citation/useful-hit ledger |
NLM_QUERY_LOG | ~/.nlm/query-log.jsonl | Recall query telemetry |
NLM_CITATION_LOG | ~/.nlm/citation-log.jsonl | Stop-hook citation events |
NLM_MISS_LOG | ~/.nlm/miss-log.jsonl | Stop-hook miss events — sessions the agent explicitly fetched via get_session/cite_session that the hook never surfaced. Reviewed via nlm misses. |
NLM_MISS_LOG_ENABLED | true | Set to 0 to disable miss-log emission entirely. |
NLM_MCP_TOKEN | auto-generated | 256-bit bearer for /api/* (non-browser) and /mcp |
NLM_MCP_CONFIG | ~/.mcp.json | Path the connect/disconnect commands modify |
NLM_CLASSIFIER | ollama | ollama (local, default), deepseek, openai, anthropic, openrouter, or openai-compatible |
NLM_CLASSIFIER_MODEL | qwen3.5:4b | Model id for the chosen provider. qwen3.5:4b (Q4_K_M, 4.7B) is the recommended local default. For measured tier expectations, see [docs/classifier-tiers.md](docs/classifier-tiers.md). |
NLM_OLLAMA_URL | http://localhost:11434 | Override Ollama endpoint |
NLM_CODE_EXEMPLARS_ENABLED | — | Set to 1 to enable the code-exemplar lane (capture from code-bearing signals + the recall_code tool/routes). Off by default. |
NLM_CODE_EMBED_MODEL | hf.co/awhiteside/CodeRankEmbed-Q8_0-GGUF | Ollama model for code-exemplar embeddings (768-dim). Only used when the exemplar lane is enabled. |
NLM_ADAPTERS | all | Comma-separated allowlist of adapters to enable |
DEEPSEEK_API_KEY | — | Required only when classifier=deepseek |
NLM_DISABLE_UPDATE_CHECK | — | Set to 1 to disable the daily npm-registry update check |
NLM_RECALL_DECAY_HALF_LIFE_DAYS | 180 | Half-life of the recency multiplier applied to recall scores. Older sessions score lower; defaults to 6 months. Set to 0 to disable recency weighting entirely. |
NLM_RECALL_DECAY_FLOOR | 0.25 | Lower bound on the recency multiplier — even ancient sessions retain at least 25% of their raw score so a perfect-match old session can still surface. |
NLM_RECALL_REWRITE_DEFAULT | true | Default value for the MCP recall_sessions rewrite parameter. When true, the service runs an LLM rewrite on vague natural-language queries before search. The HTTP hook caller bypasses rewrite regardless (hot-path protection). |
NLM_RECALL_REWRITE_TIMEOUT_MS | 5000 | Per-call timeout for the rewrite LLM. Separate from the classifier timeout. |
NLM_FACT_CORROBORATION_BOOST_CAP | 2.0 | Maximum multiplicative boost applied to fact recall scores based on how many sessions corroborate the same (subject, predicate, value). Log-scale: 1 corroboration is 1.0×, 10 is 2.0× (capped). Set to 1.0 to disable the boost — the count is still returned on each hit. |
NLM_HOOK_INJECT_FACTS | true | Whether to attach high-confidence facts about top-hit entities to the pointer block injected by the hook. Set to 0 to disable globally. |
NLM_HOOK_FACT_LIMIT | 5 | Maximum number of facts in the "Known facts" section of the pointer block. |
NLM_HOOK_FACT_MIN_CORROBORATION | 2 | Minimum number of sessions that must have asserted a fact before it qualifies for hook injection. Set to 1 to include single-source facts. |
NLM_HOOK_FACT_MIN_CONFIDENCE | 0.7 | Minimum classifier confidence for a fact to qualify for hook injection. |
TELEGRAM_BOT_TOKEN / TELEGRAM_CHAT_ID | — | Required for nlm digest --telegram |
NLM_ALERT_WEBHOOK | — | Set to a URL to enable daemon self-reporting: version-drift and embedder-cold transitions POST a CloudEvents-shaped payload here. Unset means zero network calls. |
NLM_ALERT_WEBHOOK_TOKEN | — | Optional bearer token sent as Authorization: Bearer <token> on every NLM_ALERT_WEBHOOK POST. Only used when the webhook is set. |
NLM_JOB_STALL_MINUTES | 20 | Minutes a daemon-supervised reprocess run (see POST /api/jobs/reprocess) can go without a progress advance before the supervisor calls it stalled and fires nlm.job.stalled via NLM_ALERT_WEBHOOK. The same event type also fires with reason: "exhausted" (restart budget used up) and reason: "spawn_failed" (the child process itself never launched — EMFILE/ENOMEM/bad binary). |
NLM_WIKI_DIR | — (opt-in, off by default) | The wiki projection is off unless this is set. When set, every NLM_WIKI_INTERVAL_HOURS the SQLite-backend daemon rolls up fact subjects that cleared the page threshold into a markdown tree at <dir>/Memory, reconciled against the previous run so an unchanged page writes zero bytes. Unset means no timer, no directory, no log line — an upgrade never surprises you with new files under your home directory. A failed run leaves the previous tree untouched and fires nlm.wiki.projection_failed via NLM_ALERT_WEBHOOK; a run whose written page count doesn't match what the corpus currently qualifies for fires nlm.wiki.coverage_drift. Postgres backend: not implemented, daemon never starts it. |
NLM_WIKI_INTERVAL_HOURS | 6 | How often the wiki projection re-runs once NLM_WIKI_DIR is set. |
NLM_WIKI_MIN_FACTS | 3 | Minimum current (non-superseded, non-retired) fact count a subject needs to earn a wiki page. |
NLM_WIKI_MIN_SESSIONS | 3 | Minimum distinct contributing sessions a subject needs to earn a wiki page. |
NLM_WIKI_LINK_BASE | http://127.0.0.1:<NLM_PORT> | Base URL a wiki page's session links point at. Override when the vault is synced somewhere the daemon's own loopback address won't resolve. |
~/.nlm/.env — autoloaded by every CLI command. Mode 0600, owned by you, never readable by other users. The setup wizard writes the initial keys; you can edit it directly.
The pi quality-gate extension (in the pi-sandbox repo) is a ~10-line integration that emits nlm.signal per gate step and again on retry exhaustion. It is the canonical example of the session-embedded transport.
Daemon binds 127.0.0.1:3940 (override with NLM_PORT). Selected endpoints:
| Method | Path | Auth | Purpose |
|---|---|---|---|
| GET | /api/health | Host-only | Liveness probe: version, warmup + embedding-lane state, corpus stats, update: {current, latest, behind} from the daily npm check, and job: {name, state, processed, total, startedAt, lastAdvanceAt, restarts, restartsTotal} \| null — the daemon-supervised reprocess run (null when idle: never started, or the daemon just restarted, since the supervisor holds no state across restarts). restarts is the restarts-without-progress counter (resets on any advance); restartsTotal is the run's lifetime respawn count, never reset — it's the one to watch for OOM churn on a run that keeps making progress between crashes. |
| GET | /api/recall | Bearer/Origin | Hybrid recall — ?q=, ?mode=keyword\|semantic\|hybrid, ?limit=, ?include_superseded=true (default off; opt-in to surface overturned sessions down-ranked, badged with superseded_by). Each result carries status + superseded_by. |
| GET | /api/recall/stats | Bearer/Origin | 7-day stats: total, hit_rate, useful_hit_rate, top queries |
| GET | /api/recall/recent | Bearer/Origin | Last N recall events for live tail/telemetry |
| GET | /api/recall/cite-stats | Bearer/Origin | Citation rate over ?days= |
| GET | /api/session/:id | Bearer/Origin | Full session body + supersedence links |
| GET | /api/recall/facts | Bearer/Origin | Structured fact search; includes hint field when empty |
| GET | /api/facts/history | Bearer/Origin | Version chain for one fact |
| GET | /api/dataset | Bearer/Origin | Full session list for the UI dataset view |
| GET | /api/live/recent-writes | Bearer/Origin | Live tail of ingested sessions |
| GET | /api/data/backup | Bearer/Origin | Streaming SQLite snapshot download |
| POST | /api/data/restore | Bearer/Origin | Stage a snapshot for apply-on-restart |
| POST | /api/citation/explicit | Bearer/Origin | Log an explicit session citation (the route backing the cite_session MCP tool; payload {id, conversation_id?, reason?}) |
| POST | /api/hook/pre-compact | Bearer/Origin | Hook endpoint; flushes the surfaced-IDs memo |
| ALL | /mcp | Bearer required | Streamable-HTTP MCP transport — the default for every runtime; stateless, team resolved from the token |
| GET | /api/recall-code | Bearer/Origin | Semantic code-exemplar search — ?q=, ?repo=, ?lang=, ?k=, ?negatives=0. Requires NLM_CODE_EXEMPLARS_ENABLED=1. |
| POST | /api/exemplar | Bearer/Origin | Direct code-exemplar push (capture also happens automatically from code-bearing signals). Requires the flag. |
| POST | /api/jobs/reprocess | Bearer/Origin | Start a daemon-supervised reprocess run (body: optional {args: string[]}, forwarded verbatim as CLI flags). 202 + snapshot on start, 409 + snapshot if one's already active. Backs nlm reprocess --daemon. |
| DELETE | /api/jobs/reprocess | Bearer/Origin | Stop the active supervised run (no-op if idle/already terminal). 200 + snapshot. |
/api/* is gated by three layers: 127.0.0.1 Host check (defeats DNS rebinding), Origin check when the browser sends one (defeats cross-origin drive-by), Bearer fallback when Origin is absent (server-to-server clients).
---
What happens when an AI runtime writes a session and you later recall it:
ingest: runtime transcript (jsonl/sqlite)
-> adapter parses runtime-specific format
-> classifier (Ollama local by default; DeepSeek / OpenAI / Anthropic / OpenRouter / OpenAI-compatible if you opt in) extracts label + entities + decisions + open questions
-> embedder (nomic-embed-text via Ollama) computes 768-dim vector
-> SQLite canonical store + FTS5 keyword index + sqlite-vec ANN index
recall: prompt / query
-> tokenize + match scoring (label x3, entity-exact x4, decision x2, summary x1, phrase-bonus +5)
-> hybrid: BM25-style keyword + vector cosine, fused by score
-> recency decay (180-day half-life, floored) x supersedence down-rank
-> select-top-N gate (per-fire cap 3, per-conversation cap 10)
-> pointer block prepended to model context (hooks) or returned as tool result (MCP)
---
| **nlm-memory** | mem0 | Letta / MemGPT | Built-in (CLAUDE.md) | |
|---|---|---|---|---|
| **Unit of memory** | Whole session + extracted markers | Atomic facts | Graph nodes + edges | Static file |
| **Cross-runtime** | 9 adapters, one corpus | Per-app SDK integration | Per-app SDK integration | Per-runtime config |
| **Editable timeline** | Sessions can be superseded, retired, aborted | Append-only fact log | Graph edits | Manual file edits |
| **R@5 baseline** | 97.2% public benchmark; 90.0% real 14mo corpus ([docs/benchmarks.md](docs/benchmarks.md)) | published varies | published varies | n/a |
| **External deps** | SQLite + Ollama (local) | Postgres or Qdrant | Postgres | none |
| **Hosted offering** | none — local only | yes | yes | n/a |
| **Account required** | none | yes (cloud tier) | yes | none |
| **Telemetry** | none | yes | yes | none |
| **License** | Apache 2.0 | Apache 2.0 | Apache 2.0 | — |
The defining property is the editable timeline. mem0 and Letta append; NLM lets you reach back and mark a session as superseded by a newer one, retire one as no-longer-relevant, or flag one as aborted-mid-flight. The next recall surfaces the corrected version, not the stale one. A claim from 6 months ago can be patched today.
---
本项目是 nlm-memory 的中文文档,介绍了一个本地化的非线性内存操作系统。项目的 logo 和 banner 可以在 assets 文件夹中找到。
UI 页面包括 Live、Pulse、River 和 Thread 四个部分,分别显示会话的实时写入、系统健康、会话时间线和实体对话历史。
安装步骤包括使用 npm 安装 nlm-memory 和 nlm setup,后者是一个交互式的首次运行向导,用于选择分类器和模型,配置运行时,生成 MCP token,并安装守护进程。
使用教程包括启动守护进程,打开 UI 页面,使用 nlm recall 和 nlm digest 等命令进行搜索和查看活动。
配置说明包括环境变量和关键参数,例如 NLM_SIGNALS_ENABLED、NLM_SIGNAL_RETENTION_DAYS、NLM_PORT 等。
API 参考文档包括 REST API 端点,例如 /api/health 和 /api/recall,用于检查守护进程的健康状态和进行混合回忆。
工作流和模块说明包括 AI 运行时写入会话和用户回忆会话的过程,涉及 ingest、adapter、分类器和回忆等步骤。
高质量的MCP工具,为AI运算提供了便捷的内存管理
AI Skill Hub 为第三方内容聚合平台,本页面信息基于公开数据整理,不对工具功能和质量作任何法律背书。
建议在沙箱或测试环境中充分验证后,再部署至生产环境,并做好必要的安全评估。
✅ Apache 2.0 — 宽松开源协议,可商用,需保留版权声明和 NOTICE 文件,含专利授权条款。
经综合评估,非线性内存OS 在MCP工具赛道中表现稳健,质量良好。如果你已有明确的使用需求,可以直接上手体验;如果还在评估阶段,建议对比同类工具后再做决策。
| 原始名称 | nlm-memory |
| 原始描述 | 开源MCP工具:Local-first non-linear memory OS for AI operators. One index across Claude Code,。⭐6 · TypeScript |
| Topics | aiaiderclaude-codecodexcursortypescript |
| GitHub | https://github.com/pbmagnet4/nlm-memory |
| License | Apache-2.0 |
| 语言 | TypeScript |
收录时间:2026-06-12 · 更新时间:2026-06-13 · License:Apache-2.0 · AI Skill Hub 不对第三方内容的准确性作法律背书。
选择 Agent 类型,复制安装指令后粘贴到对应客户端