Librarian MCP
Transforms a folder of Markdown files into a structured, version-controlled knowledge base with semantic search and safe AI editing via draft branches.
README
📚 Librarian MCP: The Personal Knowledge OS
Librarian MCP is an intelligent orchestration layer for your personal knowledge base, inspired by Andrej Karpathy's LLM Wiki vision. It transforms a simple folder of Markdown files into a dynamic, structured, and safe "digital brain" accessible to any AI agent via the Model Context Protocol (MCP).
Unlike traditional RAG systems that merely retrieve fragments, Librarian MCP enables Iterative Synthesis—where AI acts as an active editor, maintaining structure, cross-links, and ground truth across multiple projects.
🚀 Key Features
- 🛡️ Safety-First (Drafts Workflow): AI never modifies your "master" branch directly. All changes are isolated in
draft/*Git branches for your review and approval. - 🧠 Local Semantic Intelligence: Fully offline vector search using
transformers.js(all-MiniLM-L6-v2) andLanceDB. No external API keys or internet connection required for search. - 📏 Automated Rule Enforcement: Enforces naming conventions (
Capitalized_Snake_Case) and mandatory metadata (YAML sources/tags) at the protocol level to prevent data entropy. - 🗺️ Autonomous Project Mapping: Automatically scans your directory structure and maintains a global index of all projects and knowledge nodes.
- 🔌 Ingest API: Optional HTTP service to feed data from browser extensions, bots, or CLI tools directly into your Hub's
raw/directory. - 🐳 Portable & Private: Runs as a lightweight Docker container. Your data stays on your machine, always under Git version control.
🏗️ Architecture
graph TD
User([User / Obsidian]) <--> Hub[(Knowledge Hub\nMarkdown + Git)]
AI_Agent([AI Agent / Gemini-CLI / Cursor]) <--> MCP[Librarian MCP Server]
MCP <--> Hub
External_Source([Web / API / Bots]) -- HTTP POST --> Ingest[Ingest API]
Ingest --> Hub
🛠️ Quick Start
1. Prerequisites
- Docker & Docker Compose
- A folder to serve as your Knowledge Hub (Librarian will initialize it if empty).
2. Configuration
- Clone this repository:
git clone https://github.com/AlSokolov2/librarian-mcp.git cd librarian-mcp - Create your
.envfile:cp .env.example .env - Configure the following variables in
.env:KNOWLEDGE_HUB_PATH: Absolute path to your notes folder.USER_ID&GROUP_ID: Runid -uandid -gin your terminal to get these (prevents permission issues).
3. Launch
For Production (Optimized Image):
docker compose up -d
This builds a lightweight image (~200MB) with only runtime dependencies.
For Development (Live Reload):
docker compose -f docker-compose.dev.yml up -d
This mounts your local src/ folder into the container, allowing for instant code changes without rebuilding.
4. Connect to your MCP Client
Add Librarian to your client configuration (e.g., ~/.gemini/settings.json):
"mcpServers": {
"librarian": {
"command": "docker",
"args": ["exec", "-i", "librarian-mcp", "node", "build/index.js"]
}
}
Note: If you prefer to use the pre-built image from Docker Hub:
"args": ["run", "-i", "--rm", "alsokolov2/librarian-mcp:latest"]
🛠️ Development & Testing
If you are developing Librarian MCP, you can run tests and linting directly inside the container:
# Run tests
docker exec -it librarian-mcp-dev npm test
# Run linter
docker exec -it librarian-mcp-dev npm run lint
📖 Tools Reference
| Tool | Description |
|---|---|
search_knowledge |
Classic keyword search using grep. Fast and precise. |
semantic_search |
Contextual search by meaning. Finds related concepts even without keyword matches. |
read_file |
Reads any file from the Hub (wiki, raw, or meta). |
write_file |
Writes content to a new Git branch (draft/*). Applies templates and validates rules. |
list_drafts |
Lists all pending AI-generated drafts. |
approve_draft |
Merges a specific draft branch into master and deletes the branch. |
discard_draft |
Deletes a draft branch without saving changes. |
reindex_all |
Re-builds the local vector database for semantic search. |
update_project_map |
Synchronizes meta/PROJECT_MAP.md with the current folder structure. |
📏 Governance & Rules
Librarian enforces the "Knowledge Hub Constitution":
- Naming: Files in
wiki/must beCapitalized_Snake_Case.md. - Grounding: Every wiki page must have a
sourcesarray in its YAML header pointing to files inraw/. - Structure: Every page must start with an
# H1 Header. - History: Every change is committed to Git with an automated summary.
These rules are configurable via meta/config.json inside your Hub.
🔌 Ingest API Usage
If enabled (ENABLE_INGEST_API=true), you can send data to the Hub via HTTP:
curl -X POST http://localhost:3000/ingest \
-H "Content-Type: application/json" \
-H "x-api-key: your-secret-key" \
-d '{
"filename": "meeting_notes.txt",
"content": "Raw text from the meeting..."
}'
⚖️ License
MIT License. Created with ❤️ by AlSokolov2.
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。