DEV Community

Cover image for Self-hosted second brain with MCP
lobrzut
lobrzut

Posted on • Originally published at dev.to

Self-hosted second brain with MCP

I run IT and cybersecurity ops by day and tinker in a homelab at night. The problem I kept hitting: useful context from Cursor and Claude Code sessions evaporates when the chat ends. Notes end up scattered. RAG demos are cloud-first. I wanted something I own.

So I built Brain AI Hub: a portable second brain with a local LLM, markdown vault, semantic search, and MCP hooks for IDE agents.

What it does

  1. Local LLM - Ollama (qwen2.5, nomic-embed). OpenAI-compatible API on :11434.
  2. Knowledge store - Obsidian-style vault, PDF/EPUB library, sqlite-vec RAG, lightweight knowledge graph.
  3. Agent bridge - three MCP servers (brain-vault, brain-library, brain-rag) with one-click deploy to Cursor, Claude Code, VS Code.
  4. Transcript pipeline - distills exports from Claude/Cursor/Antigravity into vault markdown, dedupes, indexes code, runs scheduled jobs.
  5. Dashboard - FastAPI UI on :7860 for services, chat, GPU/VRAM, API keys, pipeline status.

Two editions

Edition Install
Windows portable Install.bat then Start.bat - copy the folder, run on another PC
Linux server Run linux/bootstrap.sh on the server (see repo README) - MCP SSE gateway on :7862 for LAN clients

Install scripts speak English and Polish. Set LANG=en or LANG=pl in locale.env.

MCP in practice

On Windows, Brain deploys stdio MCP configs from the dashboard. On Linux, point Cursor at the SSE gateway:

{
  "mcpServers": {
    "brain-rag": {
      "url": "http://192.168.1.10:7862/sse/brain-rag"
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Agents can search your vault, pull library chunks, and run skills without sending data to a third-party memory API.

Why MCP instead of only RAG?

RAG answers retrieval. MCP gives agents tools: write a note, list vault files, trigger a skill, query the code index. That matches how Cursor and Claude Code actually work: function calls mid-session, not a single embedding search at prompt time.

Stack

Python, FastAPI, Ollama, sqlite-vec, PowerShell (Windows), systemd (Linux). Homelab-friendly: MikroTik/UniFi networking, WireGuard, Docker where it helps.

Try it

git clone https://github.com/lobrzut/brain.git
cd brain
# Windows: Install.bat && Start.bat
# Linux:  curl -fsSL https://raw.githubusercontent.com/lobrzut/brain/main/linux/bootstrap.sh | sudo bash
Enter fullscreen mode Exit fullscreen mode

Open http://127.0.0.1:7860, connect MCP from the Tools tab, drop a PDF in the library, run a distill job on an old chat export.

Feedback and issues welcome on GitHub.

Top comments (1)

Collapse
 
sawftware profile image
Aly

Your exploration of self-hosting with MCP is quite relevant in today's landscape. By integrating document verification mechanisms, you can ensure that the information being processed is accurate and tamper-proof, significantly enhancing the trustworthiness of your applications. Utilizing evidence bundles with SHA-256 hashes can provide a solid foundation for audit trails, allowing for offline verification of the documents used in your system. For more on this, check out docimprint.com/evidence-bundles.