ProjectBrain (projectbrain-mcp v0.8.5)

For a real bug or refactor, ProjectBrain gives your coding agent the exact symbols, callers, and dependencies it needs in 1 turn—with fewer wrong files and 77–89% fewer tokens.
Instead of forcing AI coding agents to explore repositories by running dozens of rg/grep searches and reading entire files line-by-line, ProjectBrain indexes your codebase locally into a SQLite WAL Code Graph (.projectbrain.db) using tree-sitter and structural parsers. No external database daemon, no Docker, no cloud vector embeddings, and no API keys required.
What It Actually Does
- One-Turn Code Dossiers (
projectbrain dossier/brain_dossier):- Given a bug report, stack trace, or feature prompt, ProjectBrain ranks relevant symbols using sub-identifier BM25 + call/import/state-flow graph traversal, automatically bridges passive schema/DTO and class/module config declarations (
ConfigAttribute,ImmutableDict,SCREAMING_SNAKE_CASEconstants) to their executable consumers, and returns exact code slices plus 1-hop caller/callee signatures in a single read.
- Given a bug report, stack trace, or feature prompt, ProjectBrain ranks relevant symbols using sub-identifier BM25 + call/import/state-flow graph traversal, automatically bridges passive schema/DTO and class/module config declarations (
- Multi-Dimensional Program Slicing (
projectbrain slice/brain_slice):- Slices exact functions, classes, methods, or line ranges (
file.py:ClassName.methodorfile.py:120-160) across multiple files in a single call. When slicing large functions around a target variable or call, computes an AST/PDG slice across three orthogonal dimensions: backward data-dependence (def -> use), forward data-dependence (def -> use), and upward control-dependence guards (if/try/for/with), collapsing unrelated filler lines while preserving governing logic.
- Slices exact functions, classes, methods, or line ranges (
- AST Symbol-Anchored Patching (
projectbrain patch/brain_patch):- Applies surgical edits (
@replace_body <Symbol>,@add_method <ClassName>,@replace <Symbol>,@sub L<n>) validated against Tree-sitter + language syntax compilers and caller arity contracts before touching disk, with automatic rollback on syntax errors.
- Applies surgical edits (
.gitignore-Compliant Polyglot Indexing (29 File Extensions):- Honors root and nested
.gitignore/.git/info/excluderules automatically. - Supports Python, TypeScript, JavaScript, JSX/TSX, Vue, Svelte, Go, Rust, Java, Kotlin, Scala, C, C++, C#, Ruby, PHP, Swift, SQL, GraphQL, Prisma, and Protobuf.
- Honors root and nested
- Safe Output & Traceback Compression (
projectbrain run/brain_run):- Folds passing test noise (
pytest,jest/vitest,go test,cargo test), deduplicates repetitive log lines, and maps stack-tracefile:lineframes directly to enclosing functions and 1-hop callers. Direct shell execution over MCP is disabled by default unless explicitly opted in viaPROJECTBRAIN_ALLOW_EXEC=1.
- Folds passing test noise (
Quick Start (60 Seconds)
Step 1: Install
pip install projectbrain-mcp
(Or pipx install projectbrain-mcp / uv tool install projectbrain-mcp.)
Step 2: Initialize Your Repository (Non-Destructive)
projectbrain --path /path/to/your/repo init --hooks
What projectbrain init does safely (--ide auto by default):
- Builds the SQLite Code Graph Index: Writes
.projectbrain.db(WAL mode), honoring.gitignore. - Updates
.gitignore: Appends ephemeral.projectbrain*cache patterns if not already present. - Writes Minimal Root Config by Default (
--ide auto): Creates.mcp.jsonandAGENTS.mdat the repo root, and only touches.cursor/,.vscode/, or.claude/if those IDE directories already exist in your repo (pass--ide allto generate configs for all IDEs). - Appends Agent Rules Non-Destructively: Uses
<!-- projectbrain:start --> ... <!-- projectbrain:end -->section markers inAGENTS.md,CLAUDE.md,.cursor/rules/projectbrain.mdc, and deep-merges.claude/settings.local.jsonPreToolUsehooks so existing team instructions and settings are never overwritten.
Step 3: MCP Server Configuration
{
"mcpServers": {
"projectbrain": {
"command": "projectbrain-mcp",
"args": ["--lean", "/path/to/your/repo"]
}
}
}
Core CLI Workflow
# 1. Compile a 1-turn engineering dossier (target slices + callers + callees)
projectbrain --path /path/to/repo dossier "recover from a panic in an HTTP handler and abort with 500"
# 2. Slice multiple symbols or line ranges in one batch
projectbrain --path /path/to/repo slice src/App.tsx:ProtectedRoute recovery.go:CustomRecoveryWithWriter
# 3. Apply a syntax-verified, symbol-anchored patch
projectbrain --path /path/to/repo patch --apply --spec-file patch.spec
# 4. Verify closed-world structural claims (calls, reaches, imports, handles)
projectbrain --path /path/to/repo verify "checkout" reaches "validate_coupon"
Reproducible Evaluation Suite (eval/)
Every retrieval, multi-hop graph traversal, closed-world claim verification, and scale benchmark in this repository can be reproduced locally with two commands:
# 1. Run retrieval precision/recall, multi-hop graph vs. grep baseline, claim verification, and zero-ID slicing
python eval/run_eval.py
# 2. Run 200-file polyglot scale, incremental Salsa early-cutoff, FTS5, and recursive CTE latency benchmark
python eval/bench_scale.py
1. Built-In Reproducible Harness Results (python eval/run_eval.py)
| Benchmark Suite | Metric | Score | Notes |
|---|---|---|---|
File Localization (eval/tasks.json) |
Precision / Recall (10 tasks) | 100% Precision / 100% Recall |
Returns exact 1-file answers for 1-file tasks and 3-file answers for 3-file flows |
Multi-Hop Graph vs. Grep (eval/relationship_tasks.json) |
Pass Rate (8 tasks, incl. negative controls) | 8 / 8 (100%) |
Finds 2-hop call paths where naive grep misses the intermediate module |
Closed-World Claim Verification (eval/claim_tasks.json) |
Exact Verdict Accuracy (22 tasks) | 22 / 22 (100%) |
0 false supports, 0 false refutations; returns UNKNOWN on syntax-broken files |
| Self-Dogfooding Context Slicing | Symbol Recall & Token Reduction | 3 / 3 (100% Recall) |
96.6%–99.2% token reduction vs. reading matched full files |
| Adversarial Zero-Identifier Slicing | Symbol Recall (prompts with zero symbol names) | 4 / 4 (100% Recall) |
Outperforms grep + 120-line windows (0%–50% recall on 3 of 4 tasks) |
2. Blind Cold-Start Agent Benchmarks (Production Open-Source Repositories)
Measured head-to-head by spawning two isolated subagents simultaneously on unmodified open-source repositories (Naive Search Agent using rg/Select-String + read_file vs. ProjectBrain Agent starting completely cold with no pre-built .projectbrain.db index and zero file/symbol hints in the prompt):
A. paperless-ngx/paperless-ngx (4-Question Deep Architectural Audit — Cold Start)
| Metric | Naive Search Agent | ProjectBrain Agent (Cold Start) | Measured Delta |
|---|---|---|---|
| Wall-Clock Time | 12m 00s (720.0s) |
6m 27s (387.0s) |
5m 33s faster (-46.3% / 1.86x faster) |
| Model Turns | 53 turns |
15 turns |
38 fewer turns (-71.7% / 3.53x fewer) |
| Tool Calls | 51 calls |
18 calls (1 dossier + 12 reads + 5 batched slices) |
33 fewer calls (-64.7% / 2.83x fewer) |
| Uncached Input Tokens | 274,363 tokens |
216,603 tokens |
57,760 tokens saved (-21.1%) |
| Cumulative Billed Input Tokens | 6,506,996 tokens |
1,499,886 tokens |
5,007,110 tokens saved (-76.9% / 4.34x less) |
B. Netflix/dispatch (879-File Repository — 3-Question Cold-Start Trace)
| Metric | Naive Search Agent | ProjectBrain Agent (Cold Start) | Measured Delta |
|---|---|---|---|
| Wall-Clock Time | 5m 52s (352.0s) |
3m 44s (224.0s) |
2m 08s faster (-36.4% / 1.57x faster) |
| Model Turns | 16 turns |
8 turns |
8 fewer turns (-50.0% / 2.0x fewer) |
| Tool Calls | 41 calls (14 shell + 27 reads) |
5 calls (1 dossier + 1 read + 3 slices) |
36 fewer calls (-87.8% / 8.2x fewer) |
| Cumulative Billed Input Tokens | 2,139,562 tokens |
224,407 tokens |
1,915,155 tokens saved (-89.5% / 9.53x less) |
Project Layout
projectbrain/
├── src/projectbrain/
│ ├── brain.py # Context Compiler, Dossier Engine, Slicer, Explorer & Contract Verifier
│ ├── store.py # SQLite WAL Property Graph (.projectbrain.db), FTS5, and Delta Overlay
│ ├── slicer.py # Statement/Symbol Slicer, Focus-Window Folding & Signature Skeletons
│ ├── patcher.py # AST Symbol-Anchored & Line-Anchored Patch Engine + Syntax Verification
│ ├── parsers.py # Tree-sitter & Structural Parsers (29 file extensions)
│ ├── graph.py # Cross-File Call/Import Graph & Personalized PageRank Push
│ ├── ledger.py # Session Token & ROI Telemetry Ledger
│ ├── memory.py # AST-Anchored Repository Notes (.projectbrain_memory.json)
│ ├── resolve.py # Cross-File Import & TypeScript Path Alias Resolution
│ ├── frameworks.py # Route Inference (Next.js, FastAPI, Flask, Express, Hono, Gin, Actix, Spring, ASP.NET)
│ ├── cli.py # CLI Entry Point (init, dossier, slice, patch, verify, run, stats)
│ └── server.py # FastMCP Server Entry Point (standard and --lean modes)
├── tests/ # 194 Unit, Integration, Security, and Benchmark Threshold Tests
└── eval/ # Reproducible Evaluation & Scale Benchmark Harnesses
Metadata
Release files for projectbrain-mcp 0.8.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| projectbrain_mcp-0.8.5.tar.gz | 209.8 kB | Without provenance | Details for projectbrain_mcp-0.8.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| projectbrain_mcp-0.8.5-py3-none-any.whl | Python 3 | none | any | Details for projectbrain_mcp-0.8.5-py3-none-any.whl |
Total release size: 382.1 kB
Release files / projectbrain_mcp-0.8.5.tar.gz
| Download URL | projectbrain_mcp-0.8.5.tar.gz |
|---|---|
| Size | 209.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
042e81608c919d2ea2f89d87c676d5514af722986aa0852701c23cd999267058
|
|
BLAKE2b-256 checksum How to use checksums |
8aaadc8c64eaa3350edf02a7648c46aded2602ed2bca8a08f7952deabc575f63
|
| 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.8.5-py3-none-any.whl
| Download URL | projectbrain_mcp-0.8.5-py3-none-any.whl |
|---|---|
| Size | 172.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
65f2dce2f329c6f4b87ad33418fbfb91ef9519c284840b22dd5a8f1f05528928
|
|
BLAKE2b-256 checksum How to use checksums |
5f276071ffc522e7c9854b60e7b9946afd2c3cd95539c0ff2b488ec545b7e712
|
| 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.8.5
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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.