th-memory-mcp
memory-mcp
OpenCode 用の長期記憶 MCP サーバー — 好み、教訓、使用履歴を単一のローカル SQLite ファイルに保存します(100% ローカル、外部 API なし)。これにより、AI はコンテキストベースの学習を通じてユーザーを「記憶し、適応」できます。
ステータス: v1.1.0 — 全4フェーズ実装済み、テストは70/70アサーション合格(smoke 53 + capture 8 + distill 9)
ไทย / Thai: README.th.md
アーキテクチャ
OpenCode ──┬─ Plugin learning-capture (Bun) ── auto-captures prompts/tool/error into DB
│ └─ injects profile back into context on compaction
└─ MCP memory-mcp (Node.js stdio) ── 9 tools read/write the same SQLite DB
▲
Global instructions (memory-protocol.md) teach the AI to use the tools詳細は design.md を参照してください。
Related MCP server: MCP Vector Memory
スクリプト
コマンド | 説明 |
| TypeScript をコンパイルして |
|
|
| ルールベースのディスティル: インタラクション → プロファイルセクション + 古いデータの削除 (env |
| JSON-RPC によるエンドツーエンドのスモークテスト ( |
| capture-core のテスト (シークレットのフィルタリング、重複排除、切り詰め、SQL挿入) |
| distill-core のテスト (タイ語のトークン化、統計、プロファイルセクション、削除) |
ツール (9)
ツール | 説明 |
| 好みを upsert (カテゴリ+キー) — 同じキーを再保存すると信頼度が0.1増加 (上限1.0) |
| 好み + 教訓 (FTS5) + 最近の一致するインタラクションを検索。新しいタスクを始める前に使用 |
| ユーザープロファイルの概要: プロファイルセクション + 上位の好み + 最新の教訓5件 |
| 修正から学んだ教訓を記録 (状況 / 間違い / 修正) |
| 過去のユーザープロンプトをキーワードで検索 (各行200文字のスニペット) |
| ID でメモリの1行 (好み/教訓/インタラクション) を削除 (+type でテーブル間のID衝突を防止) |
| メモリ統計: 種類別の件数、DBサイズ、最古/最新のインタラクション、プロファイルセクション |
| 最近の生のインタラクションを一覧表示 (種類でフィルタ) — Smart Distill の材料 |
| メモリを |
OpenCode でのインストール
opencode.example.jsonのmcpセクションを自分のopencode.json(グローバルまたはプロジェクトレベル) にマージします重要: サーバーとプラグインの両方で
MEMORY_DB_PATHを同じデータベースファイルに設定してください (例では<ABSOLUTE_PATH>/memory-mcp/data/memory.dbを使用)。そうしないと、自動キャプチャプラグインが AI が読み取る DB とは異なる DB に書き込みます設定方法 (いずれかを選択):
mcp の
environmentで定義する (例を参照) — MCP サーバーのみに適用または システム/ユーザーレベルの環境変数として設定する (例: Windows で
setx MEMORY_DB_PATH "D:/path/to/memory.db") — サーバーとプラグインの両方に適用。プラグインは OpenCode と同じプロセスで実行されるため
グローバルメモリルールを添付 —
opencode.jsonに追加:"instructions": ["C:/Users/<user>/.config/opencode/memory-protocol.md"](例のルール内容は
AGENTS.memory.example.mdにあります — 代わりにプロジェクトレベルで添付することもできます)(任意) 自動キャプチャプラグインをデプロイ:
src/plugin/learning-capture.tsを~/.config/opencode/plugins/learning-capture.tsにコピーOpenCode を再起動 (設定は起動時のみ読み込まれます)
テスト: 「pnpm を好むことを覚えておいて」 → 新しいセッションを開いて聞き返す
日常の使用
AI はタイ語と英語の両方を相互に受け付けます — いつでも警告なしに言語を切り替えられます。
タイ語 | 英語 | 効果 |
"จำไว้ว่า..." | "覚えておいて..." |
|
"สรุปความจำ" / "distill memory" | "メモリを要約" / "ディスティルメモリ" | Smart Distill — AI が |
"ระบบความจำเป็นไงบ้าง" | "私のメモリはどうですか?" / "メモリステータス" |
|
"สำรองความจำ" | "メモリをエクスポート" / "バックアップメモリ" |
|
"ค้นประวัติ..." | "履歴を検索..." |
|
"ลืม..." | "忘れる..." |
|
長期的なケア: 時々 npm run distill を実行して統計を要約し、30日以上前のインタラクションを削除します。
data/ 構造
data/
├── memory.db # SQLite (WAL mode) — main DB (+ .db-wal, .db-shm)
└── exports/ # JSON files from export_memory (writeable only in this dir)DB パスは
MEMORY_DB_PATH環境変数で上書きできますdata/内のすべては git で無視されます
Maintenance
Related MCP Servers
- -licenseNot gradedqualityNot gradedmaintenanceProvides persistent local memory functionality for AI assistants, enabling them to store, retrieve, and search contextual information across conversations with SQLite-based full-text search. All data stays private on your machine while dramatically improving context retention and personalized assistance.3
- AlicenseNot gradedqualityNot gradedmaintenanceProvides AI coding agents with persistent, long-term memory through local semantic search and SQLite storage. It enables agents to save and retrieve architectural decisions or project context across different conversation sessions without requiring cloud services.
- AlicenseAqualityBmaintenanceProvides persistent cross-session memory and full-text search for AI coding assistants, storing project context, decisions, and preferences while enabling searchable access to conversation history via local SQLite.81MIT
- AlicenseAqualityBmaintenanceProvides AI coding assistants with persistent memory storage using a local SQLite database. Enables tools to remember project details, notes, and relationships across sessions to maintain context and reduce repetitive explanations.174MIT
Related MCP Connectors
Persistent memory and cross-session learning for AI coding assistants (hosted remote MCP).
Persistent memory for AI agents. Search, store, and recall across sessions.
Persistent memory for AI agents — verbatim conversations, searchable by meaning.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/worakorn-prince/th-memory-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server