Enables version control and backup operations for memory storage, providing Git integration for tracking changes to memory data and creating backups
Provides integration with Obsidian vaults for long-term memory storage, allowing AI to automatically promote important memories to permanent Markdown files with YAML frontmatter and wikilinks
Mnemex: Temporal Memory for AI
A Model Context Protocol (MCP) server providing human-like memory dynamics for AI assistants. Memories naturally fade over time unless reinforced through use, mimicking the Ebbinghaus forgetting curve.
π§ ACTIVE DEVELOPMENT - EXPECT BUGS π§
This project is under active development and should be considered experimental. You will likely encounter bugs, breaking changes, and incomplete features. Use at your own risk. Please report issues on GitHub, but understand that this is research code, not production-ready software.
Known issues:
Editable installs require
PYTHONPATH
workaround in Claude configAPI may change without notice between versions
Documentation may be out of sync with latest changes
Test coverage is incomplete
π New to this project? Start with the ELI5 Guide for a simple explanation of what this does and how to use it.
Overview
This repository contains research, design, and a complete implementation of a short-term memory system that combines:
Novel temporal decay algorithm based on cognitive science
Reinforcement learning through usage patterns
Two-layer architecture (STM + LTM) for working and permanent memory
Smart prompting patterns for natural LLM integration
Git-friendly storage with human-readable JSONL
Knowledge graph with entities and relations
Why Mnemex?
π Privacy & Transparency
All data stored locally on your machine - no cloud services, no tracking, no data sharing.
Short-term memory: Human-readable JSONL files (
~/.config/mnemex/jsonl/
)One JSON object per line
Easy to inspect, version control, and backup
Git-friendly format for tracking changes
Long-term memory: Markdown files optimized for Obsidian
YAML frontmatter with metadata
Wikilinks for connections
Permanent storage you control
You own your data. You can read it, edit it, delete it, or version control it - all without any special tools.
Core Algorithm
The temporal decay scoring function:
$$ \Large \text{score}(t) = (n_{\text{use}})^\beta \cdot e^{-\lambda \cdot \Delta t} \cdot s $$
Where:
$\large n_{\text{use}}$ - Use count (number of accesses)
$\large \beta$ (beta) - Sub-linear use count weighting (default: 0.6)
$\large \lambda = \frac{\ln(2)}{t_{1/2}}$ (lambda) - Decay constant; set via half-life (default: 3-day)
$\large \Delta t$ - Time since last access (seconds)
$\large s$ - Strength parameter $\in [0, 2]$ (importance multiplier)
Thresholds:
$\large \tau_{\text{forget}}$ (default 0.05) β if score < this, forget
$\large \tau_{\text{promote}}$ (default 0.65) β if score β₯ this, promote (or if $\large n_{\text{use}}\ge5$ in 14 days)
Decay Models:
PowerβLaw (default): heavier tail; most humanβlike retention
Exponential: lighter tail; forgets sooner
TwoβComponent: fast early forgetting + heavier tail
See detailed parameter reference, model selection, and worked examples in docs/scoring_algorithm.md.
Tuning Cheat Sheet
Balanced (default)
Half-life: 3 days (Ξ» β 2.67e-6)
Ξ² = 0.6, Ο_forget = 0.05, Ο_promote = 0.65, use_countβ₯5 in 14d
Strength: 1.0 (bump to 1.3β2.0 for critical)
Highβvelocity context (ephemeral notes, rapid switching)
Half-life: 12β24 hours (Ξ» β 1.60e-5 to 8.02e-6)
Ξ² = 0.8β0.9, Ο_forget = 0.10β0.15, Ο_promote = 0.70β0.75
Long retention (research/archival)
Half-life: 7β14 days (Ξ» β 1.15e-6 to 5.73e-7)
Ξ² = 0.3β0.5, Ο_forget = 0.02β0.05, Ο_promote = 0.50β0.60
Preference/decision heavy assistants
Half-life: 3β7 days; Ξ² = 0.6β0.8
Strength defaults: 1.3β1.5 for preferences; 1.8β2.0 for decisions
Aggressive space control
Raise Ο_forget to 0.08β0.12 and/or shorten half-life; schedule weekly GC
Environment template
MNEMEX_DECAY_LAMBDA=2.673e-6, MNEMEX_DECAY_BETA=0.6
MNEMEX_FORGET_THRESHOLD=0.05, MNEMEX_PROMOTE_THRESHOLD=0.65
MNEMEX_PROMOTE_USE_COUNT=5, MNEMEX_PROMOTE_TIME_WINDOW=14
Decision thresholds:
Forget: $\text{score} < 0.05$ β delete memory
Promote: $\text{score} \geq 0.65$ OR $n_{\text{use}} \geq 5$ within 14 days β move to LTM
Key Innovations
1. Temporal Decay with Reinforcement
Unlike traditional caching (TTL, LRU), memories are scored continuously based on:
Recency - Exponential decay over time
Frequency - Use count with sub-linear weighting
Importance - Adjustable strength parameter
This creates memory dynamics that closely mimic human cognition.
2. Smart Prompting System
Patterns for making AI assistants use memory naturally:
Auto-Save
Auto-Recall
Auto-Reinforce
No explicit memory commands needed - just natural conversation.
3. Two-Layer Architecture
Project Structure
Quick Start
Installation
Configuration
Copy .env.example
to .env
and configure:
MCP Configuration
Add to your Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json
):
Important:
Replace
/path/to/mnemex
with your actual repository pathThe
PYTHONPATH
environment variable is required for editable installsStorage paths are configured in your
.env
file, not in the MCP config
Maintenance
Use the maintenance CLI to inspect and compact JSONL storage:
Migrating from STM Server
If you previously used this project as "STM Server", use the migration tool:
The migration tool will:
Copy JSONL files from
~/.stm/jsonl/
to~/.config/mnemex/jsonl/
Optionally rename environment variables (STM_* β MNEMEX_*)
Create backups before making changes
Provide clear next-step instructions
After migration, update your Claude Desktop config to use mnemex
instead of stm
.
CLI Commands
The server includes 7 command-line tools:
MCP Tools
10 tools for AI assistants to manage memories:
Tool | Purpose |
| Save new memory with tags, entities |
| Search with filters and scoring |
| Unified search across STM + LTM |
| Reinforce memory (boost strength) |
| Garbage collect low-scoring memories |
| Move to long-term storage |
| Find similar memories |
| Merge duplicates (LLM-driven) |
| Get entire knowledge graph |
| Retrieve specific memories |
| Link memories explicitly |
Example: Unified Search
Search across STM and LTM with the CLI:
Example: Reinforce (Touch) Memory
Boost a memory's recency/use count to slow decay:
Sample response:
Example: Promote Memory
Suggest and promote high-value memories to the Obsidian vault.
Auto-detect (dry run):
Promote a specific memory:
As an MCP tool (request body):
Mathematical Details
Decay Curves
For a memory with $n_{\text{use}}=1$, $s=1.0$, and $\lambda = 2.673 \times 10^{-6}$ (3-day half-life):
Time | Score | Status |
0 hours | 1.000 | Fresh |
12 hours | 0.917 | Active |
1 day | 0.841 | Active |
3 days | 0.500 | Half-life |
7 days | 0.210 | Decaying |
14 days | 0.044 | Near forget |
30 days | 0.001 | Forgotten |
Use Count Impact
With $\beta = 0.6$ (sub-linear weighting):
Use Count | Boost Factor |
1 | 1.0Γ |
5 | 2.6Γ |
10 | 4.0Γ |
50 | 11.4Γ |
Frequent access significantly extends retention.
Documentation
Scoring Algorithm - Complete mathematical model with LaTeX formulas
Smart Prompting - Patterns for natural LLM integration
Architecture - System design and implementation
API Reference - MCP tool documentation
Graph Features - Knowledge graph usage
Use Cases
Personal Assistant (Balanced)
3-day half-life
Remember preferences and decisions
Auto-promote frequently referenced information
Development Environment (Aggressive)
1-day half-life
Fast context switching
Aggressive forgetting of old context
Research / Archival (Conservative)
14-day half-life
Long retention
Comprehensive knowledge preservation
License
MIT License - See LICENSE for details.
Clean-room implementation. No AGPL dependencies.
Related Work
Model Context Protocol - MCP specification
Ebbinghaus Forgetting Curve - Cognitive science foundation
Research inspired by: Memoripy, Titan MCP, MemoryBank
Citation
If you use this work in research, please cite:
Contributing
This is a research project. Contributions welcome! Please:
Read the Architecture docs
Understand the Scoring Algorithm
Follow existing code patterns
Add tests for new features
Update documentation
Status
Version: 1.0.0 Status: Research implementation - functional but evolving
Phase 1 (Complete) β
10 MCP tools
Temporal decay algorithm
Knowledge graph
Phase 2 (Complete) β
JSONL storage
LTM index
Git integration
Smart prompting documentation
Maintenance CLI
Future Work
Spaced repetition optimization
Adaptive decay parameters
Enhanced clustering algorithms
Performance benchmarks
Built with Claude Code π€
local-only server
The server can only run on the client's local machine because it depends on local resources.
Tools
Provides human-like memory dynamics for AI assistants where memories naturally fade over time unless reinforced through use, mimicking the Ebbinghaus forgetting curve. Enables automatic saving, searching, and management of contextual information with temporal decay algorithms.