Skip to main content
Glama

プログラミングエージェント自己学習メモリーエンジン

MCP(Model Context Protocol)ベースの自己学習メモリーエンジン。プログラミングエージェントに 「感知-反思-沈殿-応用」 の4層クローズドループ学習能力を提供する。エージェントがエラーから学び、使えば使うほど強くなる。

アーキテクチャ概要

┌──────────────────────────────────────────────────────┐
│                    编程智能体                          │
│  (Claude Code / Cursor / 任何支持 MCP 的智能体)       │
└──────────┬───────────────────────┬────────────────────┘
           │ MCP Protocol          │
    ┌──────▼──────┐         ┌──────▼──────┐
    │  应用层      │         │  感知层      │
    │  检索+注入   │         │  错误捕获    │
    └──────┬──────┘         └──────┬──────┘
           │                       │
    ┌──────▼──────┐         ┌──────▼──────┐
    │  沉淀层      │         │  反思层      │
    │  技能+记忆   │◄────────│  根因分析    │
    └──────┬──────┘         └─────────────┘
           │
    ┌──────▼──────┐
    │  存储层      │
    │  SQLite+FTS5 │
    └─────────────┘

Related MCP server: Self-Learning MCP

4層クローズドループ

責務

MCP ツール

感知層 Observation

ツール実行エラー、テスト失敗、ユーザー修正、会話シグナルの捕捉

record_observation, capture_conversation_signals, get_pending_observations

反思層 Reflection

根本原因分析、再利用可能な経験の抽出

get_reflection_prompt, reflect_and_save, batch_get_reflection_prompts

沈殿層 Consolidation

スキルの精錬、SKILL.md の生成、メモリーの維持

create_skill, get_skill_prompt, list_skills, get_skill, check_consolidation

応用層 Application

関連経験の検索、タスクコンテキストへの注入

get_context, search_memory, search_skill

統計

エンジン状態の確認

get_stats

インストール

# 进入项目目录(替换为你本机的实际路径)
cd memory-engine

# 安装依赖(绕过代理)
pip install --no-proxy -e .

# 或手动安装
pip install --no-proxy mcp[cli] jieba

MCP サーバーの設定

ZCode / Claude Code

MCP 設定ファイルに以下を追加:

{
  "mcpServers": {
    "memory-engine": {
      "command": "python",
      "args": ["-m", "memory_engine.server"],
      "cwd": "<项目根目录的绝对路径>"
    }
  }
}

<プロジェクトルートディレクトリの絶対パス> は、このプロジェクトをクローン/配置した実際のパス(pyproject.toml を含むディレクトリ)に置き換えること。例:Windows では D:/tools/memory-engine、macOS/Linux では /home/user/tools/memory-engine のような形式。

Cursor / VS Code

.cursor/mcp.json または VS Code の MCP 設定に同じ設定を追加する。

スタンドアロン実行(デバッグ用)

cd memory-engine
python -m memory_engine.server

コアワークフロー

0. 会話シグナルの捕捉(感知強化)

vibe coding の過程で、操作者は会話中に明示的なシグナルを残すことが多い——「注意してください」「覚えておいてください」などの強調指示、 およびエージェントの繰り返しのミスによる不満(「また…」「何度言ったら…」)。 これらの発言は最も価値の高い学習素材であり、捕捉してメモリーに組み込むべきである:

capture_conversation_signals(
  conversation_text="用户: 请注意,bat文件必须用ANSI编码
用户: 怎么又是编码问题,我说过多少次了",
  auto_record=true
)

検出器は4種類のシグナルを識別し、優先順位に従って並べる:

シグナル

識別例

意味

complaint

「また」「まだ違う」「何度言ったら」

繰り返しのミスによる不満。以前の教訓が活かされていないことを示す(最優先)

emphasis

「注意してください」「覚えておいてください」「必ず」「絶対に」

ユーザーが明示的に強調したルール

preference

「今後はすべて」「私は好き」「デフォルトで」

ユーザーの作業方法に関する好み

frustration

「呆れた」「遅すぎる」「時間の無駄」

不満感情。効率・体験の問題を示唆

検出結果は自動的に conversation_signal タイプの観察として記録され、反思時には専用にカスタマイズされたプロンプト (過去のエラー推論 + 命令形ルールへの精錬)が使用され、以降のフローはエラー反思と同様である。

1. エラーの記録(感知)

ツール実行が失敗したとき、エージェントは以下を呼び出す:

record_observation(
  obs_type="tool_error",
  tool_name="Bash",
  error_message="bat文件执行报错:编码错误",
  context="在Windows上创建的bat文件包含中文注释",
  tags="encoding,windows,bat"
)

2. 反思分析(反思)

分析プロンプトを取得:

get_reflection_prompt(obs_id="abc123")

エージェントは返されたプロンプトに基づいて根本原因を分析し、結果を保存する:

