Cortex
by liveevilkin
README.md
# š§ Cortex ā Proactive Memory Agent for AI Coding Assistants
> Obsidian-backed knowledge graph with semantic search, entity extraction, and cross-session memory. 11 MCP tools. Works with Claude Code, Cursor, Windsurf, and any MCP-compatible editor.
---
## What It Does
```
You: "How does the memory system handle forgetting?"
Cortex: š” This reminds me of your previous work on:
1. decisions/memory-architecture-choice ā Ebbinghaus decay with 14-day half-life
2. daily/2026-06-19 ā You designed the three-tier memory architecture
3. moc/system-architecture ā Full system diagram
```
- **Semantic search** ā Find concepts across languages (EN query ā CN content)
- **Knowledge graph** ā 928 entities, 106K relationships, auto-extracted from your notes
- **Proactive context** ā `memory_monitor` watches conversation topics, surfaces relevant memories
- **Gap analysis** ā Compare your learning goals against actual knowledge coverage
- **Cross-session** ā Every session loads your memory index + recent daily logs automatically
## Architecture
```
MCP Client (Claude Code / Cursor / Windsurf)
ā stdio JSON-RPC
ā¼
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā Cortex MCP Server (TypeScript) ā
ā 11 tools + 1 resource ā
ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāā ā
ā ā SQLite (sql.js) ā ā ā Knowledge graph (8 tables)
ā ā LanceDB ā ā ā Vector embeddings (384-dim)
ā ā ONNX (all-MiniLM-L6-v2) ā ā ā Local, zero API cost
ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāā ā
āāāāāāāāāāāāāāāā¬āāāāāāāāāāāāāāāāāāā
ā reads & indexes
ā¼
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā Obsidian Vault (source of truth)ā
ā daily/ decisions/ moc/ ā
ā å¦ä¹ č®”å/ ... ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
```
## Quick Start
```bash
# 1. Install
cd Cortex/mcp-server
npm install --ignore-scripts
npx tsc
# 2. Configure (Claude Code)
# Copy the MCP config to your global Claude Code settings:
# ~/.claude/.mcp.json
# 3. Use
# Start a Claude Code session. The MCP server starts automatically.
# Say: "memory_ingest" to index your vault
# Say: "search for architecture decisions" to find memories
```
## MCP Tools
| Tool | Description |
|------|-------------|
| `memory_search` | Hybrid keyword + vector semantic search |
| `memory_ingest` | Scan vault, extract entities, build index |
| `memory_status` | System health report |
| `memory_entity_extract` | Extract typed entities from text |
| `memory_graph_query` | Query the knowledge graph (multi-hop) |
| `memory_auto_link` | Suggest `[[wikilinks]]` between notes |
| `memory_monitor` | Process conversation, return proactive context |
| `memory_conflict_resolve` | Detect contradictions with existing memories |
| `memory_gap_analysis` | Analyze knowledge gaps vs learning goals |
| `memory_consolidate` | Apply decay, find archive candidates |
| `memory_session_end` | Generate daily note (portable Stop hook) |
## Editor Support
| Editor | Setup |
|--------|-------|
| **Claude Code** | `~/.claude/.mcp.json` (global) or `.mcp.json` (project) |
| **Cursor** | Copy `editors/cursor.mcp.json` ā `.cursor/mcp.json` |
| **Windsurf** | Copy `editors/windsurf.mcp.json` |
| **Cline / VS Code** | Copy `editors/cline.mcp.json` |
## Project Structure
```
Cortex/
āāā mcp-server/ ā TypeScript MCP server (32 source files)
ā āāā src/
ā ā āāā tools/ ā 11 MCP tools
ā ā āāā graph/ ā Knowledge graph + decay + gap detection
ā ā āāā ingest/ ā Vault scanner, chunker, entity extractor
ā ā āāā embeddings/ ā ONNX pipeline (all-MiniLM-L6-v2)
ā ā āāā db/ ā SQLite + LanceDB
ā ā āāā resources/ ā MCP resource endpoints
ā āāā editors/ ā Config templates for other editors
ā āāā tests/
āāā src/
ā āāā hooks/ ā Bash hooks (SessionStart, Stop, etc.)
ā āāā lib/ ā Bash utilities
ā āāā templates/ ā Vault file templates
āāā skills/ ā Claude Code skills
āāā commands/ ā Slash commands
āāā docs/ ā Architecture docs
āāā tests/ ā Hook tests
```
## License
MIT ā see [LICENSE](LICENSE)
This server cannot be deployed
Maintenance
ActivityInactive
ResponsivenessResponsive