Production-ready MCP server providing shared memory for multi-agent collaboration.
MCP Agent Memory - v2.0
Production-ready MCP server providing shared memory for multi-agent collaboration.
Overview
MCP Agent Memory is an enhanced Model Context Protocol (MCP) server that enables multiple AI agents (like Claude Code instances) to communicate asynchronously through a shared memory space. Think of it as a sophisticated shared notepad where AI agents can leave messages, search for information, and coordinate their work.
Key Features
- ๐ Concurrency Safe - File locking for shared environments
- ๐ Full CRUD - Create, Read, Update, Delete operations
- ๐ Advanced Search - Full-text search across all fields
- ๐ท๏ธ Organization - Tags, priority levels, metadata
- ๐ Analytics - Comprehensive memory statistics
- ๐พ Reliable - Automatic backups and corruption recovery
- ๐ Structured Logging - Complete operation visibility
- ๐ก๏ธ Health Monitoring - Built-in health check system
Quick Start
Installation
- Clone or download this repository
- Install dependencies:
pip install mcp pydantic - Run the server:
python3 shared_memory_mcp.py
Basic Usage
# Add a memory entry
await add_memory(
agent_name="claude-alpha",
content="Analysis complete. Found 3 key insights.",
tags=["analysis", "complete"],
priority="high"
)
# Search for entries
results = await search_memory(query="analysis")
# Get statistics
stats = await get_memory_stats()
Configuration
Add to your Claude Code config (~/.claudeCode/config.json):
{
"mcpServers": {
"shared-memory": {
"command": "python3",
"args": ["/path/to/shared_memory_mcp.py"]
}
}
}
What's New in v2.0
New Tools (6 total)
- โ
update_memory- Modify existing entries - โ
delete_memory- Remove specific entries - โ
get_memory- Retrieve single entry by ID - โ
search_memory- Full-text search - โ
get_memory_stats- Memory analytics - โ
health_check- System health monitoring
Enhanced Tools
- โก
add_memory- Now supports tags, priority, metadata - โก
read_memory- Advanced filtering and sorting - โก
clear_memory- Auto-backup before clearing
Core Improvements
- ๐ Thread-safe file locking
- ๐พ Automatic backups (keeps 10)
- ๐ Structured logging
- ๐ Auto-rotation at 1000 entries
- ๐ก๏ธ Corruption recovery
- ๐ Unique entry IDs (UUID)
Zero breaking changes! All v1 code works without modification.
Architecture
MCP Agent Memory v2.0
โโโ shared_memory_mcp.py # Main server (9 MCP tools)
โโโ utils/
โ โโโ file_lock.py # Concurrency safety
โ โโโ logger.py # Structured logging
โโโ tests/
โ โโโ test_memory_operations.py
โ โโโ test_concurrency.py
โโโ docs/
โโโ API_REFERENCE_V2.md # Complete API docs
โโโ CHANGELOG_V2.md # Version history
โโโ UPGRADE_GUIDE.md # v1โv2 migration
โโโ IMPLEMENTATION_SUMMARY.md
Storage
~/.shared_memory_mcp/
โโโ memory.json # Main storage
โโโ mcp_memory.log # Rotating logs
โโโ backups/ # Auto-backups (10 kept)
โโโ memory_backup_*.json
Documentation
Getting Started
- ๐ SHARED_MEMORY_README.md - Full user guide
- ๐ Quick Start Guide - 5-minute setup
Reference
- ๐ API Reference - Complete API documentation
- ๐ Changelog - Version 2.0 changes
- โฌ๏ธ Upgrade Guide - Migrate from v1 to v2
Developer
- ๐ง Implementation Summary - Technical details
- ๐งช Testing Guide - How to run tests
- ๐๏ธ Architecture Details - System design
API Overview
Memory Operations
| Tool | Description | Type |
|---|---|---|
add_memory |
Create new entry with tags/priority | Write |
read_memory |
Read with advanced filtering | Read |
update_memory |
Modify existing entry | Write |
delete_memory |
Remove specific entry | Write |
get_memory |
Retrieve single entry by ID | Read |
search_memory |
Full-text search | Read |
get_memory_stats |
Memory analytics | Read |
clear_memory |
Clear all entries | Write |
health_check |
System health status | Read |
See API Reference for detailed documentation.
Testing
Run Basic Tests
python3 run_basic_tests.py
Run Full Test Suite (requires pytest)
pip install pytest pytest-cov
pytest tests/ -v --cov
Test Coverage
- โ 70+ test
Tools (9)
add_memoryCreate new entry with tags, priority, and metadata.read_memoryRead memory entries with advanced filtering and sorting.update_memoryModify existing memory entries.delete_memoryRemove specific memory entries.get_memoryRetrieve a single memory entry by its ID.search_memoryPerform full-text search across all memory fields.get_memory_statsRetrieve memory analytics and statistics.clear_memoryClear all memory entries with an automatic backup.health_checkCheck the system health status.Configuration
{"mcpServers": {"shared-memory": {"command": "python3", "args": ["/path/to/shared_memory_mcp.py"]}}}