Version: 1.0 (Production-Ready Hybrid Stack)
A privacy-first, local Long Term Memory system for AI agents with hybrid GraphRAG retrieval.
Features β’ Quick Start β’ Architecture β’ Usage & Tools
Cortex is a local, privacy-first "Long Term Memory" system for AI agents. It intelligently stores and retrieves information from your workflow (IDEs, terminals, chat) using a Hybrid GraphRAG architecture that combines semantic search with graph-based reasoning.
It operates as a Model Context Protocol (MCP) server, making it instantly compatible with Claude Desktop, Cursor, VSCode (GitHub Copilot), and other AI clients.
| Feature | Description |
|---|---|
| π Privacy-First | All data stays local. Automatic PII detection & redaction (11 patterns). |
| π High Performance | ~800MB memory savings via singleton patterns + intelligent caching. |
| π§© Hybrid Retrieval | Semantic search (LanceDB) + Graph reasoning (KΓΉzu) combined. |
| π€ Multi-Agent | Safe concurrent access for multiple agents (Windows/Linux compatible). |
| π Monitoring | Real-time metrics, cache stats, and get_system_stats() tool. |
| π¨ Visualization | Auto-generated interactive HTML dashboard of your knowledge graph. |
You can run Cortex via Docker or Python (Recommended) directly.
No Python setup required. Runs the MCP server on port 8000.
# 1. Clone and start
git clone https://github.com/yourusername/cortex.git
cd Cortex
docker compose up -d
# 2. Verify it's running
curl http://localhost:8000/health
# Output: {"status": "healthy", "server": "Cortex MCP"}Click to expand Python installation steps
Prerequisites: Python 3.11+
-
Setup Environment
python -m venv venv # Windows: venv\Scripts\activate # Mac/Linux: source venv/bin/activate pip install -r requirements.txt
-
Download Models
python -m spacy download en_core_web_sm
-
Run Server
# Starts HTTP server on port 8000 python src/cortex/main.py --host 0.0.0.0 --port 8000
Cortex uses the Model Context Protocol. Once the server is running (usually at http://localhost:8000/mcp), connect your favorite AI editor.
Add this to your config file:
- Win:
%APPDATA%\Claude\claude_desktop_config.json - Mac:
~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"cortex": {
"url": "http://localhost:8000/mcp"
}
}
}Add to .vscode/mcp.json or the extension settings:
{
"mcpServers": {
"cortex": {
"url": "http://localhost:8000/mcp"
}
}
}Tip
Testing the connection: Ask your AI "What is your memory status?" or "Store this: I am working on Project X".
Cortex generates a beautiful 3D/2D interactive dashboard to explore your knowledge graph. See how memories, topics, and projects interconnect in real-time.
Explore your knowledge graph in immersive 3D space with animated data flows
Switch to 2D mode for precise navigation and analysis
Features:
- π Toggle 3D/2D views with a single click
- π― Click nodes to see detailed information (source, timestamp, category, connections)
- β¨ Animated particle flows showing data relationships
- π Starfield background for cinematic experience (3D mode)
- π Live statistics showing node and link counts
- π¨ Color-coded nodes: Memory (red), Topics (green), Projects (blue)
Generate your own dashboard with the visualize_brain tool or run the demo:
python demo_scenario.py
# Open demo_dashboard.html manuallyCortex implements a Hybrid GraphRAG approach. It doesn't just match text; it understands relationships.
graph TD
Client[AI Agent / Client] <-->|MCP Protocol| API[Cortex Server]
subgraph "Cortex Core"
API --> NLP["Intelligence Layer<br/>(spaCy + PII Filter)"]
NLP -->|Entities| Graph["Associative Store<br/>(KΓΉzu Graph DB)"]
NLP -->|Embeddings| Vector["Semantic Store<br/>(LanceDB)"]
Graph <-->|Relations| Vector
end
subgraph "Performance"
Cache["L1 Cache<br/>Embeddings + Queries"] -.-> API
Monitor["Metrics & Stats"] -.-> API
end
- π Semantic Store (Hippocampus): LanceDB + FastEmbed. Handles vector similarity search with an automatic L2 distance threshold (< 0.85).
- πΈοΈ Associative Store (Cortex): KΓΉzu Graph DB. Links memories to Topics, Projects, and Entities. Allows 2-hop neighbor traversal.
- π€ Intelligence Layer: Spacy. Automatic extraction of PERSON, ORG, PRODUCT and PII Sanitization (redacting emails, keys, etc.).
Your AI agent will have access to these tools automatically:
Saves information with automatic entity extraction and privacy cleaning.
{"content": "We chose FastAPI because of its async performance", "category": "decision", "project": "Backend-v2"}Retrieves relevant memories using hybrid ranking (Vector + Graph scores).
{"query": "Why did we choose FastAPI?", "limit": 5}Generates an interactive D3.js dashboard of your knowledge graph. Returns a path to dashboard.html.
Returns real-time metrics (cache hit rates, operation times, memory usage).
Configure Cortex via environment variables (in .env or Docker Compose):
| Variable | Default | Description |
|---|---|---|
CORTEX_STORAGE_DIR |
.cortex_storage |
Location of DB files |
CORTEX_THRESHOLD |
0.85 |
Similarity strictness (lower = stricter) |
CORTEX_SEARCH_LIMIT |
5 |
Max results returned by recall queries |
CORTEX_ENABLE_CACHE |
true |
Enable in-memory caching |
CORTEX_PII_DETECTION |
true |
Enable auto-redaction of secrets |
CORTEX_LOG_LEVEL |
INFO |
Verbosity (DEBUG, INFO, ERROR) |
Cortex is designed for sensitive data.
- Local First: No data is sent to OpenAI/Anthropic clouds for storage.
- PII Redaction: 11 patterns are automatically stripped before storage:
email,phone,ip_address,credit_cardapi_keys(sk-...),aws_keys,jwt_tokenscrypto_addresses,ssn,passwords
Warning
While Cortex sanitizes data, always ensure the storage directory (.cortex_storage) is secured with appropriate file system permissions.
We maintain 100% test coverage.
# Run full suite
pytest tests/ -v
# Check coverage
pytest tests/ --cov=src/cortexProject Structure:
Cortex/
βββ src/cortex/
β βββ intelligence/ # NLP & Privacy logic
β βββ storage/ # LanceDB & KΓΉzu wrappers
β βββ server.py # MCP Implementation
βββ tests/ # 40/40 Passing Tests
βββ docker-compose.yml
Contributions are welcome! Please follow the Singleton Pattern used in storage/manager.py to ensure thread safety.
- Fork & Branch (
feature/amazing-feature) - Test (
pytest) - PR with description
β Star this repo if Cortex helps your AI agents remember! β
Built with β€οΈ for the future of Agentic AI