Skip to main content

ProjectBrain (projectbrain-mcp)

Local-first AST Context Compiler, Closed-World Dossier, and Surgical Anchor Patch Engine for AI Coding Agents.

ProjectBrain indexes your codebase into a typed AST & call-graph (file, fn, cls, route, mod) in ~90ms and cuts coding-agent token bills by 60%–65% while speeding up multi-file debugging by 30%–42%:

  • Input Token Reduction (-81.3% to -88.3% code tokens, -73.2% to -76.3% billed prompt tokens): Compiles module constants, smart-folded AST function slices, 1–3 hop bidirectional call chains with @L<line> caller windows, and a Closed-World Exhaustive Repo Scan into a single <800-line .projectbrain_dossier.md read in 1 read_file call.
  • Output Token Reduction (-63.2% to -77.3% edit output tokens): Replaces verbatim Target + Replacement repetition (edit_file) with a compact Anchor Patch DSL (@file, @sub, @replace, @insert_after, @delete) validated by Tree-sitter in <5ms.
  • Live ROI & Savings Ledger (projectbrain stats): Tracks cumulative input/output tokens saved, file reads avoided, estimated USD saved, and developer wait-time saved in .projectbrain_ledger.json.

Quick Start (60 Seconds)

pip install projectbrain-mcp
projectbrain --path /path/to/repo init

Or run as a zero-install MCP server via uvx:

{
  "mcpServers": {
    "projectbrain": {
      "command": "uvx",
      "args": ["projectbrain-mcp"]
    }
  }
}

projectbrain init indexes the repository, updates .gitignore, writes .mcp.json (for Claude Code, Cursor, Windsurf, Antigravity), and creates .agents/rules/projectbrain.md so agents automatically use brain_dossier and brain_patch.


Verified A/B Benchmark Results (142-File Production Repo)

Benchmark Scenario Metric Baseline Agent (No Brain) ProjectBrain Agent Improvement
Scenario 1: Targeted 3-Part Engineering Analysis Code Output Ingested 67,319 tok 12,569 tok -81.3% (5.35x smaller)
Total Prompt Tokens Billed 655,391 tok 155,052 tok -76.3% (4.23x fewer)
File Reads (read_file) 16 2 -87.5%
Net API Cost $0.6723 $0.2590 -61.5% (2.60x cheaper)
Scenario 2: Unseen Open-Ended Bug Report (Zero Identifiers) Code Output Ingested 351,658 tok (1.40M chars) 40,982 tok (163.9k chars) -88.3% (8.58x smaller)
Total Prompt Tokens Billed 4,561,692 tok 1,220,579 tok -73.2% (-3.34M tokens)
File Reads (read_file) 84 (19 re-reads) 6 (0 re-reads) -92.9% (14.0x fewer reads)
Multi-File Patch Output Tokens 3,359 tok (edit_file) 529 – 1,237 tok -63.2% to -77.3% edit output
Net API Cost $3.2712 $1.1557 -64.7% (2.83x cheaper)

CLI Reference

# 1. One-command repo initialization (index + .gitignore + .mcp.json + agent rules)
projectbrain --path <repo> init

# 2. Compile a single-read (<800-line) Engineering Dossier (.projectbrain_dossier.md)
projectbrain --path <repo> dossier "<question_or_bug_1>" "<question_or_bug_2>"

# 3. Apply or dry-run a Surgical Anchor Patch spec (.projectbrain_patch.diff)
projectbrain --path <repo> patch --spec "@file src/App.tsx
@sub L84 \`!profileCompleted\` -> \`isHydrated && !profileCompleted\`" [--apply]

# 4. View Live ROI & Token Savings Dashboard
projectbrain --path <repo> stats --summary

# 5. Additional granular tools
projectbrain --path <repo> slice --summary <file:symbol_or_start-end>
projectbrain --path <repo> compile "<task>" --summary
projectbrain --path <repo> explore <symbol_or_route> [target_b]
projectbrain --path <repo> impact <file1> [file2 ...]
projectbrain --path <repo> remember <symbol_or_file> "<architectural_note>"

MCP Server (projectbrain-mcp)

Exposes native MCP tools for Claude Code, Cursor, Windsurf, and Antigravity:

  • brain_dossier(tasks, impact_files=None, repo_path=None) — Compiles <800-line .projectbrain_dossier.md with module globals, folded AST slices, call chains, and Closed-World Exhaustive Repo Scan.
  • brain_patch(spec, apply=False, repo_path=None) — Executes or dry-runs Anchor Patch DSL (@file, @sub L<n>|*|ALL|<symbol>, @replace, @insert_after, @delete) with Tree-sitter syntax verification.
  • brain_stats(repo_path=None, reset=False) — Returns cumulative token, dollar, and time savings from .projectbrain_ledger.json.
  • brain_slice, brain_context, brain_explore, brain_check, brain_remember.

Metadata

Release files for projectbrain-mcp 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for projectbrain-mcp 0.2.0
File Size Uploaded Provenance
projectbrain_mcp-0.2.0.tar.gz 98.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for projectbrain-mcp 0.2.0
File Interpreter ABI Platform
projectbrain_mcp-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 181.6 kB

Release files / projectbrain_mcp-0.2.0.tar.gz

Download URL projectbrain_mcp-0.2.0.tar.gz
Size 98.2 kB
Tags Source
SHA-256 checksum
How to use checksums
841d6627c8416c97e96bf8e810b2e0b7a9ff5ff1e1f3f7ad1c7f11848020c6c0
BLAKE2b-256 checksum
How to use checksums
ae4a241b5b048a03cd465bfc53ff247a7559e380464b231ad91cfc96f78b3235
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Release files / projectbrain_mcp-0.2.0-py3-none-any.whl

Download URL projectbrain_mcp-0.2.0-py3-none-any.whl
Size 83.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
18dc1ff16f1a8966e96ad34449f743f38093d01191bfb090c2cf8c0fb3efd224
BLAKE2b-256 checksum
How to use checksums
010d7f99f33fed8d83fa4fa621f8888ab54805db09b22ab70e58df641f0644fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Security for projectbrain-mcp 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page