Skip to content

Latest commit

Β 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Cortex Index β€” Local-First AI Workspace Manager

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.

⚑ Key Features

  • 20 MCP Tools β€” Full Model Context Protocol (MCP v1.0) over stdio JSON-RPC 2.0
  • 🧠 Brain System β€” Persistent .cortex/brain.md stores project purpose, rules, and knowledge. Created on cortex init, queryable via cortex_brain_get/update/append MCP tools. AI agents learn once, remember forever.
  • Search Layer β€” Three search tools: recursive knowledge base search, line-level grep across workspace files, and glob pattern matching for file discovery.
  • Skills Management β€” Install, uninstall, list, search, and update reusable AI skill conventions templates. Both workspace-scoped and global.
  • Task Tracking β€” Create, update, complete, list, show, and delete tracked tasks in .cortex/tasks/.
  • Codebase Documentation β€” Auto-generated architecture overview (codebase.md) with metadata that stays in sync via cortex update.
  • Project-Local β€” No global database. Each project owns .cortex/ next to it. cortex init creates it. cortex clean resets it.
  • Embedded Storage β€” Pebble LSM tree embedded KV store at .cortex/data/.

πŸ—οΈ Architecture

                     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                     β”‚  AI Agent     β”‚
                     β”‚ (Claude/etc)  β”‚
                     β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
                             β”‚ MCP (Stdio)
                β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                β”‚    Cortex MCP Server     β”‚
                β”‚  20 tools Β· JSON-RPC 2.0 β”‚
                β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                             β”‚
           β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
           β”‚                 β”‚                  β”‚
      β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”
      β”‚  Brain   β”‚     β”‚  Search   β”‚     β”‚  Skills &    β”‚
      β”‚ (3 tools)β”‚     β”‚ (3 tools) β”‚     β”‚  Tasks       β”‚
      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β”‚  (7 tools)   β”‚
                                        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                β”‚
                          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                          β”‚                                         β”‚
                    β”Œβ”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”                           β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”
                    β”‚  Codebase  β”‚                           β”‚   Project    β”‚
                    β”‚  (3 tools) β”‚                           β”‚   Metadata   β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                           β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸš€ Getting Started

# Install
git clone https://github.com/Haslab-dev/CortexIndex.git
cd CortexIndex && make && make install

# Create a project
cd ~/my-project
cortex init            # creates .cortex/ + project.json + brain.md + codebase.md + full index
cortex update          # refresh project metadata and codebase.md

# Quick MCP test
cortex mcp call cortex_brain_get '{}'

🧠 Brain System β€” Persistent Agent Knowledge

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.

# Read brain
cortex brain

# Add knowledge (append)
cortex brain add "Uses Pebble KV storage"

# Append as "Learned"
cortex brain append "Providers self-register via init() calling Register()"

# Add a rule
cortex brain rule add "All APIs must have timeout handling"

# Add a permission
cortex brain permission add "can access database credentials"

# Set an instruction
cortex brain instruction set "Always check .cortex/brain.md before modifying code"

# Search brain content
cortex brain search "Pebble"

# Via MCP (agent-friendly)
cortex mcp call cortex_brain_append '{"line":"Uses Pebble KV storage"}'

The brain persists between agent sessions β€” knowledge learned once is retained.


πŸ“Š Performance Benchmarks

Tested on cortex-index (self-project):

Operation Time Notes
Brain get <1ms Read brain.md content
Brain append <1ms append-only write
Grep workspace <1ms Recursive text search
Glob pattern <1ms File path matching
Skill CRUD <1ms install/uninstall/list/search/update
Task CRUD <1ms create/update/complete/list/show/delete
Codebase init <1ms Generate architecture overview
Codebase update <1ms Refresh metadata

πŸ”Œ 20 MCP Tools Reference

🧠 Brain (3 tools)

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"}

πŸ” Search (3 tools)

Tool Description Example
cortex_search Search knowledge base and codebase files recursively {"query":"MCP"}
cortex_grep Search for target text within workspace files {"query":"cortex"}
cortex_glob Match file paths in workspace using glob pattern {"pattern":"**/*.go"}

🎯 Skills (5 tools)

Tool Description Example
cortex_skill_install Install a coding skill conventions template {"name":"refactor"}
cortex_skill_uninstall Uninstall a coding skill conventions template {"name":"refactor"}
cortex_skill_list List all global and workspace skills {}
cortex_skill_search Search for skills by query text {"query":"refactor"}
cortex_skill_update Update or install coding skill content {"name":"refactor"}

βœ… Tasks (6 tools)

Tool Description Example
cortex_task_create Create a task tracking document {"name":"test","goal":"Test"}
cortex_task_update Update active task status {"name":"test","status":"in_progress"}
cortex_task_complete Mark a task tracking document completed {"name":"test"}
cortex_task_list List all registered workspace tasks {}
cortex_task_show Show detailed task instructions {"name":"test"}
cortex_task_delete Delete/remove task document from workspace {"name":"test"}

πŸ“ Codebase (3 tools)

Tool Description Example
cortex_codebase_init Initialize codebase.md architecture overview {}
cortex_codebase_update Update codebase.md metadata recursively {}
cortex_codebase_get Get the content of the codebase.md architecture overview file {}

