project-brain-mcp
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@project-brain-mcpIndex the codebase and run bootstrap to generate constraints.md"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
project-brain-mcp
Standalone MCP server that gives CLI
coding agents (Claude Code, Cline, Cursor, opencode) persistent decision
memory, codebase dependency-graph awareness, plan validation against
architectural constraints, and a self-bootstrapping constraints.md file —
backed by a local SQLite database (.project-brain/decisions.db) in each
project it's wired into.
CLI agent support status
Agent | Status |
Claude Code | ✅ Tested end-to-end (indexing, dependency graph, decision memory, plan validation, bootstrap, all 24 tools). |
Cline | ⚠️ Skill package shipped ( |
Cursor | ⚠️ Skill package shipped ( |
opencode | ⚠️ Skill package shipped ( |
If you try this with Cline, Cursor, or opencode, please open an issue with what worked / didn't — that feedback directly shapes which agent gets verified next.
Related MCP server: myBrAIn
Use case scenarios
These are real flows this server enables once wired into a project (the examples below are from testing against a Laravel/PHP codebase, but the same flows apply to any supported language):
Onboarding into an unfamiliar codebase. Run
index_codebaseonce, thenrun_bootstrap— the agent walks every module, records its inferred purpose/constraints/caveats vialog_module_intent, and generates a draftconstraints.md(Architectural Boundaries, Technology Constraints) for you to review and correct."What breaks if I change this?" Before editing a shared model or service, the agent calls
get_dependents/get_blast_radiusto see every file that transitively depends on it — e.g. confirming that changingapp/Models/User.phponly affectsdatabase/seeders/DatabaseSeeder.php, not half the app.Don't repeat past mistakes. When an approach fails (a library doesn't fit, a migration breaks under load, etc.), the agent logs it with
log_failure. In a later session,get_context(topic)surfaces that failure before the agent tries the same thing again.Plan review against architectural rules. Before executing a multi-step plan,
validate_plan(task, steps)checks each step against logged hard constraints and graph-derived boundaries, returningPLAN: blockedwith specific fixes if a step would violate one."Where do I even start?" For a feature request described in plain English,
find_entry_points(intent)does a semantic search over indexed modules — e.g.intent="HTTP request entry point for the web application"returned the relevant controllers in a Laravel app.Tracking structural drift over time.
diff_graph(since_commit)shows which dependency edges were added/removed since a given commit — useful after pulling a large set of changes before continuing work.
Supported languages
The code-graph indexer (index_codebase) parses these file types via
tree-sitter:
Language | Extensions |
TypeScript / JavaScript |
|
Python |
|
Rust |
|
Go |
|
Java |
|
C / C++ |
|
PHP |
|
Other file types are indexed as plain nodes but produce no dependency edges.
Prerequisites
Node.js
^20 || ^22 || >=24A git working tree for the project you want to wire this into (most tools work without git, but
diff_graphand the incremental CLI ingest path use the current commit hash)
Install & build
git clone <this-repo>
cd code-brain-mcp
npm install
npm run buildThis produces dist/src/index.js (the MCP server entry point) and
dist/cli/index.js (the project-brain CLI for remote ingest, see below).
Setup in a project
Option A — automated install script (recommended)
From the root of the project you want to add code-brain-mcp to:
/path/to/code-brain-mcp/scripts/install.shThe script:
Detects which agent(s) you use, based on marker files in your project:
Claude Code:
CLAUDE.mdor.claude/Cline:
.clinerulesor.cline/Cursor:
.cursorrulesor.cursor/opencode:
AGENTS.mdor.opencode/
Installs/merges the matching skill package from
skills/<agent>/into your project (project-memory instructions + a bootstrap flow), preserving any existing content in those files (code-brain-mcp's block is wrapped in<!-- code-brain-mcp:start/end -->markers).Registers the MCP server in your agent's config (
.mcp.json,.cursor/mcp.json,opencode.json). Cline stores MCP config outside the repo — the script prints the entry to add manually via the Cline "MCP Servers" panel.Creates
.project-brain/(the local SQLite database directory) if it doesn't already exist.Installs a
.git/hooks/post-commithook (for the optional remote-ingest workflow, see below).
If no marker file is detected, the script exits with instructions for adding one manually.
Option B — manual config (Claude Code)
Add to .mcp.json (or your global ~/.claude.json under mcpServers):
{
"mcpServers": {
"code-brain": {
"command": "node",
"args": ["/path/to/code-brain-mcp/dist/src/index.js"]
}
}
}Then copy skills/claude-code/CLAUDE.md and skills/claude-code/bootstrap.md
into your project so Claude Code knows how/when to call the tools.
First run
You don't need to type these calls yourself. Once
skills/claude-code/CLAUDE.mdis installed in your project root (viascripts/install.shor copied manually), Claude Code auto-loads it every session and treats the steps below as always-on behavior — it calls these tools on its own as part of normal work, andget_session_health()self-corrects if it skips one. The steps below are what happens under the hood, useful mainly for the very first run or for manual/CLI testing.
In a fresh Claude Code session in your project:
start_session()get_context(topic="...")— loads project memory, required before other tool calls per the session-health checker.index_codebase(incremental=false)— builds the initial dependency graph.get_bootstrap_status()— ifnever_run, runrun_bootstrap(path)repeatedly (seeskills/<agent>/bootstrap.mdfor the full multi-turn flow) to populateconstraints.mdwith the project's architectural boundaries and technology constraints.
After that, CLAUDE.md (or the equivalent rule file for your agent) describes
the always-on behaviors: calling get_dependents/get_dependencies/
get_blast_radius before changing a module, validate_plan before executing
a multi-step plan, log_decision/log_failure to build up project memory,
etc.
Transport modes
Mode | Default | Auth | Notes |
| yes | none | Single project, single SQLite file, spawned by your agent. |
| set |
| Enables |
Remote mode env vars: TRANSPORT_MODE, PROJECT_BRAIN_TOKEN, HOST
(default 127.0.0.1), PORT (default 8420), SQLITE_BUSY_TIMEOUT_MS
(default 5000).
Remote ingest CLI
For the remote-server setup, the project-brain CLI (dist/cli/index.js)
pushes graph updates from a separate machine/CI job:
project-brain index --full --push --url https://your-server --token $PROJECT_BRAIN_TOKEN
project-brain index --since <commit> --push --url https://your-server --token $PROJECT_BRAIN_TOKENThe installed post-commit git hook runs the --since HEAD~1 --push
incremental form automatically if PROJECT_BRAIN_URL is set in your
environment.
Project memory file: constraints.md
export_constraints_file() generates a human-readable constraints.md at
your project root (YAML frontmatter + Architectural Boundaries / Technology
Constraints / Flagged-for-review sections). Edit it by hand, then call
ingest_constraints_file() to sync your edits back into the database. See
constraints.md in this repo for a live example of the format.
A note on secrets
index_codebase never reads or stores raw file contents — it only parses
source files (per the extensions listed above) for import/dependency edges,
and stores file paths + module names in .project-brain/decisions.db. It
never reads .env files or similar.
The decisions/failures/module_intents/constraints tables store
free-text written by your agent via log_decision, log_failure, and
log_module_intent — avoid having your agent paste secrets/credentials into
those calls, the same way you would with any chat. .project-brain/ is
already in .gitignore, so this database stays local and is never committed.
Roadmap
Verify Cline / Cursor / opencode support. Skill packages and install paths exist for all three (
skills/<agent>/), but only Claude Code has been tested end-to-end so far.Plugin-based language support. Today, adding a language means adding a tree-sitter grammar dependency and a walker function in
src/parser/treesitter.ts(see PHP support as the most recent example). The goal is to make this a drop-in plugin interface so the community can add languages (Java/Kotlin for Android, C#/.NET, etc.) without touching core indexer code.Composer autoload beyond PSR-4. PHP support currently resolves
usestatements via PSR-4 only;classmap/files/psr-0autoload strategies and multi-composer.jsonmonorepos are not yet covered.Non-code / document repos. The dependency-graph model is code-specific today (tree-sitter ASTs). An exploratory direction is a parallel "document graph" mode for non-code repositories (e.g. a folder of legal contracts or policy documents) — same decision-memory/constraints-file mechanics, but relationships derived from document structure/references instead of imports. This is an early idea, not yet scoped into a spec.
Contributions and issue reports toward any of the above are welcome.
Development
npm test # vitest
npm run build # tsc
npm run dev # run the server directly via tsx, stdio modeThis server cannot be deployed
Maintenance
Related MCP Connectors
MCP server for AI agents to plan, verify, and deploy Cloudflare-native apps.
An MCP memory server. One memory your agents share — across models, devices and apps.
MCP server for building and testing AI agents with multi-model experimentation and insights.
Nifty's MCP server — exposes tasks, projects, messages, and files as tools for AI agents.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceAn MCP server that lets coding agents build and query a persistent knowledge graph of concepts, architecture, and decisions, enabling them to remember across sessions.265 npm545MIT
- AlicenseNot gradedqualityDmaintenanceMCP server that provides persistent memory and contextual awareness to language models, enabling project onboarding, recall of architectural rules, and code consistency across sessions.32MIT
- FlicenseBqualityBmaintenanceMCP server that gives AI coding assistants persistent memory, structural code graph analysis, and safe multi-agent coordination, enabling them to answer architectural questions, track decisions across sessions, and coordinate safely in multi-agent workflows.394-
- AlicenseNot gradedqualityCmaintenanceAn MCP server that gives AI coding agents structured access to a project's architecture, rules, modules, and technical decisions.MIT