hipocampo
Dual-memory MCP system with PostgreSQL 17 + pgvector + NVIDIA NIM embeddings. 11 tools: search, save, profile, health, auto-repair, stats, tune, dedup, checkpoint, maintenance. Sparse Selective Caching (SSC) with 4-phase progressive retrieval. Bilingual EN/ES.
README
title: Hipocampo MCP emoji: 🧠 colorFrom: blue colorTo: purple sdk: docker pinned: false
Hipocampo: Dual-Memory System with Sparse Selective Caching
⚠️ Transport Note: SSE transport is deprecated since MCP spec 2025-03-26. Hipocampo now uses Streamable HTTP (single endpoint
/mcp) as the recommended remote transport. SSE (/sse) remains available for backward compatibility but will be removed in a future release.
🌐 MCP Server — Live on Hugging Face
Hipocampo runs as a free MCP server on Hugging Face Spaces. Connect from any MCP client:
URL: https://alexbell1-hipocampo-mcp.hf.space/mcp
{
"mcpServers": {
"hipocampo": {
"url": "https://alexbell1-hipocampo-mcp.hf.space/mcp"
}
}
}
Embedding model: sentence-transformers/all-MiniLM-L6-v2 (384 dims) via Hugging Face Inference API (free, no credit card required).
Hipocampo is an advanced dual-memory persistence architecture designed for autonomous AI agents. By maintaining both technical knowledge and user profiling data across sessions, Hipocampo provides a reliable, stateful context that enables agents to learn, adapt, and scale efficiently.
Built on top of PostgreSQL 17 with pgvector, it introduces Sparse Selective Caching (SSC)—a progressive four-phase retrieval algorithm inspired by "Memory Caching: RNNs with Growing Memory" (Google, 2025).
🚀 Key Features
- Dual-Memory Architecture: Distinct storage layers for technical records (
memoria_vectorial) and user profile data (memory_items), each utilizing 1024-dimensional embeddings. - Sparse Selective Caching (SSC): A state-of-the-art four-phase progressive retrieval pipeline that scales seamlessly: Tag Router → pgvector Top-K → GIN Trigram → ILIKE Fallback.
- Logarithmic Checkpointing: Intelligently compresses historical memories based on time decay, shrinking 24-hour granular details into unified 90-day checkpoints.
- Automated Tagging Engine: A robust, Regex-based rule engine that autonomously categorizes and tags records upon persistence.
- Cross-System Vector Search: Unified semantic search across over 1,100 records for deep cross-referencing.
- Model Context Protocol (MCP): Native integration via a FastMCP server, exposing seamless read/write capabilities to modern MCP clients (e.g., Claude Desktop, OpenCode).
🛠️ Quick Start
Prerequisites
- PostgreSQL 17+ (with
pgvectorandpg_trgmextensions enabled) - Python 3.13+
- NVIDIA API Key (for
nvidia/nv-embedqa-e5-v5embeddings) — or Hugging Face API Key forsentence-transformers/all-MiniLM-L6-v2(free via HF Inference API)
Installation
# 1. Clone the repository
git clone https://github.com/carrasquelalex1/hipocampo.git
cd hipocampo
# 2. Setup the PostgreSQL Database
createdb hipocampo_db
psql -d hipocampo_db -c "CREATE EXTENSION vector; CREATE EXTENSION pg_trgm;"
psql -d hipocampo_db -f esquema.sql
# 3. Initialize Python Environment
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
# 4. Environment Configuration
cp .env.example .env
# Edit .env with your DB_HOST, DB_USER, and NVIDIA_API_KEY
Basic Usage
Hipocampo provides specialized scripts to interact with the core engine:
# Perform a search using the new SSC progressive retrieval algorithm
python3 scripts/hipocampo_ssc_search.py "query term"
# Perform a search using the legacy BIRE unified search
python3 scripts/hipocampo_search.py "query term"
# Compress older memories using Logarithmic Checkpointing
python3 scripts/hipocampo_checkpoint.py --dry-run
python3 scripts/hipocampo_checkpoint.py --force
🧠 System Architecture
The core of Hipocampo is backed by a relational and vector hybrid design:
hipocampo_db (PostgreSQL 17 + pgvector + pg_trgm)
├── memoria_vectorial (Technical Knowledge)
│ ├── Columns: contenido (text), metadatos (jsonb), embedding (vector 1024d)
│ └── Indexes: HNSW (cosine similarity, 1024d), GIN (trigram)
├── memory_items (User Profile & Events)
│ ├── Columns: memory_type (profile|event|decision), summary, embedding, extra
│ └── Indexes: HNSW (cosine similarity, 1024d), GIN (trigram)
├── memory_categories (Classification Taxonomy)
├── category_items (M:N Mapping)
└── resources (Referenced Assets & URLs)
The SSC Pipeline (v3.7)
Sparse Selective Caching operates as a multi-tier fallback system to optimize both speed and accuracy:
- Phase 1: Tag Router – Classifies the query intent (profile vs. technical) and dynamically assigns weights.
- Phase 2: PGVector Top-K – Semantic search across both tables. Execution halts here if confidence ≥ 70%.
- Phase 3: GIN Trigram – Lexical expansion via Trigram indexing if semantic confidence is < 70%.
- Phase 4: ILIKE Scan – Final fallback full-table scan triggered only if confidence falls < 40%.
🔌 MCP Server Integration
Hipocampo includes a fully functional FastMCP server, allowing LLM agents to autonomously read and write memories.
Available MCP Tools
Memory Operations:
search_hipocampo(query): Unified semantic and lexical search (auto-records metrics).quick_hipocampo_search(query): Shorthand alias for rapid queries.save_hipocampo(content, memory_type, code, categories): Persist data into the technical memory store (memoria_vectorial).profile_hipocampo(summary, extra, categories): Store personal or event-driven user data (memory_items).
Self-Diagnosis & Auto-Repair (Fase 1):
hipocampo_health(): Full system health check (PostgreSQL, NVIDIA API, disk, extensions).hipocampo_auto_repair(): Automatically repairs detected issues (restart PostgreSQL, create missing tables).
Performance Optimization (Fase 2):
hipocampo_stats(): Query performance metrics, latency analysis, and optimization recommendations.hipocampo_tune(): Auto-adjusts SSC thresholds and hybrid weights based on real usage data.
Memory Maintenance (Fase 3):
hipocampo_dedup(merge): Detects and merges duplicate memories (exact + semantic via cosine similarity).hipocampo_checkpoint(dry_run): Logarithmic checkpointing to compress old memories.hipocampo_maintenance(): Full maintenance cycle (repair → dedup → checkpoint → tune).
Starting the Server
# Standard I/O mode (default for local desktop clients)
python3 scripts/hipocampo_mcp_server.py
# Streamable HTTP mode (recommended for remote clients)
python3 scripts/hipocampo_mcp_server.py --http 8001
# Legacy SSE mode (deprecated, only for backward compatibility)
python3 scripts/hipocampo_mcp_server.py --sse 8001
For advanced configuration, please refer to the MCP Server Guide.
☕ Support / Donaciones
If this project helps you, consider supporting its development:
- PayPal: paypal.me/carrasquealex
- USDT (TRC-20): (próximamente)
- Cada grano de arena ayuda a mantener el proyecto vivo 🧠✨
📄 License
This project is licensed under the MIT License.
🇪🇸 Versión en Español
Hipocampo: Sistema de Memoria Dual con Caché Selectivo (SSC)
Hipocampo es una arquitectura avanzada de persistencia de memoria dual diseñada para agentes de Inteligencia Artificial. Al mantener tanto el conocimiento técnico como los datos del perfil del usuario entre sesiones, Hipocampo proporciona un contexto con estado confiable que permite a los agentes aprender, adaptarse y escalar eficientemente.
Construido sobre PostgreSQL 17 y pgvector, introduce Sparse Selective Caching (SSC): un algoritmo de recuperación progresiva de cuatro fases inspirado en "Memory Caching: RNNs with Growing Memory" (Google, 2025).
🚀 Características Principales
- Arquitectura de Memoria Dual: Capas de almacenamiento separadas para registros técnicos (
memoria_vectorial) y datos de perfil (memory_items), ambas utilizando embeddings de 1024 dimensiones. - Sparse Selective Caching (SSC): Algoritmo progresivo que escala según la necesidad: Enrutador de Tags → pgvector Top-K → Trigramas GIN → Escaneo ILIKE.
- Checkpointing Logarítmico: Compresión inteligente basada en el decaimiento del tiempo, consolidando detalles granulares en un solo registro tras 90 días.
- Auto-MeJORA MCP: Autodiagnóstico (health check + auto-repair), optimización dinámica (stats + tune), y mantenimiento de memoria (dedup + checkpoint) — todo desde herramientas MCP.
- Motor de Auto-Etiquetado: Reglas basadas en expresiones regulares que categorizan la información de manera autónoma al momento de la persistencia.
- Protocolo MCP (Model Context Protocol): Integración nativa mediante un servidor FastMCP con 11 herramientas, otorgando capacidades directas de lectura/escritura y mantenimiento a clientes MCP como Claude Desktop y OpenCode.
🛠️ Instalación Rápida
# 1. Clonar y configurar BD
git clone https://github.com/carrasquelalex1/hipocampo.git
cd hipocampo
createdb hipocampo_db
psql -d hipocampo_db -c "CREATE EXTENSION vector; CREATE EXTENSION pg_trgm;"
psql -d hipocampo_db -f esquema.sql
# 2. Entorno Python y dependencias
python3 -m venv venv && source venv/bin/activate
pip install -r requirements.txt
# 3. Configurar variables de entorno
cp .env.example .env
# Editar .env con DB_HOST, DB_USER, NVIDIA_API_KEY
Para usar la búsqueda directamente desde la terminal:
python3 scripts/hipocampo_ssc_search.py "término de búsqueda"
Para inicializar el servidor MCP:
python3 scripts/hipocampo_mcp_server.py
python3 scripts/hipocampo_mcp_server.py --http 8001 # Streamable HTTP (recomendado)
python3 scripts/hipocampo_mcp_server.py --sse 8001 # legacy (deprecado)
Herramientas MCP Disponibles
Operaciones de Memoria:
search_hipocampo(consulta): Búsqueda semántica + léxica híbrida (auto-registra métricas).quick_hipocampo_search(consulta): Alias rápido para búsquedas.save_hipocampo(contenido, tipo, codigo, categorias): Guarda datos técnicos enmemoria_vectorial.profile_hipocampo(resumen, extra, categorias): Guarda datos de perfil enmemory_items.
Autodiagnóstico y Reparación (Fase 1):
hipocampo_health(): Health check completo (PostgreSQL, NVIDIA API, disco, extensiones).hipocampo_auto_repair(): Repara problemas automáticamente (reinicia PostgreSQL, crea tablas faltantes).
Optimización de Rendimiento (Fase 2):
hipocampo_stats(): Métricas de rendimiento, latencia, y recomendaciones de optimización.hipocampo_tune(): Ajusta thresholds SSC y pesos híbridos según uso real.
Mantenimiento de Memoria (Fase 3):
hipocampo_dedup(fusionar): Detecta y fusiona memorias duplicadas (exactas + semánticas).hipocampo_checkpoint(seco): Checkpointing logarítmico para comprimir memorias antiguas.hipocampo_maintenance(): Ciclo completo de mantenimiento (reparar → dedup → checkpoint → tune).
Consulte los manuales en la carpeta docs/ para información arquitectónica y configuraciones avanzadas.
☕ Donaciones
Si este proyecto te es útil, considera apoyarlo:
- PayPal: paypal.me/carrasquealex
- USDT (TRC-20): (próximamente)
- Cada aporte ayuda a mantener vivo el proyecto 🧠✨
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。