I built a persistent memory MCP with Hebbian learning and GraphRAG

The Problem

AI coding assistants forget everything between sessions. Every conversation starts from zero. You explain your architecture, your patterns, your preferences — and next time, it’s gone.
I built Cuba-Memorys to fix this.

What is it?

An MCP server that gives AI agents persistent long-term memory using a knowledge graph backed by PostgreSQL. 12 tools with Cuban-themed names.

Key Features

🧠 Knowledge Graph

Entities, observations, and typed relations that persist across sessions. Your AI remembers projects, decisions, patterns, and connections between them.

⚡ Hebbian Learning

“Neurons that fire together wire together” — memories strengthen with use (Oja’s rule) and fade adaptively using FSRS spaced repetition (the algorithm behind Anki).

Not just keyword matching. Cuba-Memorys fuses 4 search signals:

  • TF-IDF similarity
  • PostgreSQL full-text search
  • Trigram matching
  • Optional pgvector HNSW embeddings
    Results are ranked using Reciprocal Rank Fusion for maximum recall.
    ### 🕸️ GraphRAG Enrichment
    Top search results are automatically enriched with degree-1 graph neighbors, giving your AI topological context — not just text matches.
    ### 🛡️ Anti-Hallucination Grounding
    Verify claims against stored knowledge with graduated confidence scoring: verifiedpartialweakunknown. Your AI can fact-check itself before answering.
    ### 😴 REM Sleep Consolidation
    After 15 minutes of inactivity, the system automatically runs maintenance: adaptive decay, deduplication, and memory consolidation. Like biological sleep for your AI’s memory.
    ### 📊 Graph Analytics
  • PageRank — Find the most important entities
  • Louvain communities — Discover knowledge clusters
  • Betweenness centrality — Identify bridge concepts
    ## The 12 Tools
    | Tool | Purpose |
    |——|———|
    | cuba_alma | CRUD knowledge graph entities |
    | cuba_cronica | Attach observations to entities |
    | cuba_puente | Create/traverse relations |
    | cuba_faro | Search with anti-hallucination |
    | cuba_alarma | Report and track errors |
    | cuba_expediente | Search past errors (anti-repetition) |
    | cuba_remedio | Mark errors as resolved |
    | cuba_eco | RLHF feedback loop |
    | cuba_decreto | Record architecture decisions |
    | cuba_jornada | Session management |
    | cuba_vigia | Graph analytics |
    | cuba_zafra | Memory maintenance |
    ## Quick Start

json
{
  "mcpServers": {
    "cuba-memorys": {
      "command": "python",
      "args": ["-m", "cuba_memorys"],
      "env": {
        "DATABASE_URL": "postgresql://user:pass@localhost:5432/brain"
      }
    }
  }
}
¨¨


The database auto-provisions via Docker if needed. Zero manual setup.

Why "Cuba"?
The tools are named after Cuban Spanish words — alma (soul), crónica (chronicle), faro (lighthouse), remedio (remedy). It started as a personal project and the naming stuck.

Links
GitHub: github.com/lENADRO1910/cuba-memorys
PyPI: pip install cuba-memorys
License: CC BY-NC 4.0
If you find it useful, a ⭐ on GitHub would mean a lot. Open to feedback and contributions!


Total
0
Shares
Leave a Reply

Your email address will not be published. Required fields are marked *

Previous Post

Owner of ICE detention facility sees big opportunity in AI man camps

Next Post

Will the Pentagon’s Anthropic controversy scare startups away from defense work?

Related Posts