claude-rag
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., "@claude-ragfind notes about deploying on AWS"
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.
claude-rag โ MCP RAG Server for Markdown Knowledge Bases
Author: Sergio Angelastro โ MIT License
MCP server that indexes a folder of .md files into a local SQLite vector store and exposes semantic search as Claude Code tools. The core RAG system (chunking, embedding, SQLite vector store, MCP server, cosine similarity search) is original work by the author.
Hook system (
hooks/) inspired by agd-memory by @Pinperepette (MIT) โ see CREDITS.md
Architecture

Three components working together:
What | When | |
โ Indexing |
| on startup / |
โก MCP | Claude calls | explicit semantic search |
โข Hook | every prompt intercepted โ keyword score on | automatic, ~10ms, no model |
Stack: Python ยท sentence-transformers (paraphrase-multilingual-MiniLM-L12-v2, ~120MB, CPU-only) ยท SQLite ยท MCP stdio
Related MCP server: flightlog
Tools exposed
Tool | Description |
| Semantic search โ returns top-K chunks with source file and section |
| Re-indexes files modified since last run (mtime-based) |
| Shows indexed files, chunk counts, last update timestamps |
| Shows cumulative token savings: RAG chunks served vs full-file baseline, broken down by source ( |
Setup
1. Clone
# Default layout: repo sits inside the KB folder
# KB files (.md) go in the parent directory
git clone https://github.com/sangelastro/claude-rag ~/.claude/my-kb/ragOr clone anywhere and point to your KB folder via env var (see step 3).
2. Install dependencies
cd ~/.claude/my-kb/rag
pip install -r requirements.txtOn first run the model (paraphrase-multilingual-MiniLM-L12-v2, ~120MB) is downloaded automatically from HuggingFace. This model supports 50+ languages including Italian natively.
3. Register in Claude Code
Add to ~/.claude.json under mcpServers:
"my-kb": {
"command": "python",
"args": ["/absolute/path/to/rag/server.py"],
"env": {
"KB_RAG_DIR": "/absolute/path/to/your/kb/folder"
}
}KB_RAG_DIRโ folder containing your.mdfiles (default:../relative toserver.py)KB_RAG_DBโ SQLite database path (default:kb.dbnext toserver.py)CHUNK_MAX_CHARSโ max chars per chunk before splitting (default:400)CHUNK_OVERLAPโ overlap in chars between consecutive sub-chunks (default:80)
If the repo is cloned inside the KB folder (as in the example above), both env vars can be omitted.
4. Restart Claude Code
The server starts automatically. On first launch it indexes all .md files in KB_RAG_DIR.
Optional: Claude Code Hooks
Two hooks auto-inject KB context without explicit kb_search calls.
Approach inspired by agd-memory (MIT).
Hook | Script | What it does |
|
| Injects KB table of contents at session start |
|
| Auto-injects top matching chunks before each prompt (keyword scoring, ~10ms, no model load) |
Setup hooks
Copy the relevant sections from hooks/hooks_example.json into your ~/.claude/settings.json, replacing the placeholder paths:
{
"hooks": {
"SessionStart": [{
"matcher": "*",
"hooks": [{"type": "command", "command": "python /absolute/path/to/rag/hooks/kb_session_start.py"}]
}],
"UserPromptSubmit": [{
"matcher": "*",
"hooks": [{"type": "command", "command": "python /absolute/path/to/rag/hooks/kb_recall.py", "timeout": 5}]
}]
}
}kb_chunks.json (used by kb_recall.py) is auto-generated next to kb.db on every reindex. No model loading in hooks โ scoring uses token overlap only.
Hook behaviour is tunable via env vars:
Variable | Default | Description |
|
| Max chunks injected per prompt |
|
| Minimum score to trigger injection |
|
| Skip prompts shorter than N words |
|
| Max chars injected (~4 chars/token) |
File structure
rag/
โโโ server.py # MCP server
โโโ requirements.txt
โโโ .gitignore
โโโ README.md
โโโ hooks/
โ โโโ kb_session_start.py # SessionStart hook
โ โโโ kb_recall.py # UserPromptSubmit hook
โ โโโ hooks_example.json # Hook config template
โโโ architecture.html # Technical documentation
โโโ kb_rag_slides.html # Architecture slide deckkb.db and kb_chunks.json are generated locally and excluded from git.
How it works
Chunking โ each
.mdfile is split on##headers; frontmatter is stripped; sections longer thanCHUNK_MAX_CHARS(400) are further split into overlapping sub-chunks withCHUNK_OVERLAP(80) chars of context continuityEmbedding โ chunks are encoded with
paraphrase-multilingual-MiniLM-L12-v2(384 dimensions, 50+ languages)Storage โ vectors stored as
float32BLOBs in SQLite +kb_chunks.jsonfor hooksSearch โ cosine similarity computed in numpy over all chunks; top-K returned
Hooks โ keyword scoring on
kb_chunks.json(no model), injected before each promptInvalidation โ mtime-based: only modified files are re-indexed on startup
Savings tracking โ every search records chars served vs full-file baseline in
search_statstable;kb_savings()aggregates the cumulative token reduction without re-reading any file
Environment variables
Variable | Default | Description |
|
| Folder with |
|
| SQLite database path |
|
| MCP server name |
|
| Max chars per chunk; longer sections are split into overlapping sub-chunks |
|
| Overlap chars between adjacent sub-chunks to preserve context continuity |
Credits
Hook architecture inspired by agd-memory by Pinperepette (MIT License) โ in particular the UserPromptSubmit recall pattern and guard rail logic.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- Alicense-qualityDmaintenanceA local MCP server that indexes and searches your Claude Code conversation history with both keyword and semantic search, fully private and running locally.Last updatedMIT
- AlicenseAqualityDmaintenanceAn MCP server that indexes Claude Code conversation history into SQLite, enabling full-text search across past sessions for context recovery and cross-agent observability.Last updated103MIT
- AlicenseAqualityCmaintenanceA local MCP server that indexes and searches your past Claude sessions using SQLite FTS5. No cloud, runs entirely on your machine.Last updated3MIT
- Flicense-qualityBmaintenanceA local MCP server that enables LLM clients like Claude to perform semantic code search and answer questions about a codebase using tree-sitter parsing and sqlite-vec vector storage.Last updated
Related MCP Connectors
Augments MCP Server - A comprehensive framework documentation provider for Claude Code
Serve a folder of Markdown notes as an MCP server: hybrid search, reading, and sourced answers.
An MCP server that gives your AI access to the source code and docs of all public github repos
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/sangelastro/claude-rag'
If you have feedback or need assistance with the MCP directory API, please join our Discord server