jogakbo

brainforge-mcp

Community jogakbo
Updated

brainforge-mcp

PyPI Python License: MIT

Turn your markdown notes into an AI-powered knowledge graph.

brainforge-mcp is an MCP server that reads a folder of markdown notes (an Obsidian vault or a Karpathy-style LLM wiki), builds a graph from [[wikilinks]] and causal callouts, and lets any MCP client ask where a concept sits, how two ideas connect, and what the wiki is missing. It is read-and-analyze only. Your LLM writes the pages; brainforge reads the structure.

Quick start (30 seconds)

Requires Python 3.10+ and uv.

uvx brainforge-mcp init ~/my-brain      # creates raw/, wiki/, output/ and prints the client config

Add it to your MCP client. Use an absolute path. MCP clients start the server without a shell, so ~ is only expanded by brainforge itself (0.1.1+).

// macOS / Linux
{ "mcpServers": { "brainforge": { "command": "uvx", "args": ["brainforge-mcp", "--vault", "/Users/me/my-brain/wiki"] } } }
// Windows
{ "mcpServers": { "brainforge": { "command": "uvx", "args": ["brainforge-mcp", "--vault", "C:\\Users\\me\\my-brain\\wiki"] } } }

Then ask your assistant: "Give me a graph_summary of my wiki."

Tool Input Returns Writes?
explain_node concept name position (degree percentile), causal role, growth hints no
find_path two concept names shortest path and the nodes in between no
causal_chain concept name upstream / downstream causal relations no
graph_summary — size, density, weak spots, next actions no
search_wiki question ranked reading list (path, score, why) over links, related:, sources: no
read_page path, optional L10-L40 range page text with a source: <path> L<a>-L<b> header to cite no
cite_check path, quote whether the quote is really in the page, and its line range no
lint_wiki — integrity report: frontmatter, broken links, sources, IDs no
suggest_links count source pages not linked to any concept, with candidates no
ingest optional raw file which raw/ files are not ingested yet, with a page-writing guide no
rebuild_graph — re-parses the wiki and saves graph.json yes (graph.json only)

Typical flow: search_wiki → read_page on the top 2–4 paths → answer and cite the source: line → cite_check any sentence you quote. Every tool except rebuild_graph is marked read-only (readOnlyHint). Your LLM writes the pages; brainforge never edits them.

--vault accepts either the wiki/ folder or the vault root created by init. The graph follows wiki edits automatically (0.2+). graph.json is written only by rebuild_graph, next to the wiki/ folder unless you pass --graph. The causal-callout syntax currently uses Korean relation words (see below). English relation words are planned.

Part of Jogakbo, but usable on its own. Issues are welcome in English or Korean.

한국어 소개

Andrej Karpathy's LLM Wiki pattern을 MCP 서버로 구현한 프로젝트입니다. 마크다운 위키를 지식 그래프로 변환하고, 어떤 LLM 클라이언트에서든 탐색·분석할 수 있습니다.

핵심 아이디어

[원본 자료]  →  [AI가 유지하는 위키]  →  [지식 그래프]  →  [LLM이 탐색·분석]
 논문, 기사       sources/                 graph.json       MCP 도구로 질의
 메모, 영상       concepts/                                  인과 관계 추적
                  entities/                                  건강 진단

MCP 도구가 하는 것: 지식 그래프 탐색, 노드 분석, 인과 관계 추적, 위키 건강 진단LLM이 하는 것: 원본 읽기 → 요약 → 위키 페이지 생성 → 위키링크/인과 관계 삽입

즉, brainforge-mcp는 위키의 "눈" 역할이고, LLM은 위키의 "손" 역할입니다.

A-to-Z 예제: 논문 하나에서 지식 그래프까지

Step 0: 설치 + 초기화

uvx brainforge-mcp init ~/my-brain

생성되는 구조:

my-brain/
├── raw/              # 불변 원본 (사용자가 넣는 곳)
│   ├── papers/
│   ├── articles/
│   ├── transcripts/
│   └── notes/
├── wiki/             # AI가 유지하는 위키
│   ├── sources/
│   ├── concepts/
│   ├── entities/
│   ├── syntheses/
│   ├── index.md
│   └── log.md
├── output/           # 블로그, 포트폴리오 등
├── CONTEXT.md        # 나는 누구인가 · 위키 운영 규칙 (ingest 가 읽음)
└── .templates/       # Obsidian Web Clipper 템플릿 (기사·논문·유튜브)

Step 1: MCP 클라이언트에 등록

init 이 마지막에 출력하는 설정 줄을 그대로 붙여 넣으면 됩니다. 경로는 절대 경로로 적으세요. MCP 클라이언트는 셸을 거치지 않고 서버를 띄우므로 ~ 를 풀어 주지 않습니다(0.1.1부터는 brainforge가 직접 풉니다).

Claude Desktop (claude_desktop_config.json), Kiro / Cursor / VS Code (mcp.json) 모두 같은 모양입니다:

{
  "mcpServers": {
    "brainforge": {
      "command": "uvx",
      "args": ["brainforge-mcp", "--vault", "/Users/me/my-brain/wiki"]
    }
  }
}

Windows에서는 "C:\\Users\\me\\my-brain\\wiki" 처럼 역슬래시를 두 번 씁니다. --vault 에는 wiki/ 폴더나 init 으로 만든 볼트 루트(my-brain) 어느 쪽을 줘도 됩니다.

Step 2: 원본 자료 넣기

논문 PDF를 마크다운으로 변환하여 raw/papers/에 저장합니다:

# 예: marker로 PDF → 마크다운 변환
marker_single "lora-paper.pdf" --output_dir ~/my-brain/raw/papers/

또는 웹 기사를 직접 마크다운으로 저장:

<!-- raw/articles/2026-04-17_lora-explained.md -->
---
title: "LoRA 논문 쉽게 설명하기"
source: https://example.com/lora
date: 2026-04-17
type: article
---

# LoRA 논문 쉽게 설명하기
LLM의 가중치를 Freeze하고 저랭크 행렬만 학습하여...

Step 3: LLM에게 인제스트 요청 (LLM이 하는 일)

채팅에서:

"raw/articles/2026-04-17_lora-explained.md를 읽고 위키에 인제스트해줘"

LLM이 원본을 읽고 다음 파일들을 생성합니다:

wiki/sources/lora-explained.md (소스 요약):

---
title: "LoRA 논문 쉽게 설명하기"
created: 2026-04-17
updated: 2026-04-17
tags: [LoRA, Fine-Tuning, PEFT]
sources: [raw/articles/2026-04-17_lora-explained.md]
---

# LoRA 논문 쉽게 설명하기

## Kernel
모델 가중치를 Freeze하고 저랭크 행렬만 학습하여 VRAM 절감.

## 핵심 주장
1. Fully Fine-Tuning 대비 VRAM 대폭 절감
2. 성능은 동등하거나 우수
...

wiki/concepts/lora.md (개념 페이지):

---
title: LoRA (Low-Rank Adaptation)
created: 2026-04-17
updated: 2026-04-17
tags: [개념, Fine-Tuning, PEFT]
sources: [raw/articles/2026-04-17_lora-explained.md]
---

# LoRA (Low-Rank Adaptation)

## Kernel
가중치 행렬 W를 직접 업데이트하지 않고, 저랭크 행렬 LoRA_A·LoRA_B만 학습.

> [!causal] 인과 관계
> [[lora]] →(가능하게 함)→ [[fine-tuning]]의 효율적 수행
> 신뢰도: 높음 | 출처: [[lora-explained]]

## 관련
[[fine-tuning]], [[transformer]], [[quantization]]

Step 4: 그래프 빌드 (MCP 도구)

채팅에서:

"위키 그래프 재빌드해줘"

→ rebuild_graph 도구가 호출되어 wiki/ 마크다운에서 위키링크 + 인과 관계를 파싱하여 graph.json 생성. (0.2부터는 이 단계 없이도 다른 도구가 바뀐 위키를 바로 읽습니다.)

Step 5: 지식 탐색 (MCP 도구)

이제 그래프가 있으므로 탐색이 가능합니다:

"LoRA가 내 위키에서 어떤 위치야?"

→ explain_node("LoRA") 호출:

## LoRA (Low-Rank Adaptation)
카테고리: concepts | 태그: Fine-Tuning, PEFT

### 위치 분석
- 연결도: 9 (상위 26%) → 중간 연결자
- 인과 역할: 기반 기술 — 다른 1개 개념을 가능하게 함

### 인과 요약
- LoRA →(가능하게 함)→ Fine-Tuning의 효율적 수행

### 성장 제안
- 인과 관계 callout 추가 권장 (현재 1개)
"위키 상태 어때?"

→ graph_summary() 호출:

## 위키 건강 리포트

### 규모: 초기 단계
- 실제 페이지: 5개 (concepts 2, sources 1, entities 1)
- 밀도: 2.4 엣지/노드 → 낮은 밀도 — 위키링크 추가 권장

### 약점
- 미해결 노드 3개 (37.5%)
- 인과 비율 5.0% — callout 추가 권장

### 다음 행동
1. 미해결 페이지 생성: transformer(2연결), quantization(1연결)

특징

  • 🔗 위키링크 + 인과 관계 기반 지식 그래프 자동 빌드
  • 🧠 의미 해석 — "연결 9개"가 아닌 "상위 26% 중간 연결자" 같은 맥락 분석
  • 📊 건강 진단 — 위키의 강점/약점/다음 행동을 구체적으로 제안
  • ⚡ 인과 체인 추적 — 개념 간 "왜" 연결을 상류/하류로 분석
  • 🔌 MCP 표준 — Claude Desktop, Cursor, Kiro, VS Code 등 어디서든 동작

도구 목록

도구 입력 돌려주는 것 쓰기
explain_node 개념 이름 노드 프로파일 — 위치 분석, 인과 역할, 성장 제안 없음
find_path 개념 이름 두 개 최단 경로 — 연결 강도, 매개 노드 해석 없음
causal_chain 개념 이름 인과 네트워크 — 상류/하류, 관계 자연어 해석 없음
graph_summary 없음 위키 건강 리포트 — 규모, 밀도, 행동 제안 없음
search_wiki 질문 읽을 파일 목록 (그래프 확장, 본문 폴백, 한국어 조사 처리) 없음
read_page 경로, 범위(L10-L40, 선택) 페이지 본문과 인용할 위치 source: 경로 L시작-L끝 없음
cite_check 경로, 인용문 인용문이 실제로 있는지와 그 줄 위치 없음
lint_wiki 없음 무결성 검사 — YAML·중복 키·깨진 링크·출처·식별자·언어 누출 없음
suggest_links 개수 개념에 연결되지 않은 소스 페이지와 후보 개념 (쓰기는 사용자 승인 후) 없음
ingest raw 파일(선택) 아직 위키에 넣지 않은 raw/ 파일과 페이지 작성 안내 없음
rebuild_graph 없음 그래프 재빌드 후 graph.json 저장 graph.json

0.2부터 위키를 고치면 다음 도구 호출 때 그래프가 저절로 다시 만들어집니다. rebuild_graph 는 graph.json 파일로 남기고 싶을 때만 부르면 됩니다.

참고: 위키 페이지 생성/수정은 MCP 도구가 아닌 LLM이 직접 파일을 작성합니다.brainforge-mcp는 "읽기 + 분석" 전문이고, "쓰기"는 LLM의 역할입니다.

v0.2 도구 사용 흐름

"LoRA 관련해서 내 위키에 뭐가 있어?"   → search_wiki("LoRA")   → 상위 2~4개를 read_page 로 읽고, source: 줄을 출처로 답변
"이 문장 정말 위키에 있어?"            → cite_check(경로, 문장) → NOT FOUND 면 그 인용은 쓰지 않음
"raw 에 새로 넣은 거 있어?"            → ingest()              → 안내대로 위키 페이지 작성
"방금 인제스트한 거 점검해줘"          → lint_wiki()           → [E]를 고치고 PASS 될 때까지 반복
"아직 연결 안 된 소스 있어?"           → suggest_links()       → 읽고 제안 → 승인 후 related: 추가

