Cortex

Cortex

Enforces structured, evidence-guided software engineering tasks with cognitive actions (investigate, plan, verify, remember) and persistent state for LLM-based coding agents.

Category
Visit Server

README

Cortex

An evidence-guided agent kernel for software-engineering agents.

Cortex is a small, local-first runtime that sits between an LLM and a set of specialist tools. It does not replace the model's planning or coding ability — it supplies the parts models are consistently bad at preserving across long tool-using tasks:

  • a stable task state,
  • explicit evidence and uncertainty,
  • disciplined tool selection,
  • bounded changes,
  • verification tied to user-visible behavior,
  • durable, structured memory,
  • secret-safe execution.

The result is a model that is forced into a better reasoning loop:

orient → investigate → form hypotheses → declare a boundary → change → verify → preserve evidence

More tools without structure = more ways to get lost. Specialized tools + a kernel = accumulated engineering judgment.


Why

A capable coding model often fails not because it cannot write a function, but because it cannot maintain epistemic discipline through a multi-step task:

user report → broad search → read a few files → infer a likely cause →
edit several files → run one command → interpret partial success as proof →
lose the trail of why each decision was made

Cortex makes tool use stateful, bounded, inspectable, and evidence-driven — without becoming an autonomous black box. The model stays the planner and author; Cortex ensures its claims have an evidence trail and its actions occur inside a declared operating envelope.

What it does

Cortex exposes six cognitive actions instead of dozens of overlapping raw tools:

Action What it enforces
start opens a durable case file; orients on git identity and tool health
investigate routes a question through discovery (vecgrep) then structure (codemap); records evidence with provenance — search output is a candidate, not proof
plan requires a testable hypothesis with a disproof path, a change boundary, and a verification plan — plans without a disproof path are rejected
verify runs the required verifiers (structural review + browser/terminal specs), detects scope drift, and writes a receipt per claim — a claim with no verifier is not_run, never passed
remember persists the outcome and completes the task — completion is impossible without a verification receipt (or an explicit "not possible" acknowledgment)
status phase, unresolved hypotheses, scope drift, missing verification, tool health

These are structural invariants enforced by a phase machine, not by prompting. A model can't skip the disproof path by restating a hypothesis, or call a change "done" without proof.

Install

go install github.com/abdul-hamid-achik/cortex/cmd/cortex@latest
# or, from a clone:
task build   # → ./bin/cortex

Cortex is a single pure-Go binary (CGO_ENABLED=0). The specialist tools it composes (codemap, vecgrep, cairn, glyph, fcheap, vidtrace, tvault) are optional at runtime — every adapter degrades safely when its tool is absent, and Cortex never fabricates a missing tool's output.

Quick start (CLI)

# 1. Open a case and orient
cortex start "Fix post-login checkout redirect" --surface code --surface browser
#   → task_06FK…  [investigating]

# 2. Investigate (routes vecgrep → codemap, records evidence)
cortex investigate task_06FK… "where is the OAuth return URL handled"

# 3. Plan — a hypothesis WITH a disproof path is mandatory
cortex plan task_06FK… \
  --hypothesis "returnTo is dropped before callback :: run login-from-checkout browser flow" \
  --file src/auth/callback.ts --symbol HandleCallback \
  --uncertainty "unsure whether state signing also strips it"

# 4. …make your edits within the boundary, then verify
cortex verify task_06FK… \
  --claim "the OAuth callback preserves the return URL" \
  --browser-spec specs/cairntrace/checkout_return.yml

# 5. Complete — needs a verification receipt to succeed
cortex remember task_06FK… "returnTo was dropped from signed state; fixed and browser-verified" \
  --tag auth --tag oauth

# anytime: inspect the case
cortex status task_06FK… --detail full
cortex list
cortex doctor              # environment + specialist tool health
cortex studio               # interactive read-only case browser (Charm v2 TUI)

Every read command supports --json for machine consumption. Output is styled at a TTY and plain when piped.

MCP server

Cortex speaks the Model Context Protocol over stdio (newline-delimited JSON-RPC):

cortex serve

It exposes ten tools: cortex_start_task, cortex_investigate, cortex_plan, cortex_verify, cortex_remember, cortex_status, cortex_resolve, cortex_abort_task, cortex_read_evidence, cortex_read_artifact.

Register it with mcphub:

mcphub add cortex cortex serve
mcphub sync --write

In gateway mode the agent sees only mcphub, which proxies Cortex's tools as cortex__<tool> and keeps the raw specialist tools available as an expert escape hatch.

The case file

Each non-trivial task gets a durable, human-readable case file under .agent/cases/<taskId>/:

.agent/cases/task_06FK…/
  case.json          # goal, workspace identity, phase, change boundary, required verification
  evidence.jsonl     # append-only ledger of claims with provenance and confidence
  hypotheses.json    # falsifiable explanations + disproof paths
  plan.json          # the planning gate
  verification.json  # receipts: which claim, which verifier, passed/failed/not_run
  commands.jsonl     # non-sensitive audit trail of tool invocations
  summary.md         # the readable outcome

It is the kernel's working memory, not a transcript. Cortex writes .agent/.gitignore so its own state never registers as a workspace change.

The ecosystem it composes

Tool Role in Cortex
codemap structural code graph — impact, callers, diff review
vecgrep semantic/keyword discovery + cross-session memory
cairntrace browser behavior verification
glyphrun terminal/TUI behavior verification
file.cheap (fcheap) durable evidence stash + search
tinyvault (tvault) secret-safe execution boundary (values never enter model context)
mcphub MCP gateway that exposes Cortex as the default agent interface

Documentation

Full docs (built with VitePress) live in docs/. Run locally with task docs. The design specification is in SPEC.md; architecture and contributor guidance in AGENTS.md.

Status

v0.1 (MVP). The kernel, both surfaces (CLI + MCP), all eight adapters, the case-file store, redaction, scope-drift detection, and the verification policy are implemented and tested. See SPEC.md §21 for the milestone roadmap.

License

MIT © 2026 Abdul Hamid Achik

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured