The AI-Native Code Intelligence Backend for LLM Agents Pure Rust Β· MCP Server Β· Semantic Code Navigation Β· AST Time Machine Β· Self-Evolving Wasm Parsers
ποΈ CortexAST is the "eyes" β read-only code intelligence. For write/execute capabilities, see the companion
cortex-actproject (the "hands").
CortexAST is a production-grade MCP (Model Context Protocol) server that gives AI coding agents (Claude, Gemini, GPT-4o, etc.) the ability to:
- Navigate codebases semantically β find symbols, blast-radius analysis, cross-file propagation checklists
- Evolve itself β download and hot-reload WebAssembly language parsers at runtime (Go, PHP, Ruby, Java, β¦)
- Time-travel your codebase β Chronos snapshot system for pre/post-refactor AST-level comparison
- Search local memory β hybrid semantic + keyword search over your codebase history
β To edit files, run commands, or patch configs, use cortex-act instead.
Codebase explorer. Use INSTEAD of ls/tree/find/cat. Two modes: map_overview (fast symbol map, near-zero tokens β run first on any repo) and deep_slice (token-budgeted XML with function bodies, vector-ranked by query). Use map_overview to orient; deep_slice to get code for editing.
AST symbol analysis. Use INSTEAD of grep/rg. Actions: read_source (extract exact source of a symbol from a file β do this before editing), find_usages (all call/type/field sites), find_implementations (structs implementing a trait), blast_radius (callers + callees β run before rename/delete), propagation_checklist (exhaustive update checklist for shared types).
AST snapshot tool for safe refactors. Workflow: save_checkpoint (before edit) β edit β compare_checkpoint (verify). Use instead of git diff β AST-level, ignores formatting noise. Actions: save_checkpoint, list_checkpoints, compare_checkpoint, delete_checkpoint.
Run compiler diagnostics (cargo check / tsc / gcc). Call after any code edit to catch errors before proceeding. Returns file, line, code, message β structured for targeted fixes.
Search past agent decisions in global memory (semantic + keyword hybrid). Requires CortexSync. Call BEFORE any research or exploration β the answer may already be cached. Returns ranked entries: intent, decision, tags, files_touched.
Fetch codebase AI rules for the current context. Requires CortexSync. Returns merged rules filtered by file_path (frontend/backend/db context). Call before starting any task in a new project.
Save task outcome to permanent global memory. Requires CortexSync. Call at END of every task. intent+decision must be β€200 chars each. For long artifacts write a file first and pass path via heavy_artifacts.
List all AI-tracked codebases (Requires CortexSync network). Use to discover target_project IDs for cross-project operations.
Manage Wasm grammar parsers for non-core languages. Core (always active): rust, typescript, python. Call status to see active/available languages. Call add with languages[] to download and hot-reload parsers from GitHub tree-sitter releases. Available: go, php, cpp, c, c_sharp, java, ruby, dart.
For full functionality, CortexSync (the "Brain") must be running in the background.
| Tool | Dependent on CortexSync? | Why? |
|---|---|---|
cortex_remember |
Yes | Persists task outcomes to the global journal. |
cortex_memory_retriever |
Yes | Performs semantic vector search over past decisions. |
cortex_get_rules |
Yes | Fetches centralized rules from the synchronized rule engine. |
cortex_list_network |
Yes | Reads the global network map of codebases. |
cortex_code_explorer |
No | Local AST analysis. |
cortex_symbol_analyzer |
No | Local AST analysis. |
If cortex-sync is offline, these tools will strictly return a graceful warning without interrupting the agent's workflow.
- Rust 1.80+
- Ollama or LM Studio running locally (optional, for Auto-Healer)
git clone https://github.com/DevsHero/CortexAST
cd CortexAST
cargo build --release
# Run as MCP server (stdio)
./target/release/cortexast{
"mcpServers": {
"cortexast": {
"command": "/path/to/cortexast",
"args": []
}
}
}{
"name": "cortex_code_explorer",
"arguments": {
"action": "map_overview",
"target_dir": "."
}
}{
"name": "cortex_symbol_analyzer",
"arguments": {
"action": "find_usages",
"symbol_name": "AuthService",
"target_dir": "."
}
}{
"name": "cortex_chronos",
"arguments": {
"action": "compare_checkpoint",
"symbol_name": "login",
"tag_a": "pre-refactor",
"tag_b": "__live__"
}
}| Always Available | Downloadable on Demand |
|---|---|
| Rust, TypeScript/JS, Python | Go, PHP, Ruby, Java, C, C++, C#, Dart |
# Agent calls this automatically when it detects a new language:
cortex_manage_ast_languages { "action": "add", "languages": ["go", "dart"] }# Run all unit tests
cargo test
# Check (no link)
cargo check
---
## Architecture
CortexAST (binary) βββ src/ βββ server.rs # MCP stdio server β all tool schemas + handlers βββ inspector.rs # LanguageConfig, LanguageDriver, Symbol, run_query βββ grammar_manager.rs # Wasm download + hot-reload (GitHub releases) βββ vector_store.rs # model2vec embeddings + cache invalidation βββ chronos.rs # AST snapshot time machine (Chronos) βββ memory.rs # global_memory.jsonl journal client βββ project_map.rs # Network map for multi-repo roaming
## License
MIT β See [LICENSE](./LICENSE)
---
*Built with β€οΈ in Rust Β· Semantic precision for the AI age*