ProjectBrain
Local MCP server providing project cognition capabilities for AI coding agents, including context packs, impact analysis, and git diff review through stdio communication.
README
ProjectBrain
ProjectBrain is a local project cognition layer for AI coding agents.
It turns code-structure facts and human project experience into task-scoped artifacts that an AI agent can use before changing code:
- Context Pack: the files, symbols, flows, risks, and human notes relevant to a task.
- Impact Analysis: the files, symbols, callers, dependencies, tests, and review risks likely affected by a change.
- Git Diff Impact: a local review of staged, branch, or last-commit changes based on changed file names from Git.
ProjectBrain is not a code search UI, a generic RAG chatbot, or an automatic code modifier. The first public version is a small local prototype that is useful for experimenting with project memory and impact analysis workflows.
Status
Prototype / local MVP.
Current capabilities:
- CodeGraph SQLite adapter.
- ProjectBrain JSON schema models and validation.
- Context Pack builder.
- Impact Analysis builder.
- Git diff Impact Analysis from local Git changed files.
- Agent-friendly compact output for Context Pack and Impact Analysis.
- Local experience claim authoring.
- JSON-file local runtime.
- Local-only stdio MCP server.
- Optional FastAPI API skeleton.
- Synthetic public demo under
examples/payment-mini/.
Quickstart
Install with Homebrew:
brew tap yinshaojun001/projectbrain https://github.com/yinshaojun001/projectbrain
brew trust yinshaojun001/projectbrain
brew install projectbrain
projectbrain doctor
For local formula testing from a checkout:
brew tap yinshaojun001/projectbrain /path/to/projectbrain
brew trust yinshaojun001/projectbrain
brew install --build-from-source projectbrain
projectbrain doctor
Or install from source:
python3 -m venv .venv
.venv/bin/python -m pip install -e .
.venv/bin/projectbrain doctor
Run the tests:
python3 -m unittest discover -s tests
Generate a Context Pack from the synthetic public demo:
.venv/bin/projectbrain facts context \
--export-json examples/payment-mini/projectbrain-codegraph-export.json \
--experience-seed examples/payment-mini/experience-seed.md \
--task "Explain the settlement entrypoint"
Generate an Impact Analysis:
.venv/bin/projectbrain facts impact \
--export-json examples/payment-mini/projectbrain-codegraph-export.json \
--experience-seed examples/payment-mini/experience-seed.md \
--task "Change the settlement contract" \
--changed-file contract/src/main/java/example/payment/settlement/SettlementService.java
See Quickstart for a fuller walkthrough. A Chinese walkthrough is available at 中文快速上手.
Use With Your Own Repository
One command sets up a local repository for agent use:
projectbrain --store-root ~/.projectbrain-work setup /path/to/my/project \
--id my_project
setup runs CodeGraph init/index, imports ProjectBrain facts, runs a Context Pack smoke test, detects local agents, and prompts you to install the MCP server into supported agents such as Codex CLI, Claude Code, Cursor, and Trae. It also prints an MCP config for manual setup:
projectbrain --store-root /absolute/path/to/.projectbrain-work mcp serve
Ask the agent to call projectbrain_context_pack before editing and projectbrain_review_git_diff after editing, both with output_format: "agent".
For non-interactive setup, pass one or more agents:
projectbrain --store-root ~/.projectbrain-work setup /path/to/my/project \
--id my_project \
--agent codex
For manual or advanced setup, ProjectBrain expects CodeGraph facts at:
<your-project>/.codegraph/codegraph.db
Import a local project into the JSON runtime:
.venv/bin/projectbrain import /path/to/my/project \
--id my_project \
--name "My Project" \
--path-prefix src/ \
--kind class \
--kind interface \
--kind method
If installed with Homebrew, run the same commands from any directory without the .venv/bin/ prefix:
projectbrain --store-root ~/.projectbrain-work import /path/to/my/project \
--id my_project \
--path-prefix src/ \
--kind class \
--kind interface \
--kind method
projectbrain --store-root ~/.projectbrain-work context my_project "Explain the checkout flow" --format agent
Then generate artifacts from the stored facts:
.venv/bin/projectbrain context my_project "Explain the checkout flow"
.venv/bin/projectbrain impact my_project "Change checkout validation" \
--changed-file src/checkout/CheckoutService.java
.venv/bin/projectbrain impact-diff my_project "Review staged checkout changes" --staged
.venv/bin/projectbrain impact-diff my_project "Review branch impact" --from main --to HEAD
Use compact output when an AI coding agent needs the next actions without the full artifact:
.venv/bin/projectbrain context my_project "Explain the checkout flow" --format agent
.venv/bin/projectbrain impact-diff my_project "Review staged checkout changes" --staged --format agent
Add local project experience so future context and impact results include human constraints:
.venv/bin/projectbrain claim add my_project \
--id exp_checkout_validation \
--applies-to checkout \
--risk high \
--review-state approved \
--claim-type HUMAN_CONFIRMED \
--statement "Checkout validation changes require compatibility review."
Review and archive local claims without deleting their history:
.venv/bin/projectbrain claim list my_project
.venv/bin/projectbrain claim review my_project exp_checkout_validation \
--review-state needs_review \
--risk medium
.venv/bin/projectbrain claim archive my_project exp_checkout_validation \
--reason "Superseded by newer checkout guidance."
Runtime artifacts are written under .projectbrain/, which is ignored by Git.
Optional FastAPI Server
python3 -m venv .venv
.venv/bin/python -m pip install -e '.[api]'
PYTHONPATH=apps/api:packages/adapters:packages/runtime:packages/schema \
.venv/bin/uvicorn projectbrain_api.main:app --reload
Routes:
GET /health
POST /api/v1/projects/import
GET /api/v1/projects
POST /api/v1/projects/{project_id}/context-pack
POST /api/v1/projects/{project_id}/impact-analysis
Local MCP Server
ProjectBrain can run as a local stdio MCP server for AI coding agents:
.venv/bin/projectbrain --store-root /absolute/path/to/.projectbrain mcp serve
It is a local child process. It does not open network sockets or upload source code. See Local MCP Usage.
MCP tools include project import, project listing, experience claim authoring, Context Packs, Impact Analysis, and Git diff review through projectbrain_review_git_diff. The read tools accept output_format: "agent" for compact agent-oriented results.
Privacy note: ProjectBrain controls the tool side, not the AI client side. MCP results may contain file paths, symbol names, and inferred risk notes. Whether those results are sent to a model provider depends on your AI client and model settings. For strict private-code environments, use a local model or an approved enterprise endpoint.
For additional local output controls, add .projectbrain-policy.json or .projectbrain-policy.yml to the imported project root:
{
"deny_paths": ["private/**", "src/main/resources/config/**"],
"output_limits": {
"max_items_per_section": 8,
"max_recommended_files": 8,
"max_recommended_tests": 5
},
"include_source_snippets": false
}
Context Pack, Impact Analysis, Git diff review, API, and MCP read outputs apply the policy. Source snippets remain disabled by default.
Inspect the policy that an imported project is using:
.venv/bin/projectbrain policy inspect my_project
Repository Layout
apps/
tools/ CLI tools
api/projectbrain_api/ optional FastAPI API
packages/
adapters/ CodeGraph adapter and artifact builders
runtime/ local JSON runtime and repository abstraction
schema/ dataclass schemas and validation
examples/payment-mini/ synthetic public demo data
tests/ unit and API tests
docs/ design and implementation notes
Public Data Boundary
This repository intentionally does not include real project source code, real CodeGraph databases, private configs, or production runtime stores.
The public demo is synthetic. If you use ProjectBrain on a private repository, keep these paths out of Git:
docs/payment/.projectbrain/.codegraph/generated from private code- private experience seeds
- private exported facts
Design Docs
| Document | Purpose |
|---|---|
| Design Document | Product positioning, architecture, components, APIs, and roadmap. |
| Domain Model | Project cognition domain model and bounded contexts. |
| Knowledge Schema | Knowledge graph, source refs, claims, confidence, and lifecycle. |
| MVP Architecture | Local MVP architecture, service boundaries, storage, and acceptance criteria. |
| Implementation Plan | Engineering phases, tests, operations, and open-source setup. |
| Agent Skills | Agent-facing skills for project understanding and impact analysis. |
| API Contract | REST and MCP contract draft. |
| CodeGraph Integration | CodeGraph as the first code-fact provider. |
| Local Runtime | CLI/runtime/API usage for the current local prototype. |
| MCP Usage | Local-only stdio MCP server usage and privacy boundary. |
| v0.2 Release Readiness | Release gate checks for tests, CLI/MCP smoke, policy, and privacy boundary. |
| 中文快速上手 | Chinese quickstart for local install, demo, MCP, claims, and privacy policy. |
| Delivery Gap Analysis | Remaining gaps between design and implementation. |
| Evaluation Plan | How to evaluate context quality, impact quality, and agent outcomes. |
Roadmap
- Add typed API request/response models.
- Add OpenAPI snapshot tests.
- Add richer Git diff symbol matching.
- Add richer agent output controls.
- Add project experience review and stale-claim workflow.
- Add database-backed repository implementation.
- Add more language adapters and richer source-fact extraction.
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。