Hindsight
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Hindsight
为 AI 编程助手提供持久化记忆的开源 MCP 服务器。
功能特性
持久化记忆:记录对话内容,追踪文件变更,提取用户偏好与决策
自动画像生成:根据交互数据构建用户画像,自动注入 AGENTS.md
上下文感知:新的 AI 会话启动时即可获取你的编码风格和项目历史
多项目隔离:每个项目独立存储记忆,同时支持全局用户偏好
文件监控:自动追踪文件的创建、修改和删除操作
Related MCP server: iai-personal-memory-engine
架构概览
┌──────────────────────────────────────────────────────┐
│ MCP Server (std io) │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ index.ts │ │ profiler.ts │ │ fileWatcher │ │
│ │ (工具路由) │ │ (画像生成) │ │ (文件监控) │ │
│ └──────┬───────┘ └──────┬───────┘ └──────┬───────┘ │
│ └────────────────┼────────────────┼─────────┘ │
│ ┌─────▼─────┐ │
│ │ store.ts │ ◄────────┘
│ │ (SQLite) │
│ └─────┬─────┘
└──────────────────────────┼───────────────────────────┘
│
┌────────────▼────────────┐
│ ~/.hindsight/hindsight.db │
│ ~/.config/opencode/AGENTS.md │
└─────────────────────────┘核心模块
src/index.ts— MCP 服务器入口,定义 19 个工具并处理请求路由src/store.ts— SQLite 存储层,管理对话、文件事件和记忆的 CRUD、搜索、批量写入、导出与清理src/profiler.ts— 画像生成器,从对话和文件事件中提取偏好、模式与决策src/fileWatcher.ts— 基于 chokidar 的文件监控,过滤构建目录和临时文件src/types.ts— TypeScript 类型定义(对话事件、文件事件、记忆、用户画像)
安装
npm install
npm run build配置
将以下配置添加到 OpenCode 配置文件(~/.config/opencode/opencode.json):
{
"mcpServers": {
"hindsight": {
"command": "node",
"args": ["path/to/hindsight/dist/index.js"]
}
}
}MCP 工具
工具名 | 说明 | 必需参数 |
| 记录用户与 AI 的对话内容 |
|
| 批量记录多条对话内容 |
|
| 开始监控指定目录的文件变化 |
|
| 停止文件监控 | 无 |
| 获取当前用户画像和上下文 | 无 |
| 查询已存储的记忆(支持类型/置信度过滤与 offset 分页) | 无 |
| 根据 ID 获取单条记忆详情 |
|
| 手动添加一条记忆 |
|
| 更新记忆的内容、置信度或类型 |
|
| 按 ID 删除指定记忆 |
|
| 按关键词搜索记忆(空格分词 AND、相关度排序、分页与置信度过滤) |
|
| 获取最近记录的对话内容 | 无 |
| 获取最近的文件变更事件 | 无 |
| 列出所有有数据的项目、记录数量及最后活跃时间 | 无 |
| 基于最新数据刷新用户画像 | 无 |
| 获取数据库统计信息 | 无 |
| 导出全部数据为 JSON(支持类型过滤和分页) | 无 |
| 清理指定天数之前的历史数据 |
|
| 检查服务器运行状态(含监控目录及其绑定项目) | 无 |
记忆类型
preference — 用户偏好(如技术选型偏好、编码习惯)
pattern — 编码模式(如常用的文件结构、设计模式)
decision — 项目决策(架构选择、技术取舍)
context — 上下文信息(当前活跃目录、文件类型分布)
工作原理
记录交互:捕获对话内容和文件变更事件
提取模式:通过关键词匹配识别用户偏好、决策和编码模式
生成画像:将提取的信息聚合为结构化用户画像,写入 AGENTS.md
提供上下文:AI 助手在启动时读取画像,获得完整的用户上下文
数据存储
数据库:
~/.hindsight/hindsight.db(SQLite,通过 sql.js 运行)用户画像:
~/.config/opencode/AGENTS.md(HINDSIGHT 标记区间自动更新)自动清理:过期记录(默认 30 天前)自动删除,并按条数上限截断最旧数据(对话 10,000 / 文件事件 10,000 / 记忆 5,000)
自动保存:数据库变更每 500ms 异步刷盘
环境变量
变量 | 说明 | 默认值 |
| 数据库存储目录 |
|
| 配置文件目录(AGENTS.md) |
|
| 数据保留天数 |
|
| 文件事件保留上限 |
|
| 对话记录保留上限 |
|
| 记忆保留上限 |
|
开发
npm run dev # 监听模式编译
npm run test # 运行集成测试许可证
MIT
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Cloud-hosted MCP server for durable AI memory
Persistent memory and cross-session learning for AI coding assistants (hosted remote MCP).
Persistent, verbatim, searchable memory for AI assistants — one memory across every MCP client.
Persistent AI memory shared across Claude, ChatGPT, coding agents, and compatible MCP clients.
Related MCP Servers
- AlicenseBqualityDmaintenanceAn MCP server that gives AI assistants persistent memory across sessions. It stores project context, decisions, and progress in structured markdown files as well as a knowledge graph and sequential thinking for better memory storage.3625 npm1MIT
- AlicenseAqualityAmaintenanceA local MCP server that gives AI assistants a long-term memory by capturing sessions verbatim and surfacing relevant context automatically.15922MIT
- AlicenseCqualityCmaintenanceAn MCP server that gives AI coding assistants persistent memory across sessions with chain-based project tracking, tickets, and structured handoffs.42GPL 3.0
- AlicenseNot gradedqualityDmaintenanceA local MCP server that gives AI coding agents persistent memory and context across sessions.4 npmMIT