ai-cortex

ai-cortex

Provides durable project context for coding agents, including project maps, session history, and explicit memories, all stored locally.

Category
访问服务器

README

ai-cortex

ai-cortex is a project knowledge substrate for coding agents.

It gives Claude, Codex, Cursor, OpenHands, and similar tools durable project context: the shape of the codebase, past agent sessions, and explicit memories for decisions, gotchas, conventions, and patterns. Everything stays local. The target repository is not modified.

<p align="center"> <img src="docs/assets/demo.gif" alt="ai-cortex demo: agent recalls a past decision and cites it" width="800" /> </p>

The Problem

Coding agents forget project knowledge.

They lose architectural constraints between sessions. They repeat mistakes after you corrected them. They rediscover code paths that were already explained. They forget why a project chose one implementation over another.

Most repositories contain code, tests, and some docs. They rarely contain the operational knowledge that makes an engineer effective in that project:

  • decisions and the reasoning behind them
  • recurring gotchas
  • conventions the user stated in conversation
  • files and systems that were already investigated
  • corrections that should persist into future sessions

ai-cortex exists to make that knowledge durable, inspectable, and available to coding agents.

What It Provides

ai-cortex has three main surfaces:

  • Project map: index a git repo, generate a session briefing, rank relevant files for a task, and inspect function blast radius.
  • Session continuity: capture compacted agent sessions so future agents can search prior decisions, corrections, file paths, and discussion.
  • Explicit memory: store typed project memories such as decision, gotcha, pattern, and how-to, then surface them when relevant.

These pieces are useful separately, but they compound when used together. A new agent session can start with a project map, recover prior discussion, and consult durable project rules before editing.

Who It Is For

ai-cortex is for experienced engineers who already use coding agents heavily and want project knowledge to survive across sessions.

It is especially aimed at people using Claude Code, Codex CLI, Cursor, OpenHands, Cline, or other MCP-compatible coding agents across real repositories.

It is not optimized for beginner onboarding or generic note-taking.

What It Is Not

ai-cortex is not:

  • a vector database
  • a generic memory framework
  • a RAG abstraction
  • hosted intelligence
  • autonomous cognition
  • orchestration software
  • magical agent memory

The philosophy is: no hidden intelligence in the substrate.

The system stores, indexes, retrieves, and surfaces developer-controlled project knowledge. It does not secretly reason about your codebase or call an LLM behind your back.

Quick Start

Requires Node.js 20 or newer and a git repository to analyze.

npm install -g ai-cortex
ai-cortex --version

Index a project:

ai-cortex index /path/to/repo

Register the MCP server so your agent can call ai-cortex tools:

claude mcp add -s user ai-cortex -- ai-cortex mcp
codex mcp add ai-cortex -- ai-cortex mcp

Install capture hooks so future sessions can be searched:

ai-cortex history install-hooks

Install the prompt guide so agents learn the memory usage pattern:

ai-cortex memory install-prompt-guide

After setup, agents can call tools such as rehydrate_project, suggest_files, search_history, recall_memory, and get_memory through MCP.

Core Mental Model

ai-cortex keeps project knowledge outside the repository:

coding agent
    |
    | MCP tools
    v
ai-cortex
    |
    | local cache
    v
~/.cache/ai-cortex/

target repository is read, not modified

There are three layers:

  • Structural: repo index, imports, functions, call graph, file ranking, blast radius.
  • Continuity: captured sessions and searchable history.
  • Memory: durable project rules, decisions, gotchas, patterns, and how-tos.

The key memory pattern is:

recall_memory -> get_memory -> apply the rule

recall_memory is browse-only. It finds candidate memories but does not mean the agent used them.

get_memory(id) fetches the full memory and records the "I am applying this" signal.

That split keeps memory usage inspectable instead of magical.

Why It Is Different

Most agent memory systems blur storage, retrieval, reasoning, and automation.

ai-cortex keeps the substrate boring on purpose:

  • local-first storage under ~/.cache/ai-cortex/
  • no writes into the target repository
  • MCP surface for agent interoperability
  • explicit memory records with lifecycle and audit history
  • no hidden LLM calls in the substrate
  • developer-controlled promotion, deprecation, cleanup, and inspection

The goal is not to make the agent autonomous. The goal is to make project knowledge durable enough that an agent can work with the context an engineer has already established.

Inspecting Performance

Run cortex stats (or cortex stats --once for a snapshot) to open the dashboard. The top of the overview shows two verdict bands: one synthesizing "Is ai-cortex helping? (all projects)" across every cached workspace, and one named after the currently-selected project so a single workspace's signal is never drowned out by the cross-project average. Press ? for an overlay that explains every metric and its good/ok/bad thresholds (single source of truth: src/lib/stats/verdict.ts).

<p align="center"> <img src="docs/assets/dashboard-two-verdicts.png" alt="cortex stats dashboard showing two verdict bands: 'Is ai-cortex helping? (all projects)' with a mixed/yellow verdict above 'ai-cortex (this project)' with a green YES verdict, plus per-project Effectiveness/Activity/Memory panels and a cross-project Storage panel" width="800" /> </p>

To hide a workspace (e.g. a test/smoke-run repo) from the dashboard, select it with j/k and press:

  • e — exclude (reversible: edit ~/.cache/ai-cortex/v1/stats-config.json)
  • a — archive (move cache to ~/.cache/ai-cortex/v1/_archived/<repoKey>/)
  • x — clean (prompts y/n; deletes the cache dir, irreversible)

Where To Go Next

  • Getting started: install, connect an agent, index a repo, capture sessions, and record a first memory.
  • Agent integration: MCP registration, session hooks, prompt guidance, and harness-specific behavior.
  • Troubleshooting: common setup, cache, MCP, stats, and memory recovery paths.
  • Mental model: project map, session continuity, explicit memory, and no hidden intelligence.
  • Memory model: memory types, scope, lifecycle, recall/use, and what makes a good memory.
  • CLI reference: command groups and common flags.
  • MCP tools: agent-facing tools and when to use each one.
  • Library API: public Node.js API for structural indexing and analysis.
  • Language support: parser-backed language coverage and call graph limits.
  • Benchmarking: performance and ranking-quality benchmark suites.
  • Storage reference: cache layout, local-first boundaries, and rebuildable state.
  • Configuration: environment variables, memory config, and agent config touchpoints.
  • Limitations: current bounds, weak spots, and harness-specific behavior.
  • Architecture overview: technical system map and data flow.
  • Roadmap: shipped foundation, future directions, and non-goals.
  • Docs index: full documentation map.
  • Changelog: release history.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选