Skip to main content
Glama

🧠 MemCurve

Persistent memory for AI assistants β€” with forgetting curves, decay, and graph clustering.

Python License MCP Domain

CortexGraph MCP server. Stores memories as a weighted knowledge graph, decays stale nodes via configurable half-life, clusters related memories, and surfaces the right context at the right time through activation-pattern retrieval.


🧠 What Is This?

For non-technical readers: Most AI assistants have no persistent memory β€” every conversation starts completely blank. MemCurve gives an AI assistant long-term memory that works like human memory: important things are remembered more strongly, rarely-accessed memories fade over time, and related memories are grouped together so that recalling one makes nearby ones more accessible. It exposes this memory system to AI tools via a standard protocol (MCP), so any compatible assistant can use it.


Related MCP server: my-memory-mcp

πŸ—οΈ CortexGraph Architecture

MemCurve implements the CortexGraph memory system β€” a weighted knowledge graph where nodes are memory entities, edges encode semantic relationships, and node weights decay over time according to configurable half-life schedules. Retrieval uses activation spreading: querying one node activates its neighbors with diminishing strength, surfacing contextually related memories.

πŸ’¬ Conversation / Tool Call
         β”‚
         β–Ό
πŸ” Entity Extraction & Message Analysis
   Detects entities, topics, facts, and relationships
   worth persisting in the memory graph
         β”‚
         β–Ό
🧠 CortexGraph (Weighted Knowledge Graph)
   β”œβ”€β”€ Nodes: memories, facts, entities
   β”œβ”€β”€ Edges: semantic relations + co-occurrence weights
   └── Node weights: decay via half-life schedule
         β”‚
         β”œβ”€β”€ ⏱️  Background Decay Process
         β”‚       Stale memory weights decay exponentially
         β”‚       GC prunes nodes below activation threshold
         β”‚
         └── πŸ”— Memory Clustering
                 Related nodes grouped into clusters
                 for efficient neighborhood retrieval
         β”‚
         β–Ό
πŸ”Ž Activation-Pattern Retrieval
   Query activates seed nodes, spreads to neighbors
   Returns ranked memory context for generation

πŸ”¬ Technical Design

Half-Life Decay β€” Memory node weights decay exponentially over time: w(t) = wβ‚€ Γ— (Β½)^(t/Ο„) where Ο„ is the configurable half-life. Frequently accessed memories are "touched" (weight refreshed) on each recall, preventing useful information from decaying. The decay function is calculated by cortexgraph.core.decay.calculate_halflife and runs on a background scheduler.

MCP Tool Surface β€” CortexGraph exposes memory operations as MCP tools that any compatible AI client can call:

Tool

Purpose

save

Persist a new memory entity to the graph

search

Semantic search over memory nodes

search_unified

Combined graph traversal + semantic search

auto_recall_tool

Context-aware memory retrieval based on current conversation

analyze_message

Extract entities and facts worth saving from a message

cluster

Group related memories into topic clusters

consolidate

Merge redundant or contradictory memory nodes

gc

Prune decayed nodes below activation threshold

promote

Boost a memory node's weight (mark as important)

touch

Refresh a node's decay timer without modifying weight

Activation Spreading β€” On search_unified, queried seed nodes activate their graph neighbors with weight proportional to edge strength Γ— query relevance. This surfaces associated memories without requiring exact semantic match β€” related context emerges from graph structure.

Security Layer β€” The server includes secret scanning on config files (should_warn_about_secrets) and enforces secure storage paths (ensure_secure_storage) before starting β€” preventing accidental exposure of API keys in the memory store.


πŸš€ Getting Started

git clone https://github.com/nathaniel-gordon/memcurve
cd memcurve
pip install -e .

Start the MCP Server

python -m cortexgraph

Visualize the Memory Graph

python scripts/visualize_graph.py

Convert to MCP Memory Format

python scripts/convert_to_memory_mcp.py

πŸ“ Project Structure

memcurve/
β”œβ”€β”€ src/cortexgraph/
β”‚   β”œβ”€β”€ server.py           # MCP server entrypoint & tool registration
β”‚   β”œβ”€β”€ context.py          # Shared db & mcp context
β”‚   β”œβ”€β”€ config.py           # Half-life and decay configuration
β”‚   β”œβ”€β”€ background.py       # Background decay scheduler
β”‚   β”œβ”€β”€ performance.py      # Performance monitoring
β”‚   β”œβ”€β”€ activation/         # Activation spreading & entity extraction
β”‚   β”‚   β”œβ”€β”€ detectors.py
β”‚   β”‚   β”œβ”€β”€ entity_extraction.py
β”‚   β”‚   └── patterns.py
β”‚   β”œβ”€β”€ tools/              # All MCP tool implementations
β”‚   └── security/           # Secret scanning & secure storage enforcement
└── scripts/

Built by Nathaniel Gordon

Available Tools

17 tools
analyze_for_recallA

Analyze message for recall/search intent.

Args: message: User message text.

Returns: Dict with: should_search, confidence, suggested_query, suggested_tags, suggested_entities, reasoning, phrase_signals.

Raises: ValueError: Invalid input.

Inputs: message (required). Returns: object

analyze_messageB

Analyze message for memory-worthy content.

Args: message: User message text.

Returns: Dict with: should_save, confidence, suggested_entities, suggested_tags, suggested_strength, reasoning, phrase_signals.

Raises: ValueError: Invalid input.

Inputs: message (required). Returns: object

auto_recall_process_messageC

Automatically recall and reinforce memories related to message topics.

Args: message: User message to analyze (non-empty string).

Returns: Dict with success, enabled, topics_found, memories_found, memories_reinforced, mode, and message.

Raises: ValueError: If message is empty or invalid.

Inputs: message (required). Returns: object

backfill_embeddingsA

Generate embeddings for memories that lack them.

Args: model: Model name (default: all-MiniLM-L6-v2). limit: Max memories to process (1-10k, None=all). force: Regenerate existing embeddings. dry_run: Preview only.

Returns: Dict with: success, processed, errors, model, total_memories, memories_without_embeddings, message.

Raises: ValueError: Invalid limit. ImportError: sentence-transformers not installed.

Inputs: force, limit, model, dry_run. Returns: object

cluster_memoriesA

Cluster similar memories or find duplicates.

Args: strategy: Clustering strategy (default "similarity"). threshold: Similarity threshold (0.0-1.0, uses config default if None). max_cluster_size: Max cluster size (1-100, uses config default if None). find_duplicates: Find duplicate pairs instead of clustering. duplicate_threshold: Duplicate threshold (0.0-1.0, uses config default if None).

Returns: Dict with clusters or duplicates list, scores, suggested_action.

Raises: ValueError: Invalid threshold or max_cluster_size.

Inputs: strategy, threshold, find_duplicates, max_cluster_size, +1 more. Returns: object

consolidate_memoriesA

Merge or link similar memories algorithmically.

Args: cluster_id: Cluster UUID to act on (required unless auto_detect=True). mode: "preview" (no changes), "apply" (merge), or "link" (relations only). auto_detect: Find high-cohesion clusters automatically. cohesion_threshold: Minimum cohesion (0.0-1.0).

Returns: Dict with success, mode, consolidated clusters, and results.

Raises: ValueError: If cluster_id invalid or cohesion_threshold out of range.

Inputs: mode, cluster_id, auto_detect, cohesion_threshold. Returns: object

create_relationA

Link two memories with typed relationship.

Args: from_memory_id: Source memory UUID. to_memory_id: Target memory UUID. relation_type: Type (related, causes, supports, contradicts, has_decision, consolidated_from). strength: Relation strength (0.0-1.0). metadata: Optional metadata dict.

Returns: Dict with relation_id, from, to, type, strength.

Raises: ValueError: Invalid UUID or relation type.

Inputs: to_memory_id (required), relation_type (required), from_memory_id (required), metadata, +1 more. Returns: object

gcA

Remove or archive low-scoring memories.

Args: dry_run: Preview without removing. archive_instead: Archive instead of deleting. limit: Max memories to process (1-10,000).

Returns: Dict with removed_count, archived_count, freed_score_sum, memory_ids.

Raises: ValueError: Invalid limit range.

Inputs: limit, dry_run, archive_instead. Returns: object

get_performance_metricsA

Get current performance metrics.

Returns: Dict with: operation stats, counts, timings.

Inputs: no named parameters. Returns: object

open_memoriesA

Retrieve specific memories by IDs with detailed information.

Args: memory_ids: Single ID or list of IDs (max 100). include_relations: Include outgoing/incoming relations. include_scores: Include decay scores and age. page: Page number (1-indexed). page_size: Memories per page (max 100).

Returns: Dict with memories, not_found IDs, and pagination metadata.

Raises: ValueError: If memory ID invalid or list exceeds max length.

Inputs: memory_ids (required), page, page_size, include_scores, +1 more. Returns: object

promote_memoryA

Promote high-value memories to long-term storage.

Args: memory_id: Memory UUID to promote. auto_detect: Detect promotion candidates automatically. dry_run: Preview without promoting. target: Storage format ("obsidian"). force: Promote even if criteria not met.

Returns: Dict with candidates, promoted_ids, and statistics.

Raises: ValueError: If memory_id invalid or target unsupported.

Inputs: force, target, dry_run, memory_id, +1 more. Returns: object

read_graphA

Return entire knowledge graph with memories and relations.

Args: status: "active", "promoted", "archived", or "all". include_scores: Include decay scores and age. limit: Max memories (1-10,000). page: Page number (1-indexed). page_size: Memories per page (max 100).

Returns: Dict with memories, relations, stats, and pagination metadata.

Raises: ValueError: If status invalid or limit out of range.

Inputs: page, limit, status, page_size, +1 more. Returns: object

reset_performance_metricsB

Reset all performance metrics.

Returns: Dict with: success, message.

Inputs: no named parameters. Returns: object

save_memoryA

Save memory to short-term storage with auto-enrichment.

Args: content: Memory content (max 50k chars). tags: Tags (max 50). entities: Named entities (max 100, auto-extracted if None). source: Source (max 500 chars). context: Context (max 1k chars). meta: Custom metadata dict. strength: Base strength (1.0-2.0, auto-calculated if None).

Returns: Dict with: success, memory_id, message, has_embedding, enrichment_applied.

Raises: ValueError: Invalid input.

Inputs: content (required), meta, tags, source, +3 more. Returns: object

search_memoryA

Search memories with filters and pagination.

Args: query: Search text (max 50k chars). tags: Filter by tags (max 50). status: Filter by status ('active', 'promoted', 'archived' or list of these). Defaults to ['active', 'promoted'] if None. top_k: Max results (1-100). window_days: Recent memories only (1-3650 days). min_score: Min decay score (0.0-1.0). use_embeddings: Enable semantic search. include_review_candidates: Include review-due memories. page: Page number (default: 1). page_size: Results per page (10-100, default: 10). preview_length: Content chars (0-5000, default: 300).

Returns: Dict with results list and pagination metadata.

Raises: ValueError: Invalid parameters.

Inputs: page, tags, query, top_k, +7 more. Returns: object

search_unifiedA

Search across STM and LTM with unified ranking.

Args: query: Search text (max 50k chars). tags: Filter by tags (max 50). status: Filter STM by status ('active', 'promoted', 'archived' or list of these). Defaults to ['active', 'promoted'] if None. limit: Max results (1-100). stm_weight: STM multiplier (0.0-2.0). ltm_weight: LTM multiplier (0.0-2.0). window_days: Recent STM only (1-3650 days). min_score: Min STM score (0.0-1.0). page: Page number (default: 1). page_size: Results per page (10-100, default: 10). preview_length: Content chars (0-5000, default: 300).

Returns: Dict with results from both STM/LTM and pagination metadata.

Raises: ValueError: Invalid parameters.

Inputs: page, tags, limit, query, +7 more. Returns: object

touch_memoryA

Reinforce memory to reset decay.

Args: memory_id: Memory UUID. boost_strength: Increase base strength.

Returns: Dict with old_score, new_score, use_count, strength.

Raises: ValueError: Invalid UUID.

Inputs: memory_id (required), boost_strength. Returns: object

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.5/5.0

    Scored across 17 tools

    Disambiguation4/5

    Most tools target distinct actions: analyze_for_recall vs analyze_message are differentiated by intent, and cluster_memories vs consolidate_memories separate detection from action. However, search_memory and search_unified overlap in capability, and auto_recall_process_message could be confused with the analyze_* tools since it also starts with message analysis.

    Naming Consistency4/5

    The majority follow a clear verb_noun pattern like save_memory, search_memory, promote_memory, and create_relation. Deviations include the abbreviated 'gc' and the awkward compound 'auto_recall_process_message', which break the otherwise predictable pattern.

    Tool Count4/5

    At 17 tools, the server is slightly above the ideal 3-15 range but still reasonably scoped for a memory system that handles search, recall, consolidation, promotion, graph relationships, and maintenance. Each tool serves a plausible purpose, though a few analysis/search tools could be merged.

    Completeness4/5

    The toolset covers the core memory lifecycle well: save, retrieve, search, reinforce, promote, consolidate, cluster, relate, and garbage collect. Minor gaps exist such as no explicit edit-memory or delete-relation tool, but the provided operations are mostly sufficient for the perceived domain.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      Not graded
      maintenance
      An MCP server enabling AI assistants to store, retrieve, and manage contextual information across conversations with features like persistent memory, advanced search, tagging, and privacy controls.
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      A MCP server that provides persistent memory for AI assistants, storing personal information, relationships, and observations to enable personalized and contextual conversations.
      4
      -