-
Notifications
You must be signed in to change notification settings - Fork 9.9k
Description
Problem
The MCP memory server stores observations indefinitely. Over weeks and months of use, the knowledge graph accumulates stale data — expired decisions, superseded findings, session-specific notes that are no longer relevant. There is no built-in mechanism to expire or lifecycle observations.
Users who want observation lifecycle management must build external tooling that:
- Parses the NDJSON storage file directly (bypassing the MCP tool interface)
- Implements date parsing and TTL logic
- Handles concurrent access (e.g., flock)
- Performs atomic file replacement
- Maintains backup and audit trails
This is significant engineering for what should be a core feature of a persistence layer, and it's fragile — any change to the storage format breaks external tooling that bypasses the MCP interface.
Proposed Solution
Add optional TTL metadata to observations:
Option A: Simple TTL (minimal schema change)
{
"entityName": "Architecture Decision",
"contents": ["Chose FastAPI over Flask for the API layer"],
"ttl": 90
}The ttl field specifies days until expiry from creation. The server would automatically exclude expired observations from open_nodes and search_nodes results, and remove them during periodic cleanup or on write.
Option B: Decay classes (richer model)
{
"entityName": "Architecture Decision",
"contents": ["Chose FastAPI over Flask for the API layer"],
"decay": "operational"
}Decay classes map to configurable TTLs: session (default 30 days), operational (default 90 days), permanent (no expiry, default for backwards compatibility). This is a pattern that emerged from building external lifecycle tooling — different observation types have naturally different shelf lives.
Supporting features
- A
created_attimestamp on each observation (currently must be embedded in the observation text manually) search_nodeswith anexclude_expired: trueparameter (default true)- A
prunetool that removes expired observations on demand - An
expire_beforeparameter onsearch_nodesfor stale observation detection
Current Workaround
External script (~200 lines of bash/jq) that:
- Runs once per day as a background process
- Reads the NDJSON storage file line-by-line
- Classifies observations by text prefix into decay tiers
- Parses embedded dates and review-by suffixes from observation text
- Deletes expired observations, rebuilds entity lines
- Backs up before modification, uses flock for concurrent access safety, writes audit trail
This works but bypasses the MCP interface entirely (direct file manipulation), which won't survive any change to the storage format and can't benefit from any future server-side optimisations.
Impact
As more users adopt MCP memory for cross-session context, observation bloat will be a universal pain point. Native TTL support would:
- Eliminate the need for external eviction scripts
- Ensure lifecycle management works through the MCP tool interface (not direct file access)
- Enable better memory hygiene defaults for new users
- Provide a foundation for richer observation metadata (created_at, updated_at, decay class)