A Model Context Protocol (MCP) server that provides autonomous memory persistence for Claude Desktop.
Claude Desktop Memory Bank is an MCP server that enables Claude to automatically maintain context and memory across sessions. It works as an auxiliary memory system that stores and organizes important information without requiring manual management by users.
The system supports three types of memory banks:
- Global Memory Bank: For general conversations not tied to specific projects
- Project Memory Banks: Linked to Claude Desktop projects
- Repository Memory Banks: Located inside Git repositories for code-related work
- Claude Desktop app installed
- Python 3.8 or newer
- Git (for repository memory banks)
-
Clone the repository:
git clone https://github.com/yourusername/claude-desktop-memory-bank.git cd claude-desktop-memory-bank -
Install the memory bank server:
pip install -e . -
Configure Claude Desktop:
Locate the Claude Desktop configuration file and add the memory bank server configuration:
{ "mcpServers": { "memory-bank": { "command": "python", "args": ["-m", "memory_bank_server"], "env": { "MEMORY_BANK_ROOT": "/path/to/your/storage/directory", "ENABLE_REPO_DETECTION": "true" } } } } -
Restart Claude Desktop
- Background Operation: Claude manages memory banks without user interaction
- Intelligent Context Persistence: Automatically identifies and persists important information
- Seamless Context Retrieval: Leverages stored context in conversations without explicit commands
- Automatic Context Pruning: Keeps memory banks organized by removing outdated information
- Section-based Updates: Supports targeted updates to specific sections within context files
- Global Memory Bank: For general context across all conversations
- Project Memory Banks: Context linked to specific Claude Desktop projects
- Repository Memory Banks: Context stored directly within Git repositories with branch detection
- Reduced Cognitive Load: Users don't need to manually manage what Claude remembers
- Conversation Continuity: Previous context flows naturally into new conversations
- Development Support: Code and project knowledge persists across sessions
- Team Collaboration: Repository memory banks can be shared via version control
- Enhanced Project Management: Keep project briefs, progress tracking, and technical decisions organized
The Memory Bank system implements the Model Context Protocol (MCP) v1.4.0+ with the following tools:
- context_activate: Activate the memory bank with context-aware detection
- context_select: Select which memory bank to use for the conversation
- context_update: Update multiple context files in one operation. Accepts a dictionary of updates where keys are context types ("project_brief", "system_patterns", "active_context", etc.) and values can be either: 1) string with complete new content, or 2) dictionary mapping section headers to new section content (for targeted updates). All updates are applied atomically with verification.
- context_list: List all available memory banks
Each memory bank manages six types of context:
- project_brief: Project purpose, goals, requirements, and scope
- product_context: Problem, solution, user experience, and stakeholders
- system_patterns: Architecture, patterns, technical decisions, and relationships
- tech_context: Technologies, setup, constraints, and dependencies
- active_context: Current focus, recent changes, next steps, and watchdog
- progress: Completed tasks, in-progress work, pending items, and issues
The server also provides access to context via MCP resources:
resource://project-brief: Access the project briefresource://active-context: Access the active contextresource://progress: Access progress notesresource://all-context: Access all context combinedresource://memory-bank-info: Access information about the current memory bank
For detailed usage instructions and tool documentation, see the Usage and Tools Guide.
For information on the architecture and implementation, see:
To maximize the chance of autonomous operation, it's recommended to add the following directives to your Claude prompt:
# MCP Memory-Bank Tool Usage
0. **🔴 DIRECTIVE: CONTEXT_ACTIVATE**
WHEN: immediately BEFORE delivering the FIRST response to the user PRIORITY: SYSTEM CRITICAL (HIGHEST) ACTION: CALL context_activate WITH appropriate parameters EXAMPLE: context.activate(current_path="/path/to/repo", project_name="ProjectName", project_description="Description")
1. **🔴 DIRECTIVE: EXECUTE MEMORY BANK CUSTOM INSTRUCTION**
WHEN: IMMEDIATELY after context_activate COMPLETES PRIORITY: SYSTEM CRITICAL (HIGHEST) ACTION: EXECUTE Custom Instructions for Claude Desktop Memory Bank
These directives ensure that:
- The memory bank is activated automatically at the beginning of each conversation
- Custom instructions for memory bank management are properly loaded
- Context persistence is handled without requiring user intervention
The system automatically prunes outdated information to keep memory banks organized:
- Different retention policies for different context types:
- Core architectural decisions (system_patterns): 180 days
- Technology choices (tech_context): 90 days
- Progress updates (progress, active_context): 30 days
- Other content: 90 days (default)
- Pruning identifies dated sections using the format
## Update YYYY-MM-DDand removes sections older than the cutoff date
The system has integration with Git repositories:
- Automatically detects Git repositories when activating memory banks
- Identifies and records the current branch name
- Displays branch information in memory bank details
- Associates repositories with projects when applicable
This project is licensed under the MIT License - see the LICENSE file for details.