cortex-works/cortex-act

0

stars

8

commits

Rust

primary language

Feb 26, 2026

updated

README

cortex-act ๐Ÿ–๏ธ

The AI-Native Code Action Backend โ€” the "hands" of the Cortex ecosystem.

cortex-ast sees. cortex-act does.

License: MIT Rust


Overview

cortex-act is a pure-Rust MCP (Model Context Protocol) server that provides AI coding agents with write, edit, and execute capabilities. It is deliberately scoped to output-only operations to enforce a strict separation of concerns:

ProjectRoleCapability
CortexAST๐Ÿ‘๏ธ EyesRead-only: code analysis, symbol lookup, semantic navigation
cortex-actโœ‹ HandsWrite/execute: file edits, config patching, shell commands
CortexSync๐Ÿง  BrainGlobal memory: captures intent/decisions, vectorizes memories

Together, they form the CortexSync Ecosystem โ€” a seamless, cross-IDE memory and action layer for AI agents.

[!IMPORTANT] To enable full ecosystem features (like task-end memory capture), ensure cortex-sync is running globally and CortexAST is installed as your primary MCP server.


Tools

1. โœ๏ธ cortex_act_edit_ast

Replace or delete a named symbol (function/class/struct) in any source file. Targets by name, not line number. Auto-heals broken AST via local LLM if validation fails. Use cortexast map_overview to discover symbol names first.

2. โš™๏ธ cortex_patch_file

Surgically patch config (JSON/YAML/TOML via dot-path), markdown docs (section heading), or .env (key). Avoids full-file rewrites.

  • type=config: target='dependencies.serde'
  • type=docs: target='Installation'
  • type=env: target='API_KEY'

3. โณ cortex_act_run_async

Run a shell command as a background job. Returns immediately with job_id. Poll with cortex_check_job. Use for long-running builds, scripts, or any command that may exceed MCP timeout.

4. ๐Ÿ“Š cortex_check_job

Poll a background job (from cortex_act_run_async). Returns status (running/done/failed), exit code, duration_secs, and last 20 lines of output (log_tail).

5. ๐Ÿ›‘ cortex_kill_job

Terminate a background job (SIGTERM). No-op if job already finished.


Architecture

cortex-act/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ main.rs            # MCP stdio server (JSON-RPC 2.0)
โ”‚   โ””โ”€โ”€ act/
โ”‚       โ”œโ”€โ”€ mod.rs
โ”‚       โ”œโ”€โ”€ editor.rs      # AST Semantic Patcher + Tree-sitter validator
โ”‚       โ”œโ”€โ”€ auto_healer.rs # LLM-based syntax error repair (10s timeout)
โ”‚       โ”œโ”€โ”€ config_patcher.rs  # JSON / YAML / TOML dot-path editor
โ”‚       โ”œโ”€โ”€ docs_patcher.rs    # Markdown section replacer
โ”‚       โ”œโ”€โ”€ env_patcher.rs     # .env key-value patcher
โ”‚       โ””โ”€โ”€ job_manager.rs    # Async background job runner + file logging

MCP Configuration

Add to your mcp_config.json:

{
  "mcpServers": {
    "cortex-act": {
      "command": "/path/to/cortex-act/target/release/cortex-act",
      "args": []
    }
  }
}

Building

cargo build --release
# Binary: target/release/cortex-act

Design Principles

  1. Single Responsibility โ€” Only performs write/execute operations. Never reads or analyzes code.
  2. Two-Phase Commit โ€” All AST edits go through a virtual dry-run before touching disk.
  3. Auto-Healing โ€” Syntax errors trigger an LLM repair loop with a strict 10-second timeout.
  4. File-based Job Logs โ€” Background job output goes to ~/.cortexast/jobs/{job_id}.log to prevent OOM.
  5. Zero unsafe Rust โ€” All edits are panic-free and use structured anyhow::Result error handling.

Author

Thanon Aphithanawat โ€” thanon@aphithanawat.me

License

MIT ยฉ 2026 Thanon Aphithanawat

Contributors

zelda2003

8 commits

cortex-works/cortex-act

0

stars

8

commits

Rust

primary language

Feb 26, 2026

updated

README

