A Model Context Protocol (MCP) server providing long-term memory storage for LLMs using a NoSQL database (TinyDB).
- 🧠 Long-term memory storage across conversations
- 🔍 Search by keywords and tags
- 📊 Access tracking and statistics
- 🐳 Docker & Docker Compose ready
- 🌐 HTTP REST API for easy testing
- 💾 Persistent storage with TinyDB
# Clone or create the repository
mkdir mcp-memory-server
cd mcp-memory-server
# Create all required files (see repository structure below)
# Start the server
docker-compose up -d
# Check logs
docker-compose logs -f
# Test the server
curl http://localhost:9393/health# Install dependencies
pip install -r requirements.txt
# Run the server
python server.pycurl http://localhost:9393/healthcurl -X POST http://localhost:9393/memories \
-H "Content-Type: application/json" \
-d '{
"content": "User prefers dark mode",
"tags": ["preference", "ui"],
"metadata": {"importance": "high"}
}'# Search by keyword
curl -X POST http://localhost:9393/memories/search \
-H "Content-Type: application/json" \
-d '{"query": "dark mode", "limit": 5}'
# Search by tags
curl -X POST http://localhost:9393/memories/search \
-H "Content-Type: application/json" \
-d '{"tags": ["preference"], "limit": 10}'curl http://localhost:9393/memories/1curl -X PUT http://localhost:9393/memories/1 \
-H "Content-Type: application/json" \
-d '{"content": "User prefers dark mode with blue accent"}'curl -X DELETE http://localhost:9393/memories/1curl http://localhost:9393/memories/recent?limit=10curl http://localhost:9393/memories/frequent?limit=10curl http://localhost:9393/statscurl http://localhost:9393/tagsmcp-memory-server/
├── server.py # Main server code
├── requirements.txt # Python dependencies
├── Dockerfile # Docker image definition
├── docker-compose.yml # Docker Compose configuration
├── README.md # This file
├── .gitignore # Git ignore rules
└── data/ # Persistent data directory
└── memory_bank.json # TinyDB database (created automatically)
The server runs on port 9393 by default. To change:
- Update
docker-compose.ymlports mapping - Update the port in
server.py(line withTCPSite)
To use with Claude Desktop or other MCP clients:
{
"mcpServers": {
"memory": {
"command": "docker",
"args": ["run", "-i", "--rm", "-v", "./data:/data", "mcp-memory-server"]
}
}
}# Build the Docker image
docker build -t mcp-memory-server .
# Run with custom data directory
docker run -p 9393:9393 -v $(pwd)/custom-data:/data mcp-memory-server
# View logs
docker-compose logs -f
# Stop the server
docker-compose downThe database is stored in /data/memory_bank.json inside the container, which is mounted to ./data/ on your host machine. This ensures memories persist across container restarts.
MIT