Generic MCP server for Markdown-based AI Brain context systems
A generic MCP server that serves Markdown-based AI Brain files to any MCP-compatible Claude client.
Gives Claude persistent, context-aware access to a collection of Markdown files (an "AI Brain") via the Model Context Protocol. Supports reading, writing, searching, and git-backed versioning — all over local stdio transport.
| Tool | Description |
|---|---|
brain_load_context | Entry point — returns the loader + NOW.md, plus lint, issue, and inbox nudges |
brain_read_file | Read a specific Brain file by name |
brain_update_file | Update a Brain file (replace, append, or patch) |
brain_commit | Git commit changes, optionally push |
brain_list_files | List all files with staleness metadata |
brain_search | Search across all Brain files |
brain_log | Append an entry to the Brain change log |
brain_read_log | Read recent change log entries |
brain_lint | Run a health check (bloat, staleness, orphan backlinks, drift, missing cross-references) |
brain_ingest | Process a new source — dry-run analysis or save to sources/ |
brain_ingest_complete | Record provenance after ingest (updates SOURCES.md + LOG.md, optionally deletes inbox file) |
brain_scan_inbox | List files pending in the inbox/ drop-folder for processing |
00_loader.md and NOW.md# 1. Clone and build
git clone <your-fork-or-clone-url> ~/Projects/brain-mcp-server
cd ~/Projects/brain-mcp-server
npm install
npm run build
# 2. Verify the build produced dist/index.js
ls dist/index.js
# 3. Test with MCP Inspector (optional but recommended)
npx @modelcontextprotocol/inspector node dist/index.js| Variable | Description | Default |
|---|---|---|
BRAIN_DIR | Absolute path to your Brain markdown files directory | ~/Projects/ai-brain-jem/brain |
Add to ~/.claude/settings.json (user-level) or .claude/settings.json (project-level):
{
"mcpServers": {
"brain": {
"command": "node",
"args": ["/absolute/path/to/brain-mcp-server/dist/index.js"],
"env": {
"BRAIN_DIR": "/absolute/path/to/your/brain/files"
}
}
}
}Add to claude_desktop_config.json (same format as above).
Add via the MCP server configuration in Cowork settings (same command, args, and env values).
After the MCP server is connected, three additional steps make it fully automatic.
Add mcp__brain to your permissions allow-list so Claude doesn't prompt for approval on every Brain tool call.
In ~/.claude/settings.json, add to the permissions.allow array:
{
"permissions": {
"allow": [
"mcp__brain"
]
}
}This matches all twelve Brain tools. You can verify with /permissions in Claude Code.
Add the following to ~/.claude/CLAUDE.md so Claude loads Brain context when relevant — not on every conversation:
## AI Brain (Conditional Auto-Load)
An AI Brain (personal knowledge system) is connected via MCP. Load it when the conversation
benefits from personal context — skip it for generic tasks.
Load Brain context proactively (don't wait to be asked) when:
- Writing on the user's behalf, career/professional tasks, work context, personal projects,
strategy/advice requiring background, anything needing voice/preferences/expertise,
or user references "my Brain" / "my context"
Skip when:
- Generic technical questions, general knowledge/research, pure coding help,
or user explicitly says not to load
Load sequence (when loading):
1. Fetch tools (if deferred): ToolSearch(query="select:mcp__brain__brain_load_context,mcp__brain__brain_read_file,mcp__brain__brain_search,mcp__brain__brain_update_file,mcp__brain__brain_commit,mcp__brain__brain_log,mcp__brain__brain_read_log,mcp__brain__brain_lint,mcp__brain__brain_ingest,mcp__brain__brain_ingest_complete,mcp__brain__brain_scan_inbox")
2. Call brain_load_context (returns loader + NOW.md + lint/issue nudges)
3. Call brain_read_file for task-relevant files per the navigation table
4. If brain_load_context flags a lint nudge or open issues, act accordinglyThis works for both Claude Code and Cowork (both read ~/.claude/CLAUDE.md).
Claude Desktop and claude.ai do not read CLAUDE.md. For these clients, add the conditional auto-load directive to your user preferences (Settings → Profile → User preferences).
See MANUAL_SETUP.md for the exact text to paste, verification tests, and a troubleshooting checklist.
Note: This step requires manual entry in each client's preferences UI. It cannot be automated.
brain_load_context at session start (automatically, if configured per above)brain_read_filebrain_update_file, then committed via brain_commitbrain_ingest (dry-run analysis, then guided updates)brain_log; health is checked via brain_lintThe routing logic lives in the loader (a Markdown file you maintain), not in code. The server is content-agnostic — it knows nothing about your specific Brain content, only how to serve Markdown files.
Brain files use [[backlinks]] (Obsidian-style wikilinks) to cross-reference each other. During ingest, the LLM maintains these links across all affected files. The lint process checks for orphan content files (zero inbound backlinks). The Brain directory can be opened as an Obsidian vault for graph view and backlink navigation.
The MCP server works from any Claude client, but different tasks suit different clients:
| Activity | Best client | Why |
|---|---|---|
| Using Brain in conversation | Chat (any client with MCP) | All read/write tools work over stdio — no uploads needed |
| Small updates (NOW.md, tasks, journal) | Chat | brain_update_file + brain_commit handle it directly |
| Large document ingestion | Cowork or Code | Multi-step workflow needs filesystem access to sources/ |
| Drop-folder ingestion | Any (via scheduled task) | Drop files into inbox/, daily task processes them automatically |
| Server code maintenance | Code | Iterative build-test-commit cycle |
| Brain repo git operations | Code | Shell access for rebasing, conflict resolution, pushing |
| Graph view & knowledge mapping | Obsidian | Open brain/ as a vault for graph visualization, backlink navigation, and orphan detection |
Chat is the primary interface for day-to-day Brain usage — loading context, searching, editing files, committing. Cowork or Code are needed when the workflow requires direct filesystem access (e.g., saving source documents) or agentic multi-step operations. Code is the right tool for maintaining the server codebase itself.
For the full methodology, see the AI Brain Primer.
MIT
JEM-Fizbit/brain-mcp-server
March 25, 2026
April 13, 2026
TypeScript