I built an MCP server that gives AI coding assistants persistent memory (85.6% token reduction)
I built an MCP server that gives AI coding assistants persistent memory (85.6% token reduction)
我开发了一个 MCP 服务器,为 AI 编程助手提供持久化记忆(Token 占用减少 85.6%)
Every time you start a new Claude Code session, your AI has zero context about what you were working on. Same with Cursor, Cline, Windsurf. You spend the first few minutes re-explaining the codebase, the decisions you made, where you left off. It’s annoying. I got tired of it and built something to fix it. 每当你开启一个新的 Claude Code 会话时,你的 AI 对你之前的工作内容一无所知。Cursor、Cline 和 Windsurf 也是如此。你不得不花费最初的几分钟重新解释代码库、你做出的决策以及上次中断的地方。这很烦人。我对此感到厌倦,于是开发了一个工具来解决这个问题。
What it does: sessionmem is a local-first MCP server that watches your coding sessions and auto-injects a compact summary at the start of each new one. Your AI instantly knows what you were working on, what decisions were made, and what’s next. The compression is aggressive. Instead of feeding the full conversation history into context (expensive, often impossible due to token limits), sessionmem distills sessions down to just the key facts. In testing we’re seeing 85.6% token reduction compared to keeping full history. 它的功能:sessionmem 是一个“本地优先”的 MCP 服务器,它会监视你的编程会话,并在每个新会话开始时自动注入一份精简摘要。你的 AI 能立即知道你正在做什么、做出了哪些决策以及下一步计划。这种压缩非常高效。sessionmem 不会将完整的对话历史记录放入上下文(这既昂贵,又常因 Token 限制而无法实现),而是将对话提炼为关键事实。在测试中,与保留完整历史记录相比,Token 占用减少了 85.6%。
Everything is stored in SQLite at ~/.sessionmem/memories.db. No cloud, no account, no API keys, no config files to mess with. Works with everything MCP-compatible: Claude Code, Cursor, Cline, Windsurf, and any other MCP host.
所有数据都存储在 ~/.sessionmem/memories.db 的 SQLite 数据库中。无需云端、无需账户、无需 API 密钥,也无需处理复杂的配置文件。它适用于所有兼容 MCP 的工具:Claude Code、Cursor、Cline、Windsurf 以及任何其他 MCP 主机。
Getting started: Install in 30 seconds: npx sessionmem. Then add to your MCP config:
开始使用:30 秒即可安装:npx sessionmem。然后将其添加到你的 MCP 配置中:
{
"mcpServers": {
"sessionmem": {
"command": "npx",
"args": ["-y", "sessionmem"]
}
}
}
That’s it. sessionmem starts watching your sessions immediately and builds up memory over time. 就是这样。sessionmem 会立即开始监视你的会话,并随着时间的推移积累记忆。
Why local-first: Your code is sensitive. Your thought process, architecture decisions, and in-progress work shouldn’t be sent to a third-party service. SQLite is fast and zero-dependency. Works offline, no daemon to manage, no Docker. You own your data. The database file is right there at ~/.sessionmem/memories.db - readable, deletable, no lock-in.
为什么选择“本地优先”:你的代码是敏感的。你的思考过程、架构决策和正在进行的工作不应发送给第三方服务。SQLite 速度快且零依赖。它支持离线工作,无需管理守护进程,也无需 Docker。你拥有自己的数据。数据库文件就在 ~/.sessionmem/memories.db,可读、可删,不存在厂商锁定。
How the memory works: After each session, sessionmem generates a compact summary capturing: what you were building, key decisions made, files touched, and what’s left to do. Next time you start a session, this gets injected automatically before you type anything. The summaries get better at capturing what matters in your specific workflow over time. 记忆的工作原理:在每次会话结束后,sessionmem 会生成一份精简摘要,记录:你正在构建的内容、做出的关键决策、涉及的文件以及待办事项。下次你开始会话时,这些内容会在你输入任何信息之前自动注入。随着时间的推移,这些摘要会越来越精准地捕捉到你特定工作流中的重点。
Links: GitHub: https://github.com/catfish-1234/sessionmem npm: https://www.npmjs.com/package/sessionmem 链接: GitHub: https://github.com/catfish-1234/sessionmem npm: https://www.npmjs.com/package/sessionmem
Would love feedback if you try it out - especially on whether the right context is being captured in the summaries. 如果你试用了这个工具,欢迎提供反馈——特别是关于摘要是否准确捕捉到了关键上下文。