ProjectBrain (projectbrain-mcp v0.8.0)
Local-First 6D AST Coordinate Matrix, Pure SQLite Graph-as-Storage (.projectbrain.db), Polyglot Context Compiler, and Symbol-Anchored Patch Engine for AI Coding Agents.
Instead of forcing LLMs to search repositories as flat 1D text files (running rg/grep and reading dozens of overlapping read_file windows), ProjectBrain indexes your codebase across Python, TypeScript/JavaScript/React, Go, Rust, Java, and SQL into a 6D AST Coordinate Matrix and a Pure SQLite WAL Property Graph (.projectbrain.db) using pre-compiled tree-sitter C wheels—no external database daemon, no Docker, no cloud vector embeddings, and no API keys required:
- 6D AST Coordinate Matrix (
X × Y × Z × W × E/T × C): Decomposes files and monolith components into atomic AST cells indexed across six orthogonal dimensions:D1: X_scope(Lexical / Structural Scope): Outer function, class/struct/trait,switch/casebranch,if/elifguard,useEffect[deps], or JSX conditional block.D2: Y_role& Layer (D3): Behavioral role (STATE,EFFECT,ACTION,IO,VIEW,SCHEMA) and architectural layer (PRODUCTIONvs. co-locatedTEST_SUITE).D3: Z_write/Z_read(State & Storage Channels): Directional dataflow tracking which state variables, object attributes, and storage/DB keys each block mutates vs. reads.D4: W_calls(Dyck-Constrained Call Graph): Outgoing function/method calls, HTTP route-to-handler bindings, and 1–3 hop interprocedural effect bubbling.D5: E_exit&T_mode(Exception & Temporal Control-Flow): Tracksraise/throw/catch/HTTP status exits (4xx/5xx) and execution mode (SYNC|ASYNC|REACTIVE|TIMER).D6: C_contract(Cross-Boundary Contract Verifier): Pre-commit verification of caller-callee arity & keyword obligations ([6D Caller Arity Contract Violation]), route/client payload keys, SQLNOT NULLschema constraints, and dialect mismatches.
- Pure SQLite WAL Graph-as-Storage (
.projectbrain.db):- Stores vertices (
graph_nodes WITHOUT ROWID), forward/reverse B-Tree adjacency lists (edges WITHOUT ROWID), sub-token BM25 inverted indices (fts_symbolsFTS5), and content-addressed source code (source_blobs WITHOUT ROWID) in a single ACID database file. - Includes
WITH RECURSIVECTE multi-hop reachability in<6ms, Salsa-styleinterface_hashearly-cutoff on body-only edits, and an in-memory Stacked Delta Overlay (temp.unified_symbols) for zero-disk dry-run verification.
- Stores vertices (
- Single-Read Surgical Dossier & Context Compiler (
projectbrain dossier/brain_context):- Uses Dyck-Constrained Sublinear ACL Push (PPR) + Submodular Concept-Coverage Selection to return exact target slices (with reversible
-> expand: brain_slice <file>:<s-e>fold handles), 1-hop callee signature skeletons, Stack-Trace Crash Frame Pinning, and Greenfield Structural Sibling Exemplars.
- Uses Dyck-Constrained Sublinear ACL Push (PPR) + Submodular Concept-Coverage Selection to return exact target slices (with reversible
- AST Symbol-Anchored Patch Engine (
projectbrain patch/brain_patch):- Supports both line-anchored (
@sub,@replace L<s-e>,@insert_after,@delete) and AST symbol-anchored (@replace_body <Symbol>,@add_method <ClassName>,@replace <Symbol>) directives with±5line drift auto-healing, lazy-elision rejection, dual Tree-sitter + Pythoncompile()validation, and pre-commit caller arity checks.
- Supports both line-anchored (
Step-by-Step Setup Guide (60 Seconds)
Step 1: Install from PyPI
pip install projectbrain-mcp
(Alternatively, use pipx install projectbrain-mcp or uv tool install projectbrain-mcp.)
Verify both the CLI and MCP server binaries are available:
projectbrain --help
projectbrain-mcp --help
Step 2: Initialize Your Repository (One Command)
Run projectbrain init --hooks inside any repository (or pass --path and optional --ide {all,antigravity,claude,cursor,vscode}):
projectbrain --path /path/to/your/repo init --hooks
What projectbrain init --hooks does automatically:
- Builds the Pure SQLite Graph-as-Storage Index: Writes
.projectbrain.db(WAL mode). - Updates
.gitignore: Ensures ephemeral index, dossier, and diff files stay out of Git. - Configures MCP Across IDEs: Writes/merges
.mcp.json(Claude Code / Antigravity),.cursor/mcp.json(Cursor), and.vscode/mcp.json(VS Code Agent Mode). - Installs Agent Rules & PreToolUse Hooks: Writes
AGENTS.md,CLAUDE.md,.cursor/rules/projectbrain.mdc, and.claude/settings.local.jsonPreToolUseguards.
Step 3: MCP Server Configuration (Standard or Lean 5-Tool Mode)
Add projectbrain-mcp to your MCP configuration (pass --lean or set PROJECTBRAIN_LEAN_MCP=1 to expose only the 6 core high-leverage tools and save ~2,900 tokens of tool-schema overhead):
{
"mcpServers": {
"projectbrain": {
"command": "projectbrain-mcp",
"args": ["--lean", "/path/to/your/repo"]
}
}
}
Or run directly with uvx:
{
"mcpServers": {
"projectbrain": {
"command": "uvx",
"args": ["projectbrain-mcp", "--lean", "/path/to/your/repo"]
}
}
}
(Every MCP tool also accepts an optional repo_path argument per call for multi-repo workspaces.)
Daily CLI Workflow & Commands
1. Compile a Single-Read Engineering Dossier (dossier / dossier --zoom)
projectbrain --path /path/to/repo dossier "recover from a panic in an HTTP handler and abort with 500"
projectbrain --path /path/to/repo dossier --zoom "how does JWT signature and exp claim verification work"
2. Surgically Slice Symbols or Line Ranges (slice)
projectbrain --path /path/to/repo slice --summary src/App.tsx:ProtectedRoute recovery.go:CustomRecoveryWithWriter
3. Apply AST Symbol-Anchored or Line-Anchored Patches (patch)
# AST Symbol-Anchored replacement (immune to line-number drift!)
projectbrain --path /path/to/repo patch --apply --spec "@file recovery.go
@replace_body Recovery
return RecoveryWithWriter(DefaultErrorWriter)
@end"
# Intra-line substitution
projectbrain --path /path/to/repo patch --apply --spec "@file src/App.tsx
@sub L84 \`!profileCompleted\` -> \`isHydrated && !profileCompleted\`"
4. View Live ROI & Token Savings Dashboard (stats)
projectbrain --path /path/to/repo stats --summary
Blind Open-Source Repository Evaluation (v0.8.0)
Evaluated zero-shot across 4 unseen open-source production repositories spanning Python, TypeScript/JSX, and Go (encode/httpx, pallets/flask, honojs/hono, gin-gonic/gin — 670 files, 6,713 functions, 656 classes/structs, 5,074 6D cells, 12,046 graph nodes, and 35,627 edges) using natural-language prompts with zero function/method identifiers:
| Repository | Language | Files | Functions | Graph Edges | Parse Health (ok/partial/unsupported) |
Warm SQLite Load | Salsa No-Op Check |
|---|---|---|---|---|---|---|---|
encode/httpx |
Python | 60 | 1,134 | 5,558 | 60 / 0 / 0 (100%) |
136.8 ms |
10.8 ms |
pallets/flask |
Python | 85 | 1,462 | 6,646 | 85 / 0 / 0 (100%) |
160.7 ms |
23.4 ms |
honojs/hono |
TypeScript / JSX | 426 | 2,775 | 15,258 | 418 / 8 / 0 (98.1%) |
318.3 ms |
78.7 ms |
gin-gonic/gin |
Go | 99 | 1,342 | 8,165 | 99 / 0 / 0 (100%) |
179.8 ms |
10.8 ms |
- Zero-Identifier Symbol Slice Recall (
compile_context@2,500token budget):12 / 12 (100.0%) - Top-5 File Localization Accuracy (
file_acc_at_5):12 / 12 (100.0%)(11 / 12Top-1) - AST Symbol-Anchored Patch Verification (
@replace_body/@sub):4 / 4 (100.0%) - Token Compression vs. Matched File Reads: 80% – 91% reduction (
4.2x – 6.0xfewer tokens vs.grep+ 80-line window baseline)
Project Layout
projectbrain/
├── src/projectbrain/
│ ├── brain.py # 6D Context Compiler, Dossier Engine, Slicer, Explorer & Contract Verifier
│ ├── store.py # Pure SQLite WAL Graph-as-Storage (graph_nodes, edges WITHOUT ROWID, FTS5, source_blobs, Delta Overlay)
│ ├── slicer.py # 6D Coordinate Matrix extractor, smart focus-window folding & signature skeletons
│ ├── patcher.py # Two-Phase AST Symbol-Anchored & Line-Anchored Patch Engine + syntax/contract gates
│ ├── parsers.py # Polyglot Tree-sitter CST codecs (Python, JS/TS/JSX/TSX, Go, Rust, Java, SQL)
│ ├── graph.py # Multiplex CodeGraph, Dyck-Constrained Sublinear ACL Push (PPR) & Hub Damping
│ ├── ledger.py # Page-accurate ROI & Token Savings Ledger (.projectbrain_ledger.json)
│ ├── memory.py # Persistent AST-anchored repo memory (.projectbrain_memory.json)
│ ├── resolve.py # Cross-file import & TypeScript path alias resolution
│ ├── frameworks.py # Next.js, FastAPI, Flask, Express, Hono, Gin, Actix, Axum & Spring route inference
│ ├── cli.py # CLI entry point (init --hooks, dossier, patch, slice, stats, compile, explore)
│ └── server.py # FastMCP server entry point (standard 22-tool and --lean 6-tool modes)
├── tests/ # 192 unit, integration, security, and benchmark threshold tests
└── eval/ # Polyglot scale benchmark, self-dogfooding & zero-identifier adversarial harness
Metadata
Release files for projectbrain-mcp 0.8.1
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.1.tar.gz | 193.8 kB | Without provenance | Details for projectbrain_mcp-0.8.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| projectbrain_mcp-0.8.1-py3-none-any.whl | Python 3 | none | any | Details for projectbrain_mcp-0.8.1-py3-none-any.whl |
Total release size: 353.2 kB
Release files / projectbrain_mcp-0.8.1.tar.gz
| Download URL | projectbrain_mcp-0.8.1.tar.gz |
|---|---|
| Size | 193.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
41ca753c26efa3a613aa369ff1655ad088251c2f5fa73a28b289bcdf1c242f2e
|
|
BLAKE2b-256 checksum How to use checksums |
f7cc0d2f3f65ec6da341cc02b6116493a5da151779955a286661b056780e3ff9
|
| 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.1-py3-none-any.whl
| Download URL | projectbrain_mcp-0.8.1-py3-none-any.whl |
|---|---|
| Size | 159.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5be85c4610a0d0d38c815a7f28dbf42880b777ebad11d9f71054547f5b5cd71a
|
|
BLAKE2b-256 checksum How to use checksums |
f1be470ca9360d8fcef12ff108e20304ffd3fb76f3fb1fc9b9603d1368d45983
|
| 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.1
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.