CodeCortex MCP Server

Local setup required. This server has to be cloned and prepared on your machine before you register it in Claude Code.
1

Set the server up locally

Run this once to clone and prepare the server before adding it to Claude Code.

Run in terminal
npm install -g codecortex-ai --legacy-peer-deps
2

Register it in Claude Code

After the local setup is done, run this command to point Claude Code at the built server.

Run in terminal
claude mcp add codecortex -- node "<FULL_PATH_TO_CODECORTEX>/dist/index.js"

Replace <FULL_PATH_TO_CODECORTEX>/dist/index.js with the actual folder you prepared in step 1.

README.md

Persistent codebase knowledge layer for AI agents.

CodeCortex

Persistent codebase knowledge layer for AI agents. Pre-builds architecture, dependencies, coupling, and risk knowledge so agents skip the cold start and go straight to the right files.

Website · npm · GitHub

The Problem

Every AI coding session starts with exploration — grepping, reading wrong files, re-discovering architecture. On a 6,000-file codebase, an agent makes 37 tool calls and burns 79K tokens just to understand what's where. And it still can't tell you which files are dangerous to edit or which files secretly depend on each other.

The data backs this up:

The Solution

CodeCortex eliminates the cold start. It pre-builds codebase knowledge — architecture, dependencies, risk areas, hidden coupling — and injects it directly into your agent's context (CLAUDE.md, .cursorrules, etc.) so agents have project knowledge from the first prompt.

Not a middleware. Not a proxy. Just knowledge your agent loads on day one.

Tested on a real 6,400-file codebase (143K symbols, 96 modules):

Without CodeCortex With CodeCortex
Tool calls 37 15 (2.5x fewer)
Total tokens 79K 43K (~50% fewer)
Answer quality 23/25 23/25 (same)
Hidden dependencies found No Yes

What makes it unique

Three capabilities no other tool provides:

  1. Temporal coupling — Files that always change together but have zero imports between them. You can read every line and never discover this. Only git co-change analysis reveals it.

  2. Risk scores — File X has been bug-fixed 7 times, has 6 hidden dependencies, and co-changes with 3 other files. Risk score: 35. You can't learn this from reading code.

  3. Inline context injection — Project knowledge is injected directly into CLAUDE.md, .cursorrules, and other agent config files with architecture, risk map, and editing directives. Agents use it without any setup.

Example from a real codebase:

  • schema.help.ts and schema.labels.ts co-changed in 12/14 commits (86%) with zero imports between them
  • Without this knowledge, an AI editing one file would produce a bug 86% of the time

Quick Start

Requires Node 20 or 22. Node 24 is not yet supported (tree-sitter native bindings need an upstream update).

# Install (--legacy-peer-deps needed for tree-sitter peer dep mismatches)
npm install -g codecortex-ai --legacy-peer-deps

# Initialize knowledge for your project
cd /path/to/your-project
codecortex init

# Regenerate inline context in CLAUDE.md and agent config files
codecortex inject

Connect to Claude Code

CLI (recommended):

claude mcp add codecortex -- codecortex serve

Or add to MCP config manually:

{
  "mcpServers": {
    "codecortex": {
      "command": "codecortex",
      "args": ["serve"],
      "cwd": "/path/to/your-project"
    }
  }
}

Connect to Cursor

Add to .cursor/mcp.json:

{
  "mcpServers": {
    "codecortex": {
      "command": "codecortex",
      "args": ["serve"],
      "cwd": "/path/to/your-project"
    }
  }
}

What Gets Generated

All knowledge lives in .codecortex/ as flat files in your repo, plus inline context is injected into agent config files:

.codecortex/
  cortex.yaml          # project manifest
  constitution.md      # project overview for agents
  overview.md          # module map + entry points
  graph.json           # dependency graph (imports, calls, modules)
  symbols.json         # full symbol index (functions, classes, types...)
  temporal.json        # git coupling, hotspots, bug history
  hotspots.md          # risk-ranked files (static, always available)
  AGENT.md             # tool usage guide for AI agents
  modules/*.md         # per-module structural analysis
  decisions/*.md       # architectural decision records
  sessions/*.md        # session change logs
  patterns.md          # coding patterns and conventions

CLAUDE.md

Configuration

claude_desktop_config.json
{"mcpServers": {"codecortex": {"command": "codecortex", "args": ["serve"], "cwd": "/path/to/your-project"}}}

Try it

Analyze the current codebase and identify high-risk files based on temporal coupling.
Explain the architectural dependencies between the schema modules.
What are the hidden coupling patterns in this project that might cause bugs during refactoring?
Generate a summary of the project's coding patterns and conventions for my next task.

Frequently Asked Questions

What are the key features of CodeCortex?

Pre-builds codebase architecture, dependencies, and risk knowledge. Identifies temporal coupling between files that change together. Calculates risk scores based on bug history and hidden dependencies. Injects project knowledge directly into CLAUDE.md and .cursorrules. Reduces token usage and tool calls by providing pre-digested context.

What can I use CodeCortex for?

Onboarding AI agents to large, unfamiliar codebases without manual exploration. Identifying high-risk files that are prone to bugs during refactoring. Discovering hidden dependencies between files that lack explicit imports. Maintaining consistent architectural standards across AI-assisted coding sessions.

How do I install CodeCortex?

Install CodeCortex by running: npm install -g codecortex-ai --legacy-peer-deps

What MCP clients work with CodeCortex?

CodeCortex works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Turn this server into reusable context

Keep CodeCortex docs, env vars, and workflow notes in Conare so your agent carries them across sessions.

Need the old visual installer? Open Conare IDE.
Open Conare