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.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.