A persistent knowledge graph for your codebase. Cortex Index converts source code into a queryable graph with symbol resolution, call tracking, and token-optimized AI context building β all local, no cloud, no vector DB.
- 30 MCP Tools β Full Model Context Protocol (MCP v1.0) over stdio + HTTP JSON-RPC 2.0
- π§ Brain System β Persistent
.cortex/brain.mdstores project purpose, rules, and knowledge. Created oncortex init, queryable viacortex_brain_get/update/appendMCP tools. AI agents learn once, remember forever. - Memory-Safe Streaming Index β Streaming parse callback with bounded batch buffers (10K nodes/edges). No unbounded accumulation. 24GB β <500MB RSS fix verified.
- Multi-Language Support β Go (real AST), TypeScript/JavaScript, Python, Rust, C/C++, Java, Kotlin, Swift β functions, structs, classes, interfaces, imports, enums, and argument type references extracted from all 8 languages.
- Incremental & Git-Aware β
fsnotifywatcher (300ms debounce), Git hook integration, branch comparison. - Project-Local β No global database. Each project owns
.cortex/next to it.cortex initcreates it.cortex cleanresets it. - Visual Web UI β Dark/light mode dashboard with force-directed SVG graph, data explorer, and search.
- Embedded Storage β SQLite (default) or Pebble LSM tree (optional
pkg/storage/pebble/).
ββββββββββββββββ
β AI Agent β
β (Claude/etc) β
ββββββββ¬ββββββββ
β MCP (Stdio / HTTP)
ββββββββββββββΌβββββββββββββ
β Cortex MCP Server β
β 30 tools Β· JSON-RPC 2.0 β
ββββββββββββββ¬βββββββββββββ
β
βββββββββββββββββββΌββββββββββββββββββ
β β β
ββββββΌβββββ βββββββΌββββββ βββββββΌβββββ
β Query β β Knowledge β β Context β
β Planner β β Graph Eng β β Builder β
ββββββ¬βββββ βββββββ¬ββββββ βββββββ¬βββββ
ββββββββββββββββββΌββββββββββββββββββ
β
βββββββββββββΌββββββββββββ
β Storage Layer β
β SQLite / Pebble β
β .cortex/data/ β
βββββββββββββ¬ββββββββββββ
β
βββββββββββββΌββββββββββββ
β Incremental Indexer β
β Streaming Parser β
β (bounded 10K batch) β
βββββββββββββ¬ββββββββββββ
β
ββββββββββββββββββββββββΌβββββββββββββββββββββββ
β β β β β
βββββΌββββ βββββΌββββ βββββΌββββ βββββΌββββ βββββΌββββ
β Go β βTS/JS β βPython β β Rust β βC/C++ β
β(AST) β β(regex)β β(regex)β β(regex)β β(regex)β
βββββββββ βββββββββ βββββββββ βββββββββ βββββββββ
βββββΌββββ βββββΌββββ βββββΌββββ
β Java β βKotlin β β Swift β
β(regex)β β(regex)β β(regex)β
βββββββββ βββββββββ βββββββββ
# Install
git clone https://github.com/Haslab-dev/CortexIndex.git
cd CortexIndex && make build && go install ./cmd/cortex
# Or quick install with Go
go install github.com/Haslab-dev/CortexIndex/cmd/cortex@latest
# Create a project
cd ~/my-project
cortex init # creates .cortex/ with brain.md + project.json
cortex index # full index (88 files / 530 symbols in ~84ms)
cortex serve # HTTP API + UI at localhost:8080
# Quick MCP test
cortex mcp call cortex_get_project_summary '{}'
cortex mcp call cortex_find_symbol '{"name":"InitDB"}'The brain file (.cortex/brain.md) records your project's purpose, rules, and explanations. Created automatically on cortex init. AI agents read it to understand context without codebase exploration.
# View
cortex brain
# Set purpose + rules
cortex brain update "## Purpose\nAPI router for 10+ LLM providers with cost tracking"
# Append knowledge
cortex brain append "Providers self-register via init() calling Register()"
# Via MCP (agent-friendly)
cortex mcp call cortex_brain_update '{"content":"## Purpose\n..."}'
cortex mcp call cortex_brain_append '{"line":"Uses Pebble for cold storage"}'The brain persists between agent sessions β knowledge learned once is retained.
Tested on my-ai-router (88 files, 530 symbols, Go + TypeScript codebase):
| Operation | Time | Notes |
|---|---|---|
| Cold full index | 84ms | Streaming parse + batch edge resolution |
| Incremental index | 60ms | Hash-based skip for unchanged files |
| Symbol lookup | <2ms | SQLite indexed queries |
| Call graph | <5ms | Depth-3 traversal |
| Architecture map | <3ms | Single query aggregation |
| Idle RSS | ~25MB | After GC stabilization |
| Full index RSS | <150MB | Bounded batch buffers at 10K |
| Storage (SQLite) | ~2MB | 88 files, 4038 edges |
Memory safety fix (24GB β <500MB) verified: streaming callback eliminates unbounded []*ParseResult accumulation, batch buffers capped at 10K nodes/edges, cache eviction every 5 minutes with 10K max entries.
| Tool | Description | Example |
|---|---|---|
cortex_brain_get |
Read brain.md (purpose/rules) | {} |
cortex_brain_update |
Replace brain.md content | {"content":"## Purpose\n..."} |
cortex_brain_append |
Append line as "Learned" | {"line":"Uses Pebble storage"} |
| Tool | Description | Example |
|---|---|---|
cortex_build_context |
Token-optimized AI context bundle (symbol + callers + callees + risk + advice) | {"name":"AnthropicProvider"} |
cortex_find_entry_points |
Find main/Init/Serve/Start functions | {} |
cortex_find_dead_code |
Functions with zero callers | {} |
cortex_get_diagnostics |
Health report + parse failures | {} |
cortex_compare_branches |
Git branch diff (files + symbols) | {"branch":"main"} |
| Tool | Description | Example |
|---|---|---|
cortex_find_symbol |
Search symbol by name | {"name":"AnthropicProvider"} |
cortex_get_definition |
Get symbol definition location | {"name":"InitDB"} |
cortex_find_references |
All symbols referencing target | {"name":"GatewayContext"} |
cortex_find_callers |
Functions calling target | {"name":"Execute"} |
cortex_find_callees |
Functions called by target | {"name":"handleChatCompletions"} |
cortex_search_text |
Full-text search (name/doc/sig/path) | {"query":"pricing"} |
cortex_search_path |
Search files by path | {"query":"providers"} |
| Tool | Description | Example |
|---|---|---|
cortex_get_file |
File metadata + symbols (auto-detects dirs) | {"path":"pkg/db/db.go"} |
cortex_list_symbols |
All symbols in a file | {"path":"pkg/gateway/router.go"} |
cortex_get_module |
Files in a directory | {"path":"internal/gateway"} |
cortex_get_package |
Same as get_module (alias) | {"path":"pkg/db"} |
cortex_explore_directory |
Directory contents with metadata | {"path":"providers"} |
| Tool | Description | Example |
|---|---|---|
cortex_get_architecture |
Module-level architecture map | {} |
cortex_get_dependency_graph |
Import/dependency edges | {} |
cortex_get_call_graph |
Call tree (depth-3) for a symbol | {"name":"main"} |
cortex_get_type_graph |
Type hierarchy (structs/interfaces) | {} |
| Tool | Description | Example |
|---|---|---|
cortex_get_project_summary |
Files, symbols, nodes, edges, health | {} |
cortex_get_stats |
Same as summary | {} |
cortex_get_health |
Service health check | {} |
cortex_get_recent_changes |
Git branch + dirty files | {} |
cortex_index |
Trigger full re-index | {} |
cortex_get_type_graph |
Type nodes (struct/class/interface/enum) | {} |
{
"mcpServers": {
"cortex-index": {
"command": "cortex",
"args": ["mcp", "stdio"]
}
}
}{
"mcpServers": {
"cortex-http": {
"url": "http://localhost:8080/mcp"
}
}
}{
"mcp": {
"cortex-index": {
"type": "local",
"command": ["cortex", "mcp", "stdio"]
}
}
}cortex mcp call cortex_get_project_summary '{}'
# β 88 files, 530 symbols, 4038 edges, HEALTHYcortex mcp call cortex_build_context '{"name":"AnthropicProvider"}'
# β Target, risk score, callers, callees, neighbors, AI advicecortex mcp call cortex_find_callers '{"name":"AnthropicProvider"}'
# β 33 callers including handleChatCompletions, GetPricing, etc.
cortex mcp call cortex_find_references '{"name":"GatewayContext"}'
# β All files referencing this typecortex mcp call cortex_get_architecture '{}'
# β Module grouping with file/symbol counts
cortex mcp call cortex_get_dependency_graph '{}'
# β 200 import/dependency edgescortex mcp call cortex_get_call_graph '{"name":"handleChatCompletions"}'
# β Call tree showing request flow
cortex mcp call cortex_find_dead_code '{}'
# β 423 candidate dead functionscortex brain update "## Purpose\nAI router proxying to 10+ LLM providers"
cortex brain append "Each provider self-registers via init() β Register()"
cortex mcp call cortex_brain_append '{"line":"Cache middleware calls Execute() on cache-miss"}'# Unit tests
make test # go test ./... + UI typecheck
# Full integration test
cd ~/my-project && cortex init && cortex index && cortex serve
# MCP tool verification
cortex mcp call cortex_find_symbol '{"name":"main"}'
cortex mcp call cortex_brain_get '{}'
# Memory test (watch RSS)
/usr/bin/time -l cortex index| Category | Tools | Status |
|---|---|---|
| Brain | brain_get, brain_update, brain_append | β |
| Symbol | find_symbol, search_symbol, get_definition, search_text, search_path | β |
| Reference | find_references, find_callers, find_callees | β |
| File | get_file, list_symbols, get_module, get_package, explore_directory | β |
| Graph | get_call_graph, get_dependency_graph, get_type_graph | β |
| Architecture | get_architecture | β |
| Intelligence | build_context, find_entry_points, find_dead_code, get_diagnostics, compare_branches | β |
| Project | get_project_summary, get_stats, get_health, get_recent_changes, index | β |
cortex init # Create .cortex/ + project.json + brain.md
cortex index # Full codebase indexing
cortex watch # Real-time file watcher
cortex clean # Remove indexed data, keep config
cortex brain # Read brain.md
cortex brain update # Replace brain.md content
cortex brain append # Append "Learned" line
cortex status # Index health + stats
cortex doctor # System check
cortex serve # HTTP API + MCP + UI on :8080
cortex start -d # Daemon mode (background)
cortex stop # Stop daemon
cortex mcp stdio # MCP via stdin/stdout
cortex mcp call <tool> # Direct tool invocation
cortex hooks install # Git hooks (commit/checkout/merge)
cortex hooks remove # Remove hooksThe dashboard includes:
- Overview β Real-time metrics, indexing activity chart, language distribution
- Graph β Force-directed SVG graph with glow edges, node dragging, dark/light mode
- Data Explorer β Browse nodes, edges, files, and metadata with pagination
- Search β AI-powered semantic symbol search
- Insights β Architecture risk analysis
- Settings β Engine configuration
Built with React 19 + Vite 6 + Tailwind CSS 4 + d3-force + Recharts.
make build # Build binary + UI
make build-ui # UI only
make serve # Run backend on :8080
make ui # Run UI dev server on :3000
make dev # Both concurrently
make install # Install globallyMIT License Β© 2026 Cortex Index Team.