πŸ”Œ MCP Client Configuration

Claude Desktop / Antigravity / Cursor / Kilo AI

{
  "mcpServers": {
    "cortex-index": {
      "command": "cortex",
      "args": ["mcp", "stdio"]
    }
  }
}

MCP is stdio-only. No HTTP transport. The server runs per-session and exits when the parent closes stdin.


πŸ§ͺ Tutorial: AI Agent Working with Cortex

Step 1 β€” Initialize the project

cortex init
# β†’ βœ“ Initialized Cortex 2.0 project 'my-project'

Step 2 β€” Explore the brain

cortex brain
# β†’ Shows brain.md content

cortex mcp call cortex_brain_get '{}'
# β†’ Returns brain.md content as JSON-RPC response

Step 3 β€” Search the codebase

cortex search "MCP"
# β†’ Returns matching lines from knowledge base and codebase files

cortex grep "cortex"
# β†’ Returns matching lines in workspace files

cortex glob "**/*.go"
# β†’ Returns matching file paths

Step 4 β€” Manage tasks

cortex task create refactor-router "Refactor API router" "Use handler pattern"
cortex task list
cortex task update refactor-router in_progress
cortex task complete refactor-router
cortex task delete refactor-router

Step 5 β€” Manage skills

cortex skill install refactor
cortex skill list
cortex skill search refactor
cortex skill update refactor "Updated content here"
cortex skill uninstall refactor

Step 6 β€” Persistent learning via brain

cortex brain append "Uses Pebble KV storage at .cortex/data/"
cortex brain rule add "All APIs must have timeout handling"
cortex brain permission add "can access database credentials"

# Via MCP (agent-friendly)
cortex mcp call cortex_brain_append '{"line":"Uses Pebble KV storage"}'

πŸ§ͺ Testing & Verification

MCP Tool Verification (2026-07-31)

All 20 MCP tools were tested against this project using the cortex MCP interface:

# Tool Test Input Result
1 cortex_search {"query":"MCP"} βœ… Returns matching results
2 cortex_grep {"query":"cortex"} βœ… Returns matching lines in workspace files
3 cortex_glob {"pattern":"**/*.go"} βœ… Returns matching file paths
4 cortex_brain_get {} βœ… Returns brain.md content
5 cortex_brain_append {"line":"Test line"} βœ… Appended "Learned" entry
6 cortex_brain_update {"content":"Updated"} βœ… Replaced brain content
7 cortex_skill_install {"name":"refactor"} βœ… Installed skill
8 cortex_skill_uninstall {"name":"refactor"} βœ… Uninstalled skill
9 cortex_skill_list {} βœ… Lists installed skills
10 cortex_skill_search {"query":"refactor"} βœ… Returns matching skills
11 cortex_skill_update {"name":"refactor"} βœ… Updated skill
12 cortex_task_create {"name":"test","goal":"Test"} βœ… Task created
13 cortex_task_list {} βœ… Lists tasks
14 cortex_task_show {"name":"test"} βœ… Shows task details
15 cortex_task_update {"name":"test","status":"in_progress"} βœ… Updated
16 cortex_task_complete {"name":"test"} βœ… Completed
17 cortex_task_delete {"name":"test"} βœ… Deleted
18 cortex_codebase_init {} βœ… Initialized codebase.md
19 cortex_codebase_update {} βœ… Updated codebase.md metadata
20 cortex_codebase_get {} βœ… Returns codebase.md content

Category Summary

Category Tools Count Status
Brain brain_get, brain_update, brain_append 3 βœ… All passing
Search search, grep, glob 3 βœ… All passing
Skills skill_install, skill_uninstall, skill_list, skill_search, skill_update 5 βœ… All passing
Tasks task_create, task_update, task_complete, task_list, task_show, task_delete 6 βœ… All passing
Codebase codebase_init, codebase_update, codebase_get 3 βœ… All passing
Total 20 βœ… All passing

πŸ› οΈ CLI Reference

cortex init                      Initialize .cortex directory, project.json, brain.md, codebase.md
cortex update                    Update project metadata and codebase.md
cortex doctor                    Check system environment and project health

cortex codebase [init|update|show|append]
                                 Manage codebase.md architecture files
cortex brain [add|show|search|rule add|permission add|instruction set|prune]
                                 Manage persistent append-only workspace brain logs
cortex task [create|update|continue|complete|list|show|delete]
                                 Manage workspace tasks in .cortex/tasks/
cortex skill [install|uninstall|list|search|update]
                                 Manage workspace and global AI skills
cortex search <query>            Orchestrate searches across knowledge and files
cortex grep <query>              Grep text in workspace
cortex glob <pattern>            Match file paths in workspace

cortex mcp stdio                 Start MCP stdio server
cortex mcp call <toolName> [jsonArgs]
                                 Execute MCP tool directly

πŸ“„ License

MIT License Β© 2026 Cortex Index Team.

About

Local-first AI code intelligence engine & persistent semantic OS for your codebase. Features: 22 native MCP tools, Go AST graph engine, Context Builder, and a Bun-powered Web UI dashboard.

Resources

Stars

6 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages