Agentic Memory System
An intelligent, tiered memory management system for Claude AI agents, implementing hierarchical storage with semantic search capabilities. Built as an MCP (Model Context Protocol) server for seamless integration with Claude Desktop and Claude Code.
Features
- 🧠 Hierarchical Memory Tiers: Working, Warm, and Cold storage with automatic migration
- 🔍 Semantic Search: Vector-based similarity search using pgvector
- 🚀 MCP Integration: Native support for Claude Desktop and Claude Code
- 📊 Performance Monitoring: Built-in metrics, health checks, and observability
- 🔒 Security First: Secure credential handling, encryption support, audit logging
- 🎯 Flexible Embeddings: Support for Ollama (local), OpenAI, or mock providers
- 💾 PostgreSQL Backend: Robust storage with pgvector for vector operations
- 🛡️ Production Ready: Comprehensive error handling, retries, and circuit breakers
Quick Start
Claude Desktop Extension (Easiest)
New! Install Codex Memory as a Claude Desktop extension for the simplest setup:
- Download
codex-memory.dxt
from Releases - Open Claude Desktop → Settings → Extensions
- Click "Install Extension" and select the
.dxt
file - Configure your database URL and embedding provider in the UI
- Start using memory commands in Claude!
See extension/README.md for detailed extension documentation.
Manual Installation
Prerequisites
- Rust 1.70+ and Cargo
- PostgreSQL 15+ with pgvector extension
- Ollama (for local embeddings) or OpenAI API key
- macOS/Linux/Windows
Build from Source
# Clone the repository
# Build the release binary
# Run setup validation
Configuration
- Copy the example environment file:
- Edit
.env
with your credentials:
DATABASE_URL=postgresql://username:password@localhost:5432/memory_db
EMBEDDING_PROVIDER=ollama
EMBEDDING_BASE_URL=http://localhost:11434
EMBEDDING_MODEL=nomic-embed-text
- Test your configuration:
MCP Integration
Claude Desktop Setup (macOS)
- Generate configuration template:
- Add to Claude Desktop configuration:
Edit ~/Library/Application Support/Claude/claude_desktop_config.json
:
- Restart Claude Desktop to load the new MCP server.
Claude Code Setup (Project-Level)
- Create
.mcp.json
in your project root:
- The MCP server will automatically start when you open the project in Claude Code.
Database Setup
PostgreSQL with pgvector
- Install PostgreSQL and pgvector:
# macOS (Homebrew)
# Ubuntu/Debian
# From source
&& &&
- Create database and user:
EXISTS vector;
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
;
;
\c codex_db
CREATE EXTENSION IF NOT
- Run migrations:
Embedding Setup
Option 1: Ollama (Recommended for Local Development)
- Install Ollama:
# macOS
# Linux
|
- Start Ollama and pull embedding model:
Option 2: OpenAI
Set your API key in .env
:
EMBEDDING_PROVIDER=openai
OPENAI_API_KEY=sk-your-api-key-here
EMBEDDING_MODEL=text-embedding-3-small
Usage
Start the MCP Server
# Using environment file
# Or with explicit configuration
DATABASE_URL="postgresql://..."
CLI Commands
# MCP Management
# Database Management
# System Management
Memory Operations (via MCP)
Once integrated with Claude, you can use natural language to interact with the memory system:
- "Remember that the user prefers dark mode"
- "What do you know about my database configuration?"
- "Search for memories about API endpoints"
- "Forget everything about passwords"
Architecture
┌─────────────────────────────────────────────────────┐
│ Claude Desktop/Code │
│ (MCP) │
└─────────────────────┬───────────────────────────────┘
│
┌─────────────────────┴───────────────────────────────┐
│ Agentic Memory System │
│ │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────┐ │
│ │ Working │ │ Warm │ │ Cold │ │
│ │ Memory │◄─┤ Memory │◄─┤ Memory │ │
│ │ (Hot tier) │ │ (Medium tier)│ │(Archive) │ │
│ └──────────────┘ └──────────────┘ └──────────┘ │
│ │
│ ┌──────────────────────────────────────────────┐ │
│ │ Embedding Service │ │
│ │ (Ollama/OpenAI/Mock) │ │
│ └──────────────────────────────────────────────┘ │
└─────────────────────┬───────────────────────────────┘
│
┌─────────────────────┴───────────────────────────────┐
│ PostgreSQL + pgvector │
└─────────────────────────────────────────────────────┘
Performance
- Working Memory Access: <1ms P99
- Semantic Search: <100ms P99 for 1M vectors
- Embedding Generation: ~10ms (Ollama local)
- Batch Operations: 100+ ops/second
- Memory Capacity: 1K working, 10K warm, unlimited cold
Security
- Credential Management: Environment variables with secure defaults
- Connection Security: TLS/SSL support for database connections
- Access Control: Database user with minimal required permissions
- Audit Logging: Complete audit trail of all operations
- Data Encryption: At-rest and in-transit encryption support
Monitoring
Prometheus Metrics
The system exposes metrics on :8080/metrics
:
- Memory operations (create, read, update, delete)
- Search performance and hit rates
- Tier migration statistics
- Database connection pool metrics
- Embedding generation latency
Health Checks
# System health
# Detailed diagnostics
Troubleshooting
Common Issues
Database Connection Failed:
# Check PostgreSQL is running
# Verify credentials
Ollama Not Responding:
# Check Ollama is running
# Pull embedding model
MCP Not Loading in Claude:
# Validate configuration
# Check logs
Debug Mode
Enable detailed logging:
LOG_LEVEL=debug
Development
Building from Source
# Debug build
# Release build with optimizations
# Run tests
# Run with hot reload
Running Tests
# All tests
# Specific test suites
# With output
Contributing
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
Development Workflow
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Run
cargo fmt
andcargo clippy
- Submit a pull request
License
This project is licensed under the MIT License - see LICENSE for details.
Support
- Documentation: MCP_SETUP.md
- Issues: GitHub Issues
- Discussions: GitHub Discussions
Acknowledgments
- Built for the Claude AI ecosystem
- Uses pgvector for efficient vector operations
- Inspired by hierarchical memory architectures in cognitive science