项目内存管理服务器

一个为Claude Code提供项目内存管理的MCP服务器,支持智能关键词匹配、检索和自动内容验证。

  • by JerryZhongJ
  • Python
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 JerryZhongJ/memory-mcp

使用说明

英语| 简体中文

存储器MCP

为Claude Code提供项目内存管理的MCP服务器。

快速开始

先决条件

选项1:通过CLI安装(推荐)

直接从GitHub安装(无需下载):

# Add to current project (local scope)
claude mcp add memory \
  --env ANTHROPIC_API_KEY=$ANTHROPIC_API_KEY \
  -- uvx --from git+https://github.com/JerryZhongJ/memory-mcp.git memory-mcp --project $(pwd)

选项2:本地开发安装

如果您需要修改源代码或为开发做出贡献:

# 1. Clone the repository
git clone https://github.com/JerryZhongJ/memory-mcp.git
cd memory-mcp

# 2. Install dependencies
uv sync

# 3. Add to Claude Code
claude mcp add memory \
  --env ANTHROPIC_API_KEY=$ANTHROPIC_API_KEY \
  -- uv --directory /path/to/memory-mcp run memory-mcp --project $(pwd)

验证安装

配置后,Claude Code将自动加载服务器。您可以通过以下方式进行验证:

# List all configured MCP servers
claude mcp list

# Use /mcp command in Claude Code to check server status

管理服务器

# Remove server
claude mcp remove memory

# View server details
claude mcp get memory

运作原理

  • 记忆以Markdown文件的形式存储在项目的 .memories 目录
  • 使用智能关键字匹配和检索
  • LLM会自动决定是创建新内存还是更新现有内存
  • 自动验证内容大小和相关性
  • 具有自动后端生命周期管理的前端后端分离架构

配置CLAUDE.md

为了帮助Claude更好地使用此MCP服务,建议创建一个 .claude/CLAUDE.md 使用以下使用规则在项目中创建文件:

# Project Memory Management Rules

## ⚠️ Mandatory Rules (Must Be Strictly Followed)

### 1. Query Memory Before Starting Tasks

**Every time you receive a user question, the first step must be to use `recall_memory_tool` to query relevant information.**

Do not rely on judgment to decide whether to query. Any question may be related to existing memories.

### 2. Save New Information Immediately Upon Discovery

**Whenever you obtain valuable new information through investigation, you must immediately use `memorize_memory_tool` to save it.**

Save the information as soon as you discover it, don't wait until after answering the user's question.

**Standard Workflow**:
```
User Question → Query Memory → Investigate Code/Docs → Discover New Info → Save Immediately → Answer User
```

**Important**: Skipping these steps leads to duplicate work, inconsistent answers, and knowledge loss.

许可证

麻省理工学院