Hindsight
Hindsight is an MCP server that gives AI coding assistants persistent, project-aware memory and context.
Record single or batch conversations, optionally scoped to a project.
Start/stop file watching to track file creation, modification, and deletion.
Add, update, delete, fetch by ID, list, filter, paginate, and keyword-search memories by type and confidence.
Generate and refresh user profiles/context, including updates to AGENTS.md.
Retrieve recent conversations and file events with pagination.
List projects with record counts and last activity, and view database statistics.
Export data as JSON with type filters and pagination, and clear old data by age.
Check server health, uptime, watch status, and database stats.
Supports automatic retention limits, secret redaction, and global/project isolation.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Hindsight what do you remember about my project?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Hindsight
为 AI 编程助手提供持久化记忆的开源 MCP 服务器。
功能特性
持久化记忆:记录对话内容,追踪文件变更,提取用户偏好与决策
自动画像生成:根据交互数据构建用户画像,自动注入 AGENTS.md
上下文感知:新的 AI 会话启动时即可获取你的编码风格和项目历史
多项目隔离:每个项目独立存储记忆,同时支持全局用户偏好
文件监控:自动追踪文件的创建、修改和删除操作
密钥脱敏:对话与记忆写入时自动识别并替换常见密钥格式(AWS/GitHub/Slack/OpenAI key、JWT、私钥块、
password=等),可用HINDSIGHT_REDACT=0关闭
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、相关度排序、分页与置信度过滤) |
|
| 获取最近记录的对话内容(支持 offset 分页) | 无 |
| 获取最近的文件变更事件(支持 offset 分页) | 无 |
| 列出所有有数据的项目、记录数量及最后活跃时间 | 无 |
| 基于最新数据刷新用户画像 | 无 |
| 获取数据库统计信息 | 无 |
| 导出全部数据为 JSON(支持类型过滤和分页) | 无 |
| 清理指定天数之前的历史数据 |
|
| 检查服务器运行状态(含监控目录及其绑定项目) | 无 |
记忆类型
preference — 用户偏好(如技术选型偏好、编码习惯)
pattern — 编码模式(如常用的文件结构、设计模式)
decision — 项目决策(架构选择、技术取舍)
context — 上下文信息(当前活跃目录、文件类型分布)
工作原理
记录交互:捕获对话内容和文件变更事件
提取模式:通过关键词匹配识别用户偏好、决策和编码模式
生成画像:将提取的信息聚合为结构化用户画像,写入 AGENTS.md
提供上下文:AI 助手在启动时读取画像,获得完整的用户上下文
数据存储
数据库:
~/.hindsight/hindsight.db(SQLite,通过 sql.js 运行)用户画像:全局画像写入
~/.config/opencode/AGENTS.md;项目画像写入项目目录下的AGENTS.md(项目目录取自start_file_watching的监控路径,未绑定目录的项目仅通过get_user_context提供)。均在 HINDSIGHT 标记区间自动更新自动清理:过期记录(默认 30 天前)自动删除,并按条数上限截断最旧数据(对话 10,000 / 文件事件 10,000 / 记忆 5,000)
自动保存:数据库变更每 500ms 异步刷盘
环境变量
变量 | 说明 | 默认值 |
| 数据库存储目录 |
|
| 配置文件目录(AGENTS.md) |
|
| 数据保留天数 |
|
| 文件事件保留上限 |
|
| 对话记录保留上限 |
|
| 记忆保留上限 |
|
| 写入时脱敏常见密钥(设为 | 开启 |
开发
npm run dev # 监听模式编译
npm run test # 运行集成测试许可证
MIT
Available Tools
19 toolsadd_memoryC
手动添加一条记忆
Inputs: type (required), content (required), project, confidence.
batch_record_conversationsB
批量记录多条对话内容(一次调用写入多条消息)
Inputs: messages (required), project.
clear_old_dataC
清理指定天数之前的历史数据(对话、文件事件、记忆)
Inputs: olderThanDays (required), project.
delete_memoryC
删除指定 ID 的记忆
Inputs: id (required).
export_dataC
导出指定项目的数据(对话、文件事件、记忆)为 JSON,支持类型过滤和分页
Inputs: limit, offset, include, project.
get_file_eventsB
获取最近的文件变更事件(创建/修改/删除),支持 offset 分页
Inputs: limit, offset, project.
get_memoriesC
获取存储的记忆
Inputs: type, limit, offset, project, +1 more.
get_memory_by_idB
根据 ID 获取单条记忆的详细内容
Inputs: id (required).
get_recent_conversationsC
获取最近记录的对话内容,支持 offset 分页
Inputs: limit, offset, project.
get_statsB
获取数据库统计信息(对话/文件事件/记忆数量)
Inputs: project.
get_user_contextC
获取用户画像和上下文信息
Inputs: project.
health_checkA
检查服务器运行状态(运行时长、文件监控状态、数据库统计)
Inputs: no named parameters.
list_projectsA
列出所有有数据记录的项目的记录数量与最后活跃时间(project 为 null 表示全局数据)
Inputs: no named parameters.
record_conversationC
记录用户与 AI 的对话内容
Inputs: role (required), content (required), project.
refresh_profileC
基于最新数据刷新用户画像
Inputs: project.
search_memoriesB
按关键词搜索记忆内容,默认按相关度(命中次数+置信度)排序,支持分页
Inputs: query (required), sort, type, limit, +3 more.
start_file_watchingC
开始监控指定目录的文件变化(可同时监控多个目录)
Inputs: path (required), project.
stop_file_watchingA
停止文件监控(指定 path 则只停该目录,不指定则停止全部)
Inputs: path.
update_memoryC
更新指定 ID 记忆的内容、置信度或类型
Inputs: id (required), type, content, confidence.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 19 tools
Most tools map to a distinct resource+action (memory CRUD, conversation recording, file watching, stats). There are a few mild overlaps: get_stats and health_check both return database statistics, and list_projects reports per-project counts that overlap with get_stats totals, but the descriptions clarify the primary purpose of each.
Nearly all tools follow a snake_case verb_noun pattern (get_memories, add_memory, update_memory, search_memories, export_data, clear_old_data). Minor deviations exist: batch_record_conversations prefixes the verb with 'batch', and health_check is a noun phrase without a verb, but overall the convention is readable and predictable.
19 tools cover a fairly rich domain (conversation logging, file watching, memory CRUD/search, profile, stats, export, cleanup), and each maps to a distinct operation. It is on the heavier side but nothing feels redundant enough to remove outright.
Memory lifecycle is fully covered (add/get/list/search/update/delete), alongside conversation recording, file watching, stats, export, cleanup, and health. Minor gaps remain: conversations have no get-by-id or delete operations, and the user profile can only be refreshed, not directly edited.
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.3629 npm1MIT
- AlicenseAqualityBmaintenanceA local MCP server that gives AI assistants a long-term memory by capturing sessions verbatim and surfacing relevant context automatically.15927MIT
- 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.11 npmMIT