cortex-act ๐Ÿ–๏ธ

The AI-Native Code Action Backend โ€” the "hands" of the Cortex ecosystem.

cortex-ast sees. cortex-act does.

License: MIT Rust


Overview

cortex-act is a pure-Rust MCP (Model Context Protocol) server that provides AI coding agents with write, edit, and execute capabilities. It is deliberately scoped to output-only operations to enforce a strict separation of concerns:

ProjectRoleCapability
CortexAST๐Ÿ‘๏ธ EyesRead-only: code analysis, symbol lookup, semantic navigation
cortex-actโœ‹ HandsWrite/execute: file edits, config patching, shell commands
CortexSync๐Ÿง  BrainGlobal memory: captures intent/decisions, vectorizes memories

Together, they form the CortexSync Ecosystem โ€” a seamless, cross-IDE memory and action layer for AI agents.

[!IMPORTANT] To enable full ecosystem features (like task-end memory capture), ensure cortex-sync is running globally and CortexAST is installed as your primary MCP server.


Tools

1. โœ๏ธ cortex_act_edit_ast

Replace or delete a named symbol (function/class/struct) in any source file. Targets by name, not line number. Auto-heals broken AST via local LLM if validation fails. Use cortexast map_overview to discover symbol names first.

2. โš™๏ธ cortex_patch_file

Surgically patch config (JSON/YAML/TOML via dot-path), markdown docs (section heading), or .env (key). Avoids full-file rewrites.

  • type=config: target='dependencies.serde'
  • type=docs: target='Installation'
  • type=env: target='API_KEY'

3. โณ cortex_act_run_async

Run a shell command as a background job. Returns immediately with job_id. Poll with cortex_check_job. Use for long-running builds, scripts, or any command that may exceed MCP timeout.

4. ๐Ÿ“Š cortex_check_job

Poll a background job (from cortex_act_run_async). Returns status (running/done/failed), exit code, duration_secs, and last 20 lines of output (log_tail).

5. ๐Ÿ›‘ cortex_kill_job

Terminate a background job (SIGTERM). No-op if job already finished.


Architecture

cortex-act/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ main.rs            # MCP stdio server (JSON-RPC 2.0)
โ”‚   โ””โ”€โ”€ act/
โ”‚       โ”œโ”€โ”€ mod.rs
โ”‚       โ”œโ”€โ”€ editor.rs      # AST Semantic Patcher + Tree-sitter validator
โ”‚       โ”œโ”€โ”€ auto_healer.rs # LLM-based syntax error repair (10s timeout)
โ”‚       โ”œโ”€โ”€ config_patcher.rs  # JSON / YAML / TOML dot-path editor
โ”‚       โ”œโ”€โ”€ docs_patcher.rs    # Markdown section replacer
โ”‚       โ”œโ”€โ”€ env_patcher.rs     # .env key-value patcher
โ”‚       โ””โ”€โ”€ job_manager.rs    # Async background job runner + file logging

MCP Configuration

Add to your mcp_config.json:

{
  "mcpServers": {
    "cortex-act": {
      "command": "/path/to/cortex-act/target/release/cortex-act",
      "args": []
    }
  }
}

Building

cargo build --release
# Binary: target/release/cortex-act

Design Principles

  1. Single Responsibility โ€” Only performs write/execute operations. Never reads or analyzes code.
  2. Two-Phase Commit โ€” All AST edits go through a virtual dry-run before touching disk.
  3. Auto-Healing โ€” Syntax errors trigger an LLM repair loop with a strict 10-second timeout.
  4. File-based Job Logs โ€” Background job output goes to ~/.cortexast/jobs/{job_id}.log to prevent OOM.
  5. Zero unsafe Rust โ€” All edits are panic-free and use structured anyhow::Result error handling.

Author

Thanon Aphithanawat โ€” thanon@aphithanawat.me

License

MIT ยฉ 2026 Thanon Aphithanawat

Contributors

zelda2003

8 commits

Languages

Rust

66.8%

Python

15.2%

Shell

4.0%

C++

2.7%

Perl

2.4%

Jupyter Notebook

2.4%

CMake

2.0%

TypeScript

1.4%

JavaScript

1.0%