Transforms a GitHub repository into a personal knowledge base, allowing for direct reading and writing of tasks, notes, and structured knowledge via the GitHub API.
Organizes and manages personal data using Markdown files, supporting specific formats for task lists, priority headers, and categorized knowledge entries.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Knowledge MCP ServerWhat tasks do I have for today?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Knowledge MCP Server
MCP server biến GitHub repository thành bộ não cá nhân cho AI. Claude đọc/ghi trực tiếp vào các file markdown trên GitHub thông qua giao thức MCP.
Claude (LLM) ◄──stdio──► MCP Server ◄──HTTPS──► GitHub API ◄──► brain/ repoNguyên tắc: MCP server chỉ xử lý dữ liệu, không gọi LLM. Toàn bộ suy luận do Claude đảm nhận.
Yêu cầu
Node.js >= 18
GitHub account + Personal Access Token
Claude Desktop hoặc bất kỳ MCP client nào
Cài đặt
1. Clone repo
git clone https://github.com/<your-username>/knowledge_mcp.git
cd knowledge_mcp2. Cài dependencies
npm install3. Build
npm run build4. Tạo file .env
cp .env.example .envMở .env và điền thông tin:
GITHUB_TOKEN=ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
GITHUB_OWNER=yourusername
GITHUB_REPO=brain
GITHUB_BRANCH=main
BRAIN_BASE_PATH=brainLấy GitHub Token:
Tạo token mới (classic) với quyền repo
Copy token vào
GITHUB_TOKEN
Chuẩn bị Brain Repository
Cách 1: Tự động (khuyên dùng)
Chỉ cần tạo repo rỗng trên GitHub (ví dụ: brain), rồi kết nối MCP server. Sau đó nói với Claude:
"Khởi tạo brain cho tôi"
Claude sẽ gọi tool initBrain và tự động tạo toàn bộ cấu trúc thư mục trong 1 commit:
brain/
├── inbox/capture.md
├── tasks/today.md
├── tasks/backlog.md
├── notes/ideas.md
├── notes/learning.md
├── goals/short-term.md
├── goals/long-term.md
└── knowledge/general.md ← knowledge baseCách 2: Thủ công
Nếu muốn tự tạo, copy thư mục example-brain/brain/ trong repo này lên GitHub:
cd example-brain
git init
git add .
git commit -m "init: brain repository"
git remote add origin https://github.com/<your-username>/brain.git
git push -u origin mainFormat markdown cho tasks
- [ ] Task chưa làm
- [x] Task đã hoàn thành
- [ ] !!! Task ưu tiên cao #work @due(2026-03-20)
- [ ] !! Task ưu tiên trung bình #personalCác file khác (notes, goals, inbox) viết tự do, mỗi dòng là một item.
Kết nối với Claude Desktop
Mở file cấu hình Claude Desktop:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.json
Thêm vào:
{
"mcpServers": {
"knowledge-brain": {
"command": "node",
"args": ["/đường-dẫn-tuyệt-đối/knowledge_mcp/dist/index.js"],
"env": {
"GITHUB_TOKEN": "ghp_...",
"GITHUB_OWNER": "yourusername",
"GITHUB_REPO": "brain",
"GITHUB_BRANCH": "main",
"BRAIN_BASE_PATH": "brain"
}
}
}
}Lưu ý: Thay
/đường-dẫn-tuyệt-đối/bằng đường dẫn thực tế trên máy bạn.
Khởi động lại Claude Desktop để load MCP server.
Kết nối với Claude Code
Thêm vào file .claude/settings.json hoặc chạy lệnh:
claude mcp add knowledge-brain -- node /đường-dẫn-tuyệt-đối/knowledge_mcp/dist/index.jsHoặc cấu hình thủ công trong .claude/settings.json:
{
"mcpServers": {
"knowledge-brain": {
"command": "node",
"args": ["/đường-dẫn-tuyệt-đối/knowledge_mcp/dist/index.js"],
"env": {
"GITHUB_TOKEN": "ghp_...",
"GITHUB_OWNER": "yourusername",
"GITHUB_REPO": "brain"
}
}
}
}Danh sách Tools
Khởi tạo
Tool | Mô tả |
| Tạo toàn bộ cấu trúc brain trên repo rỗng (1 commit) |
Đọc dữ liệu
Tool | Mô tả |
| Lấy tất cả tasks (today + backlog) |
| Lấy tasks hôm nay |
| Lấy tasks backlog |
| Lấy notes (ideas / learning) |
| Lấy goals (short-term / long-term) |
| Lấy nội dung inbox |
Ghi dữ liệu
Tool | Input | Mô tả |
|
| Thêm task mới |
|
| Đánh dấu task hoàn thành |
|
| Thêm ghi chú |
|
| Lưu nhanh vào inbox |
Knowledge Base
Tool | Input | Mô tả |
| — | Xem danh sách topics (chỉ tên, không đọc nội dung) |
|
| Đọc toàn bộ entries trong 1 topic |
|
| Thêm kiến thức, tự tạo topic nếu chưa có |
|
| Tìm kiếm keyword across tất cả topics |
Bắt đầu sử dụng
Lần đầu tiên — tạo repo rỗng trên GitHub, cấu hình MCP, rồi nói:
"Khởi tạo brain cho tôi"
→ Claude gọi initBrain, tạo toàn bộ cấu trúcSau đó — hỏi Claude bất kỳ câu nào:
"Hôm nay tôi cần làm gì?"
→ Claude gọi getTodayTasks, phân tích và trả lời
"Thêm task: thiết kế landing page"
→ Claude gọi addTask với text "thiết kế landing page"
"Đánh dấu task review PR là xong"
→ Claude gọi markTaskDone với text "review PR"
"Tóm tắt goals của tôi"
→ Claude gọi getGoals cho cả short-term và long-term
"Ghi lại ý tưởng: xây dựng AI chatbot cho team"
→ Claude gọi saveToInbox hoặc addNote
"Tôi đang làm dự án gì?"
→ Claude gọi getTasks và phân tích contextKnowledge Base — Hệ thống kiến thức
Knowledge base cho phép lưu trữ kiến thức theo topic và tìm kiếm lại khi cần. Kiến thức được tổ chức trong folder knowledge/, mỗi topic là 1 file markdown.
Cấu trúc
brain/knowledge/
├── javascript.md ← topic về JS
├── git.md ← topic về Git
├── docker.md ← topic về Docker
└── cooking.md ← không chỉ code — lưu gì cũng đượcFormat mỗi topic file
Mỗi entry là 1 heading ## với nội dung bên dưới:
# JavaScript
## var vs let vs const
- `var`: function-scoped, hoisted → tránh dùng
- `let`: block-scoped, có thể reassign
- `const`: block-scoped, không thể reassign
## Promise vs async/await
Promise là cách xử lý bất đồng bộ trong JS.
async/await là syntax sugar cho Promise...Ví dụ sử dụng
Hỏi kiến thức đã lưu
User: "Nhắc lại cách undo commit trong git?"
Claude:
1. searchKnowledge("undo commit")
2. Tìm thấy entry "Undo last commit" trong topic "git"
3. Trả lời: git reset --soft HEAD~1Lưu kiến thức mới
User: "Lưu lại cách tối ưu Dockerfile cho Node.js"
Claude:
1. addKnowledge("docker", "Dockerfile tối ưu cho Node.js", "FROM node:20-alpine...")
2. Trả lời: Đã lưu vào topic dockerTạo topic mới tự động
User: "Ghi nhớ: trứng luộc lòng đào cần đúng 6 phút 30 giây"
Claude:
1. addKnowledge("cooking", "Trứng luộc lòng đào", "Nước sôi → thả trứng → 6:30 → ngâm đá")
2. File cooking.md được tạo tự động nếu chưa cóXem có những topic gì
User: "Tôi đã lưu những kiến thức gì?"
Claude:
1. listTopics()
2. Trả về: javascript, git, docker, cooking
→ Chỉ 1 API call, không đọc nội dung file nàoĐọc chi tiết 1 topic
User: "Cho tôi xem hết kiến thức về Docker"
Claude:
1. getKnowledge("docker")
2. Trả về tất cả entries: Các lệnh cơ bản, Dockerfile tối ưu, Docker Compose...Tìm kiếm cross-topic
User: "Tôi có ghi gì về async không?"
Claude:
1. searchKnowledge("async")
2. Tìm thấy entry "Promise vs async/await" trong topic "javascript"
3. Trả về nội dung matchFlow tiết kiệm token
Bước | API calls | Token |
| 1 | Chỉ tên file, ~50 bytes |
| 1 (cached 30s) | Chỉ 1 file |
| 1 + N (cached) | Lần đầu load, các lần sau free |
| 2 (read + write) | Chỉ 1 file |
So với lưu hết vào 1 file: knowledge tách topic nên khi đọc chỉ load đúng cái cần, không phải load toàn bộ.
Cấu trúc source code
src/
├── index.ts # Entry point — khởi tạo server + stdio transport
├── mcp.ts # Đăng ký tất cả MCP tools
├── config.ts # Load biến môi trường
├── logger.ts # Structured JSON logger (ghi ra stderr)
├── errors.ts # Error hierarchy (NotFoundError, ConflictError...)
├── core/
│ ├── brain.ts # Facade chính — đọc/ghi/init brain qua GitHub
│ ├── parser.ts # Parse markdown ↔ structured data
│ ├── knowledge.ts # Knowledge base — lưu/tìm kiến thức theo topic
│ └── aggregator.ts # Truy vấn cross-file (tổng hợp tasks)
├── github/
│ ├── client.ts # Octokit wrapper (getFile, updateFile, listDirectory...)
│ └── sync.ts # Map brain section → GitHub file path + retry
├── tools/
│ ├── helpers.ts # toolHandler wrapper (error handling + logging)
│ ├── brain.ts # Tool: initBrain
│ ├── tasks.ts # Tools: getTasks, addTask, markTaskDone...
│ ├── notes.ts # Tools: getNotes, addNote, getGoals
│ ├── inbox.ts # Tools: getInbox, saveToInbox
│ └── knowledge.ts # Tools: listTopics, getKnowledge, addKnowledge, searchKnowledge
└── types/
├── brain.ts # Types: FileContent, BrainSection, Note, Goal
└── task.ts # Types: Task, TaskStatus, TaskPriorityBiến môi trường
Biến | Bắt buộc | Mặc định | Mô tả |
| Yes | — | GitHub Personal Access Token (quyền repo) |
| Yes | — | Username hoặc org trên GitHub |
| Yes | — | Tên repo chứa brain |
| No |
| Branch sử dụng |
| No |
| Thư mục gốc trong repo |
| No |
|
|
| No |
| Thời gian cache file reads (ms) |
| No |
| Số lần retry khi gặp SHA conflict |
Scripts
npm run build # Compile TypeScript → dist/
npm run start # Chạy server (production)
npm run dev # Chạy trực tiếp bằng tsx (development)Lưu ý kỹ thuật
initBrain dùng Git Tree API: Tạo tất cả file trong 1 commit duy nhất, hoạt động cả trên repo hoàn toàn rỗng (chưa có commit nào).
TTL Cache: File reads được cache trong bộ nhớ (mặc định 30s) để giảm API calls. Writes tự động invalidate cache.
Retry on conflict: Khi ghi file gặp SHA conflict (409), server tự đọc lại file mới nhất và thử lại (mặc định 3 lần).
Format-preserving: Khi sửa task (mark done, thêm task), server chỉ sửa đúng dòng cần thiết, không rewrite toàn bộ file.
CRLF safe: Parser tự normalize
\r\n→\n, hỗ trợ frontmatter, numbered lists, priority markers (!/!!/!!!), due dates (@due(YYYY-MM-DD)).Structured logging: Tất cả logs ghi ra stderr dạng JSON, không ảnh hưởng MCP protocol trên stdout.
License
MIT
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.