lint_wiki 는 brainforge 볼트 구조(init 결과)에 맞춘 기본값을 씁니다. 아직 없는 페이지로 가는 [[링크]] 는오류가 아니라 경고(성장 제안)로 처리합니다. 볼트에 wiki-lint.json 을 두면 설정을 바꿀 수 있습니다.

인과 관계 표기

위키링크([[]])는 연결만 표현합니다. "왜" 연결되는지는 인과 callout으로 명시합니다:

> [!causal] 인과 관계
> [[메타러닝]] →(가능하게 함)→ [[DiscoRL]]의 RL 규칙 자동 발견
> 신뢰도: 높음 | 출처: [[discovering-sota-rl-algorithms]]

지원하는 관계 유형:

  • →(가능하게 함)→ / →(성능 향상)→ / →(성능 저하)→
  • →(기반이 됨)→ / →(발전시킴)→ / →(대체함)→
  • →(포함함)→ / →(적용됨)→

기존 옵시디언 볼트에 적용

이미 옵시디언을 사용 중이라면 wiki/ 폴더를 볼트 안에 만들고 --vault 옵션으로 지정하면 됩니다. 기존 [[위키링크]]를 자동으로 파싱합니다.

문제 해결 (Troubleshooting)

증상 확인할 것
클라이언트에 도구가 안 보임 uvx 가 PATH 에 있는지(uvx --version), 설정 JSON 문법, 클라이언트 재시작. 클라이언트 로그에 위키 폴더가 없습니다 가 있으면 --vault 경로를 고치세요
위키를 고쳤는데 답이 예전 그대로 0.2부터는 저절로 갱신됩니다. 0.1.x 라면 rebuild_graph 를 부르거나 업그레이드하세요
Windows 에서 경로 오류 JSON 안에서는 C:\\Users\\... 처럼 역슬래시를 두 번
설치된 버전 확인 uvx brainforge-mcp --version

변경 기록은 CHANGELOG.md에 있습니다.

라이선스

MIT

Inspired by Andrej Karpathy's LLM Wiki idea.

MCP Server · Populars

    REA: Reverse Engineer Anything

    Reverse engineer anything, Reimagine everything. RE anything from app behavior down to native binaries. Discord: https://discord.gg/GkcryMnJDM

    Community morluto

    🦞 OpenClaw — Personal AI Assistant

    Your own personal AI assistant. Any OS. Any Platform. The lobster way. 🦞

    Community openclaw

    MarkItDown-MCP

    An MCP server for the "markitdown" library.

    Community microsoft

    MarkItDown

    Python tool for converting files and office documents to Markdown.

    Community microsoft

    graphify

    Turn any codebase, with its docs, SQL schemas, configs, and PDFs, into a queryable knowledge graph. A /graphify skill for Claude Code, Cursor, Codex, and Gemini CLI: local deterministic AST parsing, every edge explained, no vector store.

    Community Graphify-Labs

MCP Server · New

    tokensave-dev

    tokensave-cli

    The TokenSave CLI, which indexes a repository into a code graph and serves it to AI coding agents over MCP.

    Community tokensave-dev
    ordewell

    ordewell

    Open source agent orchestrator. One goal becomes an editable plan of tasks that run in parallel on Claude Code, Codex, OpenCode and more, each on its own git branch.

    Community ordewell
    goodnight000

    api-anything

    Turn any website into an API your agent can call. Learns from the site's own frontend, heals itself when the site changes.

    Community goodnight000
    shuttle-browser

    Shuttle

    A Chromium fork built for AI agents: built-in MCP server, per-agent logged-in identities, sessions as tab groups

    Community shuttle-browser
    synectus

    OpenGMB

    Open-source Google Business Profile manager: reviews, posts, profile edits, rank tracking and keyword research for every location, with approval rules before anything goes live and an MCP server for AI agents. Self-host with Docker.

    Community synectus