Memory MCP Server

Memory MCP Server

Captures live conversation snapshots every 5 prompts and provides semantic recall to maintain context across Claude Code sessions.

Category
访问服务器

README

Memory MCP Server

License: MIT Node.js 20+ MCP Compatible

Claude Code silently compresses older conversation turns to stay within its context window. You have seen it: "111 turns omitted." Every decision, every file path, every nuance from earlier in the session -- gone. This server captures live conversation snapshots every 5 prompts so that context is never lost.


Why This Exists

Claude Code's context compression is aggressive and invisible. Mid-conversation, it drops the exact turns where you discussed architecture, debugged a tricky issue, or agreed on a design. By the time you need that context, it is already gone.

Existing memory solutions bolt on basic RAG -- they index static documents and retrieve them on demand. That helps with long-term recall, but it does nothing for the conversation you are in right now.

This server solves both problems:

  • Live mid-conversation capture. A hook fires every 5 prompts and writes a snapshot of recent turns to your vault. When Claude compresses old turns, the snapshots survive intact.
  • Session-end summaries. When a session ends, a lightweight summary is written with wikilinks back to every snapshot, so you can trace the full conversation later.
  • Semantic recall. On each new prompt, the most relevant memories from your vault are injected into context automatically. Past sessions inform current ones.

The result: Claude Code with a persistent, searchable memory that captures context as it happens, not after the fact.


Features

  • Snapshot capture -- saves conversation turns to markdown every 5 prompts
  • Session summaries -- end-of-session notes with topic, tools used, and links to snapshots
  • Semantic search -- find related memories using Voyage AI embeddings and LanceDB
  • Full-text search -- keyword search across all notes
  • Obsidian-native -- writes standard markdown with frontmatter, works with any vault
  • Auto-recall -- injects relevant memories into context on every prompt
  • File watcher -- auto-reindexes when vault files change on disk

Quick Start

git clone https://github.com/MaybeLOL/memory-mcp-server.git
cd memory-mcp-server
npm install && npm run build

Then add the server to ~/.claude/mcp.json and the hooks to ~/.claude/settings.json (see Configuration below).


How It's Different

Basic RAG Memory This Server
When it captures Manual or end-of-session Live, every 5 prompts
What it captures Static documents Actual conversation turns
Compression recovery None Snapshots preserve compressed turns
Session continuity Keyword lookup Semantic search + auto-recall
Obsidian integration Rarely Native markdown with wikilinks

Most memory tools treat recall as a lookup problem. This server treats it as a continuity problem -- making sure context from 50 turns ago is still available even after Claude Code compresses it away.


Configuration

1. MCP Server

Add to ~/.claude/mcp.json:

{
  "mcpServers": {
    "memory": {
      "command": "node",
      "args": ["/path/to/memory-mcp-server/dist/index.js"],
      "env": {
        "VAULT_PATH": "/path/to/your/vault",
        "DB_PATH": "/path/to/lancedb-data",
        "VOYAGE_API_KEY": "your-voyage-api-key"
      }
    }
  }
}

DB_PATH is where LanceDB stores its vector index. The directory is created automatically.

2. Hooks

Add these hooks to ~/.claude/settings.json. If you already have a settings.json, merge the hooks section into your existing config.

macOS / Linux / Git Bash on Windows:

{
  "hooks": {
    "UserPromptSubmit": [
      {
        "matcher": "*",
        "hooks": [
          {
            "type": "command",
            "command": "VAULT_PATH=\"/path/to/vault\" VOYAGE_API_KEY=\"your-key\" node \"/path/to/memory-mcp-server/dist/recall.js\"",
            "timeout": 15
          },
          {
            "type": "command",
            "command": "VAULT_PATH=\"/path/to/vault\" node \"/path/to/memory-mcp-server/dist/mid-capture.js\"",
            "timeout": 15
          }
        ]
      }
    ],
    "SessionEnd": [
      {
        "matcher": "*",
        "hooks": [
          {
            "type": "command",
            "command": "VAULT_PATH=\"/path/to/vault\" node \"/path/to/memory-mcp-server/dist/capture.js\"",
            "timeout": 30
          }
        ]
      }
    ]
  }
}

Windows (cmd/PowerShell): The inline VAR=value command syntax does not work. Use wrapper scripts or set environment variables in your system settings. If Claude Code uses Git Bash as its shell, the above syntax works as-is.

Replace /path/to/vault and /path/to/memory-mcp-server with your actual paths.

3. Environment Variables

Variable Required Description
VAULT_PATH Yes Absolute path to your Obsidian vault (or any markdown folder)
VOYAGE_API_KEY Yes Voyage AI API key for embeddings
DB_PATH MCP server only Path to LanceDB vector index directory

MCP Tools

Tool Description
memory_write Create or update a note
memory_read Read a note by path
memory_delete Delete a note
memory_search Full-text keyword search across all notes
memory_semantic_search Semantic similarity search via Voyage AI embeddings
memory_list List notes, optionally filtered by folder, type, or tag
memory_index Re-index all notes into the vector database

How It Works

Mid-Conversation Capture

The mid-capture hook runs on every UserPromptSubmit. It maintains a counter at ~/.claude/session-turn-count.json and every 5th prompt:

  1. Reads the conversation transcript JSONL
  2. Extracts all turns since the last snapshot
  3. Writes them to <vault>/conversations/YYYY-MM-DD-session-<slug>-<id>-snap-N.md

Non-capture prompts exit in under 500ms (just a counter increment).

Session-End Summary

When a session ends, the capture hook writes a lightweight summary containing:

  • Topic, tools used, and working directory
  • First and last turn for context
  • Wikilinks to all mid-session snapshots

Recall

On each prompt, the recall hook embeds the user's message via Voyage AI and compares it against all vault notes, then injects the top semantic matches as a system message.

Note: The recall hook re-embeds all notes on every prompt. For large vaults (500+ notes), this may be slow or exceed the 15s timeout. Consider increasing the timeout or reducing vault size if needed.


Prerequisites

  • Node.js 20+
  • A Voyage AI API key (for embeddings)
  • An Obsidian vault or any folder of markdown files

Troubleshooting

MCP server not connecting: Check that VAULT_PATH, DB_PATH, and VOYAGE_API_KEY are all set. Run manually to see errors:

VAULT_PATH=/path/to/vault DB_PATH=/path/to/db VOYAGE_API_KEY=your-key node dist/index.js

Hooks not firing: Verify your ~/.claude/settings.json is valid JSON. Check that file paths in hook commands are correct and absolute.

npm install fails on LanceDB: The @lancedb/lancedb package includes native binaries. If you are behind a proxy or on an unsupported platform, the download may fail. See LanceDB docs for platform support.

Recall is slow: For vaults with many notes, the recall hook may time out. Increase the timeout value in your hook config, or reduce the number of notes in your vault.


License

MIT

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选