reflect_and_save(
  obs_id="abc123",
  root_cause="Windows的cmd.exe默认使用系统ANSI编码,UTF-8编码的bat文件会导致中文注释被解析错误",
  category="encoding",
  lesson="在Windows上创建bat文件时,文件必须使用ANSI/GBK编码,而非UTF-8",
  solution="将bat文件保存为ANSI编码,或使用chcp 65001切换代码页",
  tags="encoding,windows,bat,cmd",
  generalizable=true
)

3. スキルの精錬(沈殿)

十分な経験が蓄積されたら、スキルを精錬できるか確認する:

check_consolidation()

スキルを作成:

create_skill(
  name="windows-bat-encoding",
  description="Windows bat文件中文编码问题的处理方法",
  trigger_conditions="创建或编辑.bat文件\n在Windows上运行脚本失败且涉及中文",
  steps="将文件保存为ANSI编码\n或使用chcp 65001 + UTF-8 BOM",
  caveats="chcp 65001仅在当前cmd会话有效\n某些旧版Windows不支持UTF-8 BOM",
  category="encoding"
)

4. 検索と応用(応用)

新しいタスクを開始する前に、関連する経験を取得:

get_context(task_description="需要创建一个Windows批处理脚本来部署应用")

関連するスキルとケースを含むコンテキストが返され、そのまま prompt に注入される。

メモリーの階層

タイプ

説明

エピソード記憶 Episodic

具体的な「ストーリー」、ある修正の完全な記録

「2024-01-15 XXプロジェクトのbatエンコーディング問題を修正」

意味記憶 Semantic

抽象化されたルールと教訓

「WindowsではbatファイルはANSIエンコーディングを使用すべき」

スキル Skill

標準化された実行可能な操作ガイド

SKILL.md ファイル

データストレージ

  • SQLite データベース (data/memories.db):構造化ストレージ、FTS5 全文検索対応

  • JSONL ログ (data/observations.jsonl):生の観察記録の追記ログ

  • Markdown ファイル (data/skills/):生成されたスキルドキュメント、人間が読める形式、バージョン管理可能

プロジェクト構造

memory-engine/
├── 开发思路.md              # 设计文档
├── README.md                # 本文件
├── pyproject.toml           # Python 项目配置
├── requirements.txt         # 依赖列表
├── config/
│   └── settings.json        # 引擎配置
├── src/memory_engine/
│   ├── __init__.py
│   ├── server.py            # MCP 服务器入口(15个工具)
│   ├── models/
│   │   └── schemas.py       # 数据模型
│   ├── observation/
│   │   ├── collector.py     # 感知层:错误收集器
│   │   └── signal_detector.py # 感知层:对话信号检测器
│   ├── reflection/
│   │   └── analyzer.py      # 反思层:根因分析器
│   ├── consolidation/
│   │   ├── memory_store.py  # 存储层:SQLite + FTS5
│   │   └── skill_generator.py # 沉淀层:技能生成器
│   └── application/
│       └── retriever.py     # 应用层:记忆检索器
├── data/
│   ├── memories.db          # SQLite 数据库(运行后生成)
│   ├── observations.jsonl   # 观察日志(运行后生成)
│   └── skills/              # 技能 Markdown(运行后生成)
└── tests/
    └── test_engine.py       # 测试

エラーカテゴリ

encoding | build_error | runtime_error | test_failure | dependency | configuration | platform_specific | performance | security | best_practice | api_usage | preference | communication | other

設計理念

  • 外部 LLM に依存しない:反思とスキル精錬は呼び出し側(エージェント自身)が行い、エンジンはフレームワークとストレージのみを提供する

  • MCP ネイティブ:標準 MCP サーバーとして動作し、MCP をサポートする任意のエージェントが直接接続できる

  • 人機協調:すべてのメモリーとスキルは人間が読める形式(Markdown、JSON)で保存され、レビューと保守が容易

  • 段階的学習:単一エラー→エピソード記憶→意味記憶→スキルへと、層ごとに抽象化し、段階的に精錬する

Install Server
A
license - permissive license
B
quality
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • A
    license
    Not graded
    quality
    C
    maintenance
    Helps AI coding agents remember what they learn across sessions by storing and retrieving atomic learnings, enabling persistent memory for AI tools.
    11
    1
    MIT
  • A
    license
    Not graded
    quality
    B
    maintenance
    Enables AI agents to learn from their work by recording tasks, extracting patterns, detecting mistakes, and proactively surfacing insights, all using the agent's own model through a cooperative intelligence pattern.
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    Provides coding agents with durable, cross-session lessons-learned memory, enforcing that success or failure verdicts can only come from human approval, human correction, or objective metrics—never from the agent itself.
    Apache 2.0

View all related MCP servers

Related MCP Connectors

  • Persistent memory and knowledge management for AI agents with semantic search and 50+ tools.

  • Persistent memory for AI agents — verbatim conversations, searchable by meaning.

  • Shared debugging memory for AI coding agents

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/top777/memory-engine'

If you have feedback or need assistance with the MCP directory API, please join our Discord server