Cuba-Memorys MCP Server

Local setup required. This server has to be cloned and prepared on your machine before you register it in Claude Code.
1

Set the server up locally

Run this once to clone and prepare the server before adding it to Claude Code.

Run in terminal
git clone https://github.com/LeandroPG19/cuba-memorys.git
cd cuba-memorys/rust
cargo build --release
2

Register it in Claude Code

After the local setup is done, run this command to point Claude Code at the built server.

Run in terminal
claude mcp add -e "DATABASE_URL=${DATABASE_URL}" cuba-memorys -- node "<FULL_PATH_TO_CUBA_MEMORYS>/dist/index.js"

Replace <FULL_PATH_TO_CUBA_MEMORYS>/dist/index.js with the actual folder you prepared in step 1.

Required:DATABASE_URL+ 2 optional
README.md

Persistent memory for AI agents with knowledge graph and adaptive learning.

🧠 Cuba-Memorys

Persistent memory for AI agents β€” A Model Context Protocol (MCP) server that gives AI coding assistants long-term memory with a knowledge graph, neuroscience-inspired algorithms, and anti-hallucination grounding.

12 tools with Cuban soul. Sub-millisecond handlers. Mathematically rigorous.

[!IMPORTANT] v2.0.0 β€” Complete Rust rewrite. 5,452 LOC, 36 source files, 0 CVEs, 0 tech debt. Internally audited with GO verdict. The Python version (v1.6.0) remains in src/ as legacy reference.


Why Cuba-Memorys?

AI agents forget everything between conversations. Cuba-Memorys solves this:

  • 🧬 FSRS-6 adaptive decay β€” Memories strengthen with use and fade realistically (21 parameters, per-entity sigmoid)
  • 🧠 Hebbian + BCM metaplasticity β€” Self-normalizing importance via Oja's rule with Bienenstock-Cooper-Munro throttle
  • πŸ” 4-signal RRF fusion search β€” TF-IDF + pg_trgm + full-text + pgvector HNSW, with entropy-routed adaptive k
  • πŸ•ΈοΈ Knowledge graph β€” Entities, observations, typed relations with Leiden community detection
  • πŸ›‘οΈ Anti-hallucination grounding β€” Verify claims against stored knowledge with graduated confidence scoring
  • πŸ’€ REM Sleep consolidation β€” Autonomous background decay + PageRank + neighbor diffusion after idle
  • πŸ“Š Graph intelligence β€” Personalized PageRank, Leiden communities, Brandes centrality, Shannon entropy
  • πŸ” Dual-Strength memory β€” Storage + retrieval strengths track independently (Bjork 1992)
  • ⚑ Error memory β€” Never repeat the same mistake (anti-repetition guard)

Comparison

Feature Cuba-Memorys Basic Memory MCPs
Knowledge graph with typed relations βœ… ❌
FSRS-6 adaptive spaced repetition βœ… ❌
Hebbian learning + BCM metaplasticity βœ… ❌
Dual-Strength memory model βœ… ❌
4-signal entropy-routed RRF fusion βœ… ❌
KG-neighbor query expansion βœ… ❌
GraphRAG topological enrichment βœ… ❌
Leiden community detection βœ… ❌
Brandes betweenness centrality βœ… ❌
Shannon entropy analytics βœ… ❌
Adaptive prediction error gating βœ… ❌
Anti-hallucination verification βœ… ❌
Error pattern detection + MTTR βœ… ❌
Session-aware search boost βœ… ❌
REM Sleep autonomous consolidation βœ… ❌
Embedding LRU cache βœ… ❌
Optional ONNX BGE embeddings βœ… ❌
Write-time dedup gate βœ… ❌
Contradiction auto-supersede βœ… ❌
Graceful shutdown (SIGTERM/SIGINT) βœ… ❌

Quick Start

git clone https://github.com/LeandroPG19/cuba-memorys.git
cd cuba-memorys

# Start PostgreSQL
docker compose up -d

# Build Rust binary
cd rust
cargo build --release

Configure your AI editor (Claude Code, Cursor, Windsurf, etc.):

{
  "mcpServers": {
    "cuba-memorys": {
      "command": "/path/to/cuba-memorys/rust/target/release/cuba-memorys",
      "env": {
        "DATABASE_URL": "postgresql://cuba:memorys2026@127.0.0.1:5488/brain"
      }
    }
  }
}

The server auto-creates the brain database and all tables on first run.

Optional: ONNX Embeddings

For real BGE-small-en-v1.5 semantic embeddings instead of hash-based fallback:

export ONNX_MODEL_PATH="$HOME/.cache/cuba-memorys/models"
export ORT_DYLIB_PATH="/path/to/libonnxruntime.so"

Without ONNX, the server uses deterministic hash-based embeddings β€” functional but without semantic understanding.


πŸ‡¨πŸ‡Ί The 12 Tools

Every tool is named after Cuban culture β€” memorable, professional, meaningful.

Knowledge Graph

Tool Meaning What it does
cuba_alma Alma β€” soul CRUD entities. Types: concept, project, technology, person, pattern, config. Triggers Hebbian + Dual-Strength boost.
cuba_cronica CrΓ³nica β€” chronicle Attach observations with dedup gate, contradiction detection, Shannon density gating, and adaptive PE gating V5.1. Supports batch_add.
cuba_puente Puente β€” bridge Typed relations (uses, causes, implements, depends_on, related_to). Traverse walks the graph. Infer discovers tra

Tools (3)

cuba_almaCRUD entities including concepts, projects, technologies, persons, patterns, and configs.
cuba_cronicaAttach observations with dedup gate, contradiction detection, and adaptive PE gating.
cuba_puenteManage typed relations and traverse the knowledge graph.

Environment Variables

DATABASE_URLrequiredPostgreSQL connection string for the brain database.
ONNX_MODEL_PATHPath to directory containing ONNX models for semantic embeddings.
ORT_DYLIB_PATHPath to the ONNX runtime dynamic library.

Configuration

claude_desktop_config.json
{"mcpServers": {"cuba-memorys": {"command": "/path/to/cuba-memorys/rust/target/release/cuba-memorys", "env": {"DATABASE_URL": "postgresql://cuba:memorys2026@127.0.0.1:5488/brain"}}}}

Try it

β†’Store this project architecture as a new entity in my memory.
β†’What are the dependencies related to the current project in my knowledge graph?
β†’Verify if the claim about this API's performance matches my stored observations.
β†’Consolidate my recent notes into the knowledge graph and identify key community clusters.

Frequently Asked Questions

What are the key features of Cuba-Memorys?

FSRS-6 adaptive spaced repetition for memory decay. Knowledge graph with typed relations and Leiden community detection. 4-signal RRF fusion search using TF-IDF, pg_trgm, and pgvector. Anti-hallucination grounding with confidence scoring. Autonomous REM sleep consolidation for background graph optimization.

What can I use Cuba-Memorys for?

Maintaining long-term context for AI coding assistants across multiple sessions.. Building a self-organizing knowledge base of project-specific technical patterns.. Detecting contradictions in AI-generated code against previously stored project constraints.. Analyzing project structure and entity relationships using graph intelligence..

How do I install Cuba-Memorys?

Install Cuba-Memorys by running: git clone https://github.com/LeandroPG19/cuba-memorys.git && cd cuba-memorys/rust && cargo build --release

What MCP clients work with Cuba-Memorys?

Cuba-Memorys works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Turn this server into reusable context

Keep Cuba-Memorys docs, env vars, and workflow notes in Conare so your agent carries them across sessions.

Need the old visual installer? Open Conare IDE.
Open Conare