Skip to main content
Glama
ai-chat-memory

ai-chat-memory

ai-chat-memory

AIとの会話で自分が打った言葉を、どのAIからも引ける「自分専用の記憶」にする。

Codex や Claude Code に毎日打っている言葉には、自分の目的・判断基準・好み・やめたことが一番濃く残っています。 でもそれは各アプリのログに散らばったままで、次のAIには引き継がれません。

ai-chat-memory はそのログから 自分の発言だけ を取り出し、3つの層に整理して、MCP でどのAIからも読めるようにします。

L2  テーマ索引     テーマごとの「現在地・方針・変遷・未解決」     ← AIはここから読む
 ↑
L1  会話の要約     会話1本ごとの「目的・決めたこと・未解決」
 ↑
L0  自分の発言     打った言葉そのもの(全文検索できる)           ← 根拠はここで確かめる
  • 依存ライブラリなし(Python 3.10+ と SQLite だけ)

  • 全部ローカル。要約は手元の Ollama のモデルで作る。外には何も送らない

  • 読み取り専用の MCP サーバー付き。Claude Code / Codex / Claude Desktop などから使える

なぜ作ったか

2か月で「自分専用AI」のための仕組みを25個作り、ほとんど使わずに終わりました。 残ったのは「手間ゼロで勝手に溜まるもの」だけでした。記録を書く仕組みは続かない。でもAIとは毎日話している。 なら、その会話そのものを記憶にすればいい、というのがこのツールです。

Related MCP server: Rapport MCP Server

使い方

pipx install git+https://github.com/jibun-opt-log/ai-chat-memory
aimemory import            # Codex / Claude Code のログから自分の発言を取り込む(何度実行しても重複しない)
aimemory distill           # 会話の要約とテーマ索引を作る(Ollama が必要)
aimemory stats
aimemory search "画像生成"  # 自分で引く
aimemory ui                # ブラウザで見る(テーマ → 会話の要約 → 元の発言、検索つき。127.0.0.1 だけで動く)

要約のモデルは --model(既定 qwen3.5:9b)、Ollama の場所は --ollama で変えられます。 データは ~/.aimemory/memory.sqlite(--db か AIMEMORY_DB で変更可)。

AIから使う(MCP)

# Claude Code
claude mcp add --scope user ai-chat-memory -- aimemory mcp
# Codex (~/.codex/config.toml)
[mcp_servers.ai-chat-memory]
command = "aimemory"
args = ["mcp"]

ツールは list_topics → get_topic → list_episodes → search_messages / get_session の順に、上の層から下りていく作りです。 AIへの指示ファイル(CLAUDE.md / AGENTS.md)に「自分の過去の判断が関係する質問では ai-chat-memory を上の層から引く」と一行書いておくと効きます。

自動で回す(macOS)

1時間ごとに aimemory import、毎晩 aimemory distill を launchd や cron で回せば、あとは普段どおりAIと話すだけで溜まっていきます。

何を取り込み、何を捨てるか

取り込む

捨てる

自分が手で打ったメッセージ

AIの返答、ツールの出力

サブエージェント・承認レビュー・codex exec などスクリプト実行の会話

アプリが差し込む文脈(<environment_context> など)

「ok」などの短い相づち、複数の会話で同じ文面(テンプレートやbotの指示)

  • APIキーやトークンらしい文字列は [redacted] に置き換えます(パターン照合なので完全ではありません)。

  • 自分のスクリプトが claude -p などで投げる指示は、--skip-prefix "その文の書き出し" で除外できます。スクリプト側で claude -p --no-session-persistence を使えば、そもそもログに残りません。

注意

  • 要約はモデルが作るので、読み違えます。 事実として扱う前に L0 の原文を確かめてください(MCP の説明にもそう書いてあります)。

  • MCP でつないだAIがクラウドのモデルなら、引いた部分はそのモデルに渡ります。元々そのAIに打った内容ですが、どのAIにつなぐかは自分で選んでください。

  • 対応しているログは Codex(~/.codex/sessions)と Claude Code(~/.claude/projects)です。形式が変わると読めなくなることがあります。

English (short)

Turns the messages you typed to Codex and Claude Code into a local, three-layer memory — raw messages → per-conversation summaries → per-theme index — and serves it read-only over MCP so any AI can read you top-down. Stdlib only, summaries by a local Ollama model, nothing leaves your machine.

License

MIT

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      C
      quality
      B
      maintenance
      Provides persistent, local-first AI memory across sessions via MCP tools for storing, searching, and retrieving context from past interactions.
      31
      75 PyPI
      1
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI assistants to query local conversation transcripts and relationship data via a local MCP server, allowing retrieval of past conversations and facts about people.
      1
      AGPL 3.0
    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables AI tools to query a user's private, locally stored memories (notes, documents) with source citations, using the MCP protocol.
      -
    • A
      license
      Not graded
      quality
      B
      maintenance
      Exposes a private social memory archive to AI assistants via MCP, enabling read-only queries about the user's posts, people, and preferences with tools like search, whoami, and timeline.
      MIT