情景+实体记忆 MCP 服务
Project description
Memory MCP Service
A scenario + entity memory MCP service that provides persistent memory capabilities for Claude Code.
Features
- Episodes: Dialogue scenes divided by task/function
- Entities: Structured knowledge units (decisions, concepts, preferences, etc.)
- Dual-layer storage: User-level (cross-project) + Project-level (project isolated)
- Real-time cache: Messages are stored in real-time to prevent loss
- Semantic retrieval: Vector-based semantic search
Installation
Windows One-click Installation
Run install.bat file in the project root directory:
install.bat
Mac/Linux One-click Installation
chmod +x install.sh
./install.sh
The installation script will automatically create a Python 3.10 virtual environment (
venv310) and install dependencies.
Configure Claude Code
Important
This package depends on chromadb which uses Pydantic V1, not compatible with Python 3.14+.
Required: Use local source code with venv310 virtual environment (Python 3.10).
Add MCP Server
# Windows:
claude mcp add memory-mcp -s user -- "C:\path\to\memory-mcp\venv310\Scripts\python.exe" -m src.server
# Mac/Linux:
claude mcp add memory-mcp -s user -- /path/to/memory-mcp/venv310/bin/python -m src.server
Manual Configuration File
Edit ~/.claude/settings.json and add:
{
"mcpServers": {
"memory-mcp": {
"command": "C:\\path\\to\\memory-mcp\\venv310\\Scripts\\python.exe",
"args": ["-m", "src.server"],
"cwd": "C:\\path\\to\\memory-mcp"
}
}
}
Configure Hooks (Optional)
Hooks enable automatic message saving. Once configured, conversations will be saved without manual memory tool calls.
Add the following hooks configuration to ~/.claude/settings.json:
pip install (recommended, works on all platforms):
{
"hooks": {
"SessionStart": [{
"matcher": ".*",
"hooks": [{
"type": "command",
"command": "memory-mcp-session-start"
}]
}],
"UserPromptSubmit": [{
"matcher": ".*",
"hooks": [{
"type": "command",
"command": "memory-mcp-auto-save"
}]
}],
"Stop": [{
"matcher": ".*",
"hooks": [{
"type": "command",
"command": "memory-mcp-save-response"
}]
}],
"SessionEnd": [{
"matcher": ".*",
"hooks": [{
"type": "command",
"command": "memory-mcp-session-end"
}]
}]
}
}
Local source code installation (alternative)
Mac/Linux:
{
"hooks": {
"SessionStart": [{
"matcher": ".*",
"hooks": [{
"type": "command",
"command": "/path/to/venv310/bin/python",
"args": ["/path/to/memory-mcp/session_start.py"]
}]
}],
"UserPromptSubmit": [{
"matcher": ".*",
"hooks": [{
"type": "command",
"command": "/path/to/venv310/bin/python",
"args": ["/path/to/memory-mcp/auto_save.py"]
}]
}],
"Stop": [{
"matcher": ".*",
"hooks": [{
"type": "command",
"command": "/path/to/venv310/bin/python",
"args": ["/path/to/memory-mcp/save_response.py"]
}]
}],
"SessionEnd": [{
"matcher": ".*",
"hooks": [{
"type": "command",
"command": "/path/to/venv310/bin/python",
"args": ["/path/to/memory-mcp/session_end.py"]
}]
}]
}
}
Windows (requires cmd wrapper):
{
"hooks": {
"SessionStart": [{
"matcher": ".*",
"hooks": [{
"type": "command",
"command": "cmd",
"args": ["/c", "C:\\path\\to\\memory-mcp\\venv310\\Scripts\\python.exe", "C:\\path\\to\\memory-mcp\\session_start.py"]
}]
}],
"UserPromptSubmit": [{
"matcher": ".*",
"hooks": [{
"type": "command",
"command": "cmd",
"args": ["/c", "C:\\path\\to\\memory-mcp\\venv310\\Scripts\\python.exe", "C:\\path\\to\\memory-mcp\\auto_save.py"]
}]
}],
"Stop": [{
"matcher": ".*",
"hooks": [{
"type": "command",
"command": "cmd",
"args": ["/c", "C:\\path\\to\\memory-mcp\\venv310\\Scripts\\python.exe", "C:\\path\\to\\memory-mcp\\save_response.py"]
}]
}],
"SessionEnd": [{
"matcher": ".*",
"hooks": [{
"type": "command",
"command": "cmd",
"args": ["/c", "C:\\path\\to\\memory-mcp\\venv310\\Scripts\\python.exe", "C:\\path\\to\\memory-mcp\\session_end.py"]
}]
}]
}
}
Hooks Description:
| Hook Name | Purpose | Weight |
|---|---|---|
| SessionStart | Create new episode (lightweight JSON ops, no chromadb) | ~50ms |
| UserPromptSubmit | Save user messages + entity detection + memory retrieval | ~1-2s |
| Stop | Save assistant responses | ~1s |
| SessionEnd | Write close signal + remove project trust (no chromadb) | ~50ms |
Note: SessionStart and SessionEnd hooks are lightweight — they do not import MemoryManager/chromadb to avoid the heavy initialization cost (10-30s). Episode closing and archiving is handled by the background monitor process.
Verify Configuration
claude mcp list
Expected output should show memory-m-mcp: ... - ✓ Connected
Usage
Automatic Mode (With Hooks)
After configuring hooks, conversations are automatically saved without manual operation.
Manual Mode
Manually call memory tools:
# Start a new task
memory_start("Login Function Development", ["auth"])
# Record a decision
memory_add_entity("Decision", "Adopt JWT + Redis solution", "Consider distributed deployment")
# Retrieve history
memory_recall("Login scheme")
# Close task
memory_close_episode("Completed JWT login function development")
Tools List
memory_start_episode: Start a new episodememory_close_episode: Close an episodememory_get_current_episode: Get current episodememory_add_entity: Add entitymemory_confirm_entity: Confirm candidate entitymemory_reject_candidate: Reject candidatememory_deprecate_entity: Deprecate entitymemory_get_pending: Get pending entitiesmemory_recall: Comprehensive retrievalmemory_search_by_type: Search by typememory_get_episode_detail: Get episode detailmemory_list_episodes: List all episodes by timememory_stats: Get statisticsmemory_encoder_status: Check encoder statusmemory_cache_message: Manually cache a messagememory_clear_cache: Clear message cachememory_cleanup_messages: Clean up old messages
Entity Types
User-level (cross-project shared)
Preference: User preferencesConcept: General conceptsHabit: Work habits
Project-level (project isolated)
Decision: Project decisionsEpisode: Development episodesFile: File descriptionsArchitecture: Architecture designs
Storage Locations
- User-level:
~/.claude-memory/(Windows:%APPDATA%/claude-memory/) - Project-level:
{project-root}/.claude/memory/
License
MIT License - see LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file chenxiaofie_memory_mcp-0.2.0.tar.gz.
File metadata
- Download URL: chenxiaofie_memory_mcp-0.2.0.tar.gz
- Upload date:
- Size: 24.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
afdc1025792946de5f208f2ca7e6bef878751ebc59cd345f35b8178a342619d8
|
|
| MD5 |
2a19704d5390053ecc3f445f860c1cb1
|
|
| BLAKE2b-256 |
8da3ba0050fb9e432822335d560006cb712c6b708d4929b726196a04de71b179
|
File details
Details for the file chenxiaofie_memory_mcp-0.2.0-py3-none-any.whl.
File metadata
- Download URL: chenxiaofie_memory_mcp-0.2.0-py3-none-any.whl
- Upload date:
- Size: 31.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
93957c10421085a64f28879666e13aaf9f4ec33194910aa86391a73592938d08
|
|
| MD5 |
4b33dedfdf7c0934a4dae92b52e6fe6d
|
|
| BLAKE2b-256 |
e8c2df4319f7d050af43c4ddd73f51cb68739be0db9160fc2d2ddd02a7502a42
|