Skip to main content
Glama

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

スクリプト

コマンド

説明

npm run build

TypeScript をコンパイルして dist/ に出力

npm start

dist/index.js から MCP サーバー (stdio) を実行

npm run distill

ルールベースのディスティル: インタラクション → プロファイルセクション + 古いデータの削除 (env RETENTION_DAYS デフォルト30)

npm test

JSON-RPC によるエンドツーエンドのスモークテスト (node test/smoke.mjs)

node test/capture.test.mjs

capture-core のテスト (シークレットのフィルタリング、重複排除、切り詰め、SQL挿入)

node test/distill.test.mjs

distill-core のテスト (タイ語のトークン化、統計、プロファイルセクション、削除)

ツール (9)

ツール

説明

remember

好みを upsert (カテゴリ+キー) — 同じキーを再保存すると信頼度が0.1増加 (上限1.0)

recall

好み + 教訓 (FTS5) + 最近の一致するインタラクションを検索。新しいタスクを始める前に使用

get_profile

ユーザープロファイルの概要: プロファイルセクション + 上位の好み + 最新の教訓5件

save_lesson

修正から学んだ教訓を記録 (状況 / 間違い / 修正)

search_history

過去のユーザープロンプトをキーワードで検索 (各行200文字のスニペット)

forget

ID でメモリの1行 (好み/教訓/インタラクション) を削除 (+type でテーブル間のID衝突を防止)

memory_stats

メモリ統計: 種類別の件数、DBサイズ、最古/最新のインタラクション、プロファイルセクション

get_recent_interactions

最近の生のインタラクションを一覧表示 (種類でフィルタ) — Smart Distill の材料

export_memory

メモリを data/exports/ 配下に JSON でエクスポート (ファイル名は自動サニタイズ)

OpenCode でのインストール

  1. opencode.example.jsonmcp セクションを自分の 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 と同じプロセスで実行されるため

  2. グローバルメモリルールを添付 — opencode.json に追加:

    "instructions": ["C:/Users/<user>/.config/opencode/memory-protocol.md"]

    (例のルール内容は AGENTS.memory.example.md にあります — 代わりにプロジェクトレベルで添付することもできます)

  3. (任意) 自動キャプチャプラグインをデプロイ: src/plugin/learning-capture.ts~/.config/opencode/plugins/learning-capture.ts にコピー

  4. OpenCode を再起動 (設定は起動時のみ読み込まれます)

  5. テスト: 「pnpm を好むことを覚えておいて」 → 新しいセッションを開いて聞き返す

日常の使用

AI はタイ語と英語の両方を相互に受け付けます — いつでも警告なしに言語を切り替えられます。

タイ語

英語

効果

"จำไว้ว่า..."

"覚えておいて..."

remember — 好みを保存

"สรุปความจำ" / "distill memory"

"メモリを要約" / "ディスティルメモリ"

Smart Distill — AI が get_recent_interactions を読み、パターンを見つけ、洞察を自分で保存します

"ระบบความจำเป็นไงบ้าง"

"私のメモリはどうですか?" / "メモリステータス"

memory_stats

"สำรองความจำ"

"メモリをエクスポート" / "バックアップメモリ"

export_memory

"ค้นประวัติ..."

"履歴を検索..."

search_history

"ลืม..."

"忘れる..."

forget

長期的なケア: 時々 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 で無視されます

A
license - permissive license
A
quality
A
maintenance

Maintenance

Maintainers
Response time
0dRelease cycle
13Releases (12mo)
Commit activity

Related MCP Servers

  • -
    license
    Not graded
    quality
    Not graded
    maintenance
    Provides 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
  • A
    license
    Not graded
    quality
    Not graded
    maintenance
    Provides 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.
  • A
    license
    A
    quality
    B
    maintenance
    Provides 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.
    8
    1
    MIT
  • A
    license
    A
    quality
    B
    maintenance
    Provides 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.
    17
    4
    MIT

View all related MCP servers

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.

View all MCP Connectors

Latest Blog Posts

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