Th Memory

MCP文档知识

提供方 未标注

文档知识 stdio · 本地进程 未标注 社区 / 第三方 Claude DesktopClaudeCursorVS Code
查看接入方式

面向OpenCode及其他宿主的长时记忆MCP服务器——将偏好、经验教训和使用历史存储在单个本地SQLite文件中(100%本地,无外部API),使AI能够通过基于上下文的学习“记住并适应”用户。

一句话选型结论

按资料字段整理

Th Memory 属于文档知识类 MCP 服务器,stdio · 本地进程,鉴权方式未标注,可直接接入 Claude Desktop、Claude、Cursor 等,有可直接执行的安装命令。接入前先确认权限范围;涉及写入、删除或付款的操作,建议先在测试环境验证。

分类文档知识 传输方式stdio · 本地进程 鉴权未标注 部署方式本地部署
GitHub 星标 未标注 仓库热度,无公开仓库时显示未标注
工具数 未标注 暴露给模型的工具数量
资源 / 提示词 0 / 0 资源与提示词模板数量
维护方 社区 / 第三方 核验等级 仅资料核对

工具与能力

文档知识
数量来自来源目录的标注,具体工具清单以官方文档为准
工具数量未标注暴露给模型可调用的工具个数
资源数量0可读取的资源条目
提示词数量0内置提示词模板数量

能力标签

支持客户端

适用场景

记忆

安装与配置

stdio · 本地进程 未标注
客户端在本机拉起子进程,数据不出本机
npx th-memory-mcp

这条命令只是入口,具体启动参数请按官方文档补齐,不要直接照搬到别的服务器。

  1. 1
    准备运行环境

    stdio 服务在本地起进程,需要先装好 Node.js 等运行时,再按安装命令拉取依赖。

  2. 2
    安装服务

    复制上面的安装命令执行;命令里带占位符的位置,换成自己的密钥或路径。

  3. 3
    写入客户端配置

    在客户端的 MCP 配置里填好启动命令和参数,保存后完全退出客户端再打开,让新配置生效。

  4. 4
    验证是否可用

    连接成功后随便调一个只读工具,确认能返回结果,再接入正式流程。

典型使用场景

3 类
按分类与标签整理的常见用法,具体以官方文档为准
文档检索问答

在你的文档库里按问题找答案。

知识库读写

把新资料写进知识库,随用随取。

内容整理

把零散资料归纳成结构化笔记。

选择建议

选之前先看这几条
按条目字段给出的判断,不替你决定用不用

值得选的地方

  • 有现成的安装命令,不用自己找入口,照着跑就能起服务。
  • 已适配 Claude Desktop、Claude、Cursor,换客户端不用重新研究配置。

先想清楚的地方

  • stdio 方式要求本地装好运行时(如 Node.js),换机器要重新装一遍。
  • 资料没标注工具数量,实际能力要装好后确认。
  • 版本更新与行为细节以官方仓库为准。

更适合

  • 需要在文档知识场景里让模型直接调用外部能力的人。
  • 已经在用 Claude Desktop、Claude 的用户,接入路径最短。
  • 想先快速试一下、能接受在本地或自有环境跑服务的人。

不太适合

  • 完全不想在本地装环境的人。
  • 需要厂商级 SLA 和技术支持的生产环境。

同类对比

6 个同类
同分类里挑最接近的几条,字段以各自详情页为准
MCP 服务器工具数传输方式部署方式安装命令最后核验
Th Memory当前 未标注 stdio · 本地进程 本地部署 有 未标注
dify 未标注 stdio · 本地进程 本地部署 有 2026-04-11
open-webui 未标注 stdio · 本地进程 本地部署 有 2026-04-11
JeecgBoot 未标注 stdio · 本地进程 本地部署 有 2026-04-11
Cherry Studio 未标注 未标注 未标注 无 2026-05-17
mempalace 未标注 stdio · 本地进程 本地部署 有 2026-04-11

服务器档案

文档知识
字段来自项目仓库与公开索引,中文说明由本站标注
提供方未标注上游标注的维护方 未标注
分类文档知识本站按上游分类展示
连接方式stdio · 本地进程客户端在本机拉起子进程,数据不出本机
鉴权方式未标注远程服务建议用最小权限凭据
维护方社区 / 第三方核验等级 仅资料核对
包名 / 运行时未标注 · 未标注本地安装时用到的包标识与运行时
部署类型本地部署上游给出的部署形态
最近核验未标注上游最后核验时间

详细介绍

12.1 KB
来自项目仓库与上游目录的原文,未做删改

th-memory-mcp

Requirements

  • Node.js 22.23.4+, 24.22.1+, or 26.12.1+ — patched releases only; the server uses Node-only APIs (better-sqlite3 native build, import.meta.url). Node.js 20 is EOL and unsupported. CI tests the minimum patched version of each supported line (22/24/26).
  • npm — for npm install, npm run build, npm test. No external services, accounts, or API keys — everything lives in a single local SQLite file.
  • OpenCode — the host that loads the MCP server and the auto-capture plugin (any build with MCP over stdio + plugins). The plugin uses node:sqlite on OpenCode Desktop/Node 22.5+ and falls back to bun:sqlite on the Bun-based CLI.
  • OS: Windows / macOS / Linux — cross-platform (Node); Windows: set MEMORY_DB_PATH with setx, macOS/Linux: export in your shell profile.

> Security: Use a patched Node.js release — check your runtime with npx is-my-node-vulnerable. npm audit covers npm dependencies only, not Node.js core CVEs.

Quick Start

Fastest path: npm run quickstart (after cloning) builds, wires opencode.json/opencode.jsonc, deploys the plugin, and sets MEMORY_DB_PATH — the steps below are the manual equivalent. npm alternative: npm install -g th-memory-mcp (or npx th-memory-mcp) and point mcp.command to th-memory-mcp instead of dist/index.js (plugin still from this repo; not on GitHub Packages anymore).```bash

1. Clone and build

git clone https://github.com/worakorn-prince/th-memory-mcp.git
cd th-memory-mcp && npm install && npm run build

2. Share one DB between the server and the plugin

setx MEMORY_DB_PATH "$PWD/data/memory.db" # Windows (PowerShell)

export MEMORY_DB_PATH="$PWD/data/memory.db" # macOS/Linux — add to your shell profile (~/.zshrc)


3. Merge this into `~/.config/opencode/opencode.json` (replace `` with the absolute clone path; ready-made block in `opencode.example.json`). `MEMORY_DB_PATH` must be the SAME file for server and plugin — a system/user-level env var covers both; `environment` below covers the server only. Example rules: `AGENTS.memory.example.md` (attachable at project level).```json
{ "instructions": ["<REPO>/AGENTS.memory.example.md"],
  "mcp": { "memory": { "type": "local", "command": ["node", "<REPO>/dist/index.js"], "enabled": true, "environment": { "MEMORY_DB_PATH": "<REPO>/data/memory.db" } } } }
  1. (Optional) Auto-capture: deploy the dual-mode plugin to a directory (OpenCode V2 only auto-discovers local plugins from a folder) — src/plugin/learning-capture.ts → ~/.config/opencode/plugins/learning-capture/index.ts
  2. Restart OpenCode (config loads at startup only), then try: "Remember that I prefer pnpm" → new session → "What package manager do I prefer?"

The plugin works in both modes: OpenCode V2 calls the default export's id + setup(ctx) (domain hooks for prompt/tool/compaction/failure events), while V1 (1.18.29+) calls the same default export's server(), which returns the legacy hook object. One file, no runtime import of @opencode/plugin (types only), so it loads under both Node and Bun.

If startup reports Failed to load plugin ... Received protocol 'bun:' or the plugin is silently ignored on V2, you are on an older install layout. Re-deploy the current src/plugin/learning-capture.ts to ~/.config/opencode/plugins/learning-capture/index.ts; a legacy ~/.config/opencode/plugins/learning-capture.ts is renamed to .bak- by npm run quickstart (never deleted). It loads node:sqlite first and only falls back to bun:sqlite under Bun.

Architecture

OpenCode loads the plugin learning-capture (dual-mode V1/V2, Node/Bun) — auto-captures prompt/tool/error into the DB, injects the profile on compaction — and the MCP server th-memory-mcp (Node stdio) exposing the 16 tools on that same SQLite DB; global rules (memory-protocol.md) teach the AI to use them.

Why th-memory-mcp?

  • Context-based learning, not fine-tuning — captures your preferences, corrections, and habits, then recalls them next session; no data leaves your machine.
  • 100% local & private — one SQLite file, no cloud, no external API; secrets (api_key=, password:, token) filtered before storage.
  • Low overhead & resilient — tool calls are capped (latency < 10 ms, bounded output) and degrade gracefully if the DB is unavailable.
  • Open & extensible — MIT licensed; 16 documented tools, rule-based distill, auto-capture plugin; Node + better-sqlite3 only (no extra native extensions).

Highlights

  • Structured memory — preferences with confidence scoring plus lesson records (situation → mistake → correction), not just flat facts.
  • Lifecycle, temporal & conflict-aware — states (active/stale/superseded/archived), confidence/importance/salience scoring, per-type decay, validity intervals for point-in-time truth and supersession chains; duplicate/contradiction resolution keeps both sides of ambiguous evidence.
  • Hybrid retrieval — get_context blends FTS5 keyword search with dependency-free lexical fuzzy matching (hashed n-gram similarity, 512-dim FNV-1a) via RRF fusion, then assembles a token-budgeted context with optional memory-graph expansion.
  • Consolidation — clusters similar memories into derived ones with full provenance (derived_from links).
  • First-class Thai / i18n — Thai-aware tokenization in distill; Thai and English accepted interchangeably.

Works with other harnesses

A standard MCP server: 16 tools anywhere MCP-over-stdio works; all harnesses share one SQLite file via MEMORY_DB_PATH. Auto-capture needs a hook runtime (built into OpenCode, bridged for Claude Code).

Feature OpenCode Claude Code Qwen Code Codex Cursor
16 MCP tools ✅ ✅ ✅ ✅ ✅
Auto-capture (background) ✅ plugin ✅ hooks ⚠️ adapter ❌ manual ❌ Rules
Profile injection ✅ compaction ✅ UserPromptSubmit ❌ get_profile ❌ get_profile ❌ get_profile
Lexical fuzzy matching ✅ (v2.0) ✅ (v2.0) ✅ (v2.0) ✅ (v2.0) ✅ (v2.0)

Scripts

Command Description
npm run build compile TypeScript → dist/
npm start run the MCP server (stdio) from dist/index.js
npm run distill interactions → profile sections + prune old data (RETENTION_DAYS, default 30)
npm test build + full suite (46 files, 148 tests: 147 pass, 1 skip)
node test/.test.mjs run one suite: capture, distill, lifecycle, temporal, conflict, retrieval, graph, context, consolidation, benchmark, security
node test/smoke.mjs end-to-end smoke test over JSON-RPC (16 tools)

Tools (16)

Tool Description
remember upsert preference (category+key); re-save +0.1 confidence (cap 1.0)
recall search preferences + lessons (FTS5) + recent matching interactions — run before a new task
get_profile profile sections + top preferences + 5 most recent lessons
save_lesson record a lesson from a correction (situation / mistake / correction)
search_history search past prompts by keyword (200-char snippets)
forget delete one row (preference/lesson/interaction) by id (+type avoids cross-table id clash)
memory_stats counts by kind, DB size, oldest/newest interaction, profile sections
get_recent_interactions recent raw interactions (filter by kind) — Smart Distill feedstock
export_memory export to JSON under data/exports/ only (filename auto-sanitized)
get_context task-relevant memories via hybrid retrieval (+ graph expansion), token-budgeted
consolidate cluster similar memories via embedding similarity; optionally create derived memories linked via derived_from
link_memory typed link between two memories: supports/contradicts/supersedes/derived_from/related_to/caused_by/depends_on
merge_memory merge a duplicate into canonical memory (source superseded; provenance in metadata.merged_from)
update_memory update fields in place, or create a superseding memory when content changes (supersede=false edits in place)
import_memory import from JSON (validates type, dedupes, never overwrites blindly); dry-run by default, apply=true to insert
extract_memories scan recent interactions for memory-intent phrases, propose candidates (deterministic, no LLM); dry-run by default, apply=true to create (source=captured)

CLI (th-memory)

Binary Entry Purpose
th-memory-mcp dist/index.js MCP server (stdio) — the 16 tools above
th-memory dist/cli.js zero-dep local CLI (same DB via MEMORY_DB_PATH)

Usage: th-memory [--db ] [--json] [--plain] [options] — per-command help via th-memory --help. highlight/recall --highlight: matches underlined (ESC[4m) on a color TTY, else [mem]…[/mem] markers (piped, --plain, --json).

Flag Effect
--db use this SQLite file (sets MEMORY_DB_PATH)
--json print JSON {ok,data} instead of plain text
--plain / --no-color disable colors
-h, --help / -V, --version show help / print version

Command · Usage
remember · remember --category --key --value — save a preference (--value - reads from stdin)
recall · recall [--limit ] [--highlight] — search memory
forget · forget [--type ] — delete by id (t: memory\ · preference\ · lesson\ · interaction)
export · export [--include-interactions] [--filename ] — export to data/exports/*.json
import · import (--file \ · --json ) [--apply] [--user-id ] — import backup (dry-run by default)
stats · stats — memory statistics
profile · profile — distilled user profile
history · history [--query ] [--limit ] — search past prompts (no query = recent prompts)
recent · recent [--limit ] [--kind ] — recent interactions (k: prompt\ · tool_call\ · error)
highlight · highlight [text...] -q [--limit ] — highlight topic matches (empty text = stdin pipe)```bash
th-memory remember --category coding_pref --key package_manager --value pnpm
th-memory recall pnpm --limit 5
echo "I prefer pnpm for installs" | th-memory highlight -q pnpm


## Daily usage

The AI accepts Thai and English interchangeably; long-term care: `npm run distill` summarizes stats and prunes interactions older than 30 days.

- &quot;Remember that...&quot; → `remember` — save a preference
- &quot;Summarize memory&quot; / &quot;distill memory&quot; → **Smart Distill** — AI reads `get_recent_interactions`, finds patterns, saves insights itself
- &quot;How is my memory?&quot; / &quot;memory status&quot; → `memory_stats`
- &quot;Export memory&quot; / &quot;backup memory&quot; → `export_memory`
- &quot;Search history...&quot; → `search_history` · &quot;Forget...&quot; → `forget`

## data/ structure```
data/
├── memory.db          # SQLite (WAL mode) — main DB (+ .db-wal, .db-shm); path overridable via MEMORY_DB_PATH
└── exports/           # JSON files from export_memory (writeable only in this dir)
# everything in data/ is git-ignored

Known Limitations

  • No encryption at rest — data/memory.db is plain, unencrypted SQLite (WAL mode, better-sqlite3); "100% local & private" means no cloud/network exfiltration, not encrypted at rest — anyone with filesystem access can read it. For sensitive data: OS full-disk encryption (BitLocker / FileVault / LUKS) or an opt-in SQLCipher build (native rebuild + key management); no in-code encryption by default (src/db/index.ts documents this).
  • Single-user, no auth layer (Batch B-3) — userId / sessionId / projectId are caller-supplied with no authentication or authorization check inside the server; scope isolation (retrieval, get_context, graph, consolidate, link_memory, merge_memory) binds only to caller-sent values, so any scope is readable/writable by passing a different id. Suitable for a single-user local process; do not share one server/DB across untrusted users without an auth layer in front enforcing the correct userId (projectId / sessionId). No auth is built in by design.

License

MIT © 2026 worakorn-prince — see LICENSE for the full text.

常见问题

8 问
答案由本站依据条目字段整理,不引用上游原文
Th Memory 怎么安装?

在客户端按下面的安装命令接入:npx th-memory-mcp。装完在客户端配置里引用同一个包或端点。

Th Memory 怎么在 Claude Desktop、Claude、Cursor 里配置?

它的传输方式是stdio · 本地进程,在客户端的 MCP 配置里填好启动命令和参数,保存后完全退出客户端再打开,配置才会生效。

Th Memory 收费吗?

本站不代收费用,也没有标注具体价格。是否收费取决于服务本身和背后的接口额度,正式使用前按官方说明确认。

Th Memory 需要 API Key 吗?

资料没有标注鉴权方式,是否需要密钥取决于服务本身,接入前按官方文档确认。

Th Memory 支持哪些客户端?

资料标注支持 Claude Desktop、Claude、Cursor、VS Code、Gemini CLI、Codex;其他客户端只要能配置 MCP Server,也能用同样的命令或地址接入。

Th Memory 能提供哪些能力?

资料显示能力标签包括 记忆。具体工具清单以官方文档为准。

Th Memory 需要什么运行环境?

属于本地进程,需要在本机装好运行环境。

Th Memory 是本地还是远程?

它是本地进程(stdio),由客户端在本机拉起。传输方式为stdio · 本地进程。

热门专题

按标签挑服务器
全部专题 →

服务器信息以作者仓库与官方文档为准;分类、传输方式与鉴权方式的中文说明为中文整理,最近核验 未标注。