DocsRagMcp
Uses Ollama (default model nomic-embed-text) as the embedding provider for indexing and querying documents, so passages and questions are embedded fully locally without sending data off the machine.
Uses OpenAI's embeddings API (default text-embedding-3-small, configurable endpoint for OpenAI-compatible servers) to embed indexed document chunks and search queries instead of the local Ollama model.
Click on "Deploy 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., "@DocsRagMcp Index my Markdown notes in ~/notes and find the vacation policy."
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.
docs-rag-mcp
An MCP server, written in C#, that lets Claude, GitHub Copilot, Cursor and other AI assistants search your own documents with retrieval-augmented generation (RAG).
Point it at a folder of Markdown, text or PDF files. It splits them into passages, turns each passage into an embedding, and stores everything in a local SQLite file. When you ask your assistant a question, it calls search_docs, gets back the most relevant passages with their file and section, and answers from them.
Runs fully local with Ollama, or uses OpenAI or Azure OpenAI embeddings
One file, no database server: the index is a single SQLite file
Incremental: re-indexing only embeds files that changed, and drops files you deleted
Cites its sources: every passage comes with its file path and heading or PDF page
Safe by default for shared machines: you can limit which folders it may read
Example
With the sample handbook indexed, asking "Can I spend a month working from Spain?" returns:
2 passages for "Can I spend a month working from Spain?":
[1] samples/handbook/remote-work.md > Working from another country (score 0.71)
## Working from another country
You can work from another country for up to 30 days a year. Tell your manager and HR
two weeks in advance, because some countries need paperwork for tax and insurance.
[2] samples/handbook/remote-work.md > Remote work (score 0.57)
...Neither "Spain" nor "month" appears in the document. The search matches on meaning, not keywords.
Related MCP server: Personal RAG MCP Server
How it works
flowchart LR
A[AI assistant<br/>Claude, Copilot, Cursor] -- MCP over stdio --> B[docs-rag-mcp]
B -- index_folder --> C[Read .md / .txt / .pdf<br/>split by heading or page<br/>chunk with overlap]
C --> D[Embedding model<br/>Ollama, OpenAI, Azure OpenAI]
D --> E[(SQLite<br/>chunks + vectors)]
B -- search_docs --> D
E -- cosine similarity, top K --> BQuick start (local, with Ollama)
You need the .NET 10 SDK and Ollama. Pull the embedding model once:
ollama pull nomic-embed-textThe server is published on NuGet and in the MCP Registry as io.github.Ahmed-Manai/docs-rag-mcp. dnx, which comes with .NET 10, downloads and starts it, so there is nothing else to install. Add it to your assistant:
In claude_desktop_config.json (Settings > Developer > Edit Config):
{
"mcpServers": {
"docs-rag": {
"command": "dnx",
"args": ["DocsRagMcp", "--yes"],
"env": {
"DOCSRAG_ALLOWED_PATHS": "/path/to/your/notes"
}
}
}
}In .vscode/mcp.json:
{
"servers": {
"docs-rag": {
"type": "stdio",
"command": "dnx",
"args": ["DocsRagMcp", "--yes"],
"env": {
"DOCSRAG_ALLOWED_PATHS": "${workspaceFolder}"
}
}
}
}In ~/.cursor/mcp.json, use the same mcpServers block as for Claude Desktop.
claude mcp add docs-rag -e DOCSRAG_ALLOWED_PATHS=/path/to/your/notes -- dnx DocsRagMcp --yesgit clone https://github.com/Ahmed-Manai/docs-rag-mcp.git
cd docs-rag-mcp
dotnet build -c ReleaseThen use "command": "dotnet" with "args": ["run", "--no-build", "-c", "Release", "--project", "/path/to/docs-rag-mcp/src/DocsRagMcp"].
Now ask your assistant: "Index my notes in /path/to/your/notes", then ask questions about them.
Tools
Tool | What it does |
| Indexes the Markdown, text and PDF files in a folder and its subfolders. Unchanged files are skipped and deleted files are removed. |
| Returns the passages closest in meaning to a question, with file, section and score. Optional |
| Lists the indexed files with their number of chunks and when they were indexed. |
| Removes a file, or every file in a folder, from the index. Files on disk are never touched. |
search_docs and list_sources are marked read-only and remove_from_index destructive, so clients can decide when to ask you for confirmation.
Configuration
Settings come from environment variables (or the matching command-line switch, such as --provider).
Variable | Default | Description |
|
|
|
|
| Embedding model, or the deployment name for Azure OpenAI |
|
| Required for Azure OpenAI. For OpenAI, set it to use any OpenAI-compatible API |
| OpenAI or Azure OpenAI key. Read from the environment only, never from the command line | |
| any folder | Folders the server may index, separated by |
|
| Where the index is stored |
|
| Maximum characters per chunk |
|
| Characters repeated between consecutive chunks |
OpenAI
"env": {
"DOCSRAG_PROVIDER": "openai",
"DOCSRAG_API_KEY": "sk-..."
}Azure OpenAI
"env": {
"DOCSRAG_PROVIDER": "azure",
"DOCSRAG_ENDPOINT": "https://my-resource.openai.azure.com/",
"DOCSRAG_MODEL": "my-embedding-deployment"
}Without DOCSRAG_API_KEY, the server signs in with Microsoft Entra ID through DefaultAzureCredential (az login, Visual Studio, managed identity...). Your account needs the Cognitive Services OpenAI User role on the resource.
LM Studio, vLLM and other OpenAI-compatible servers
"env": {
"DOCSRAG_PROVIDER": "openai",
"DOCSRAG_ENDPOINT": "http://localhost:1234/v1",
"DOCSRAG_MODEL": "text-embedding-nomic-embed-text-v1.5"
}Privacy and security
With Ollama, documents and questions never leave your machine.
The server only reads your files. The only file it writes is the index.
Set
DOCSRAG_ALLOWED_PATHSso an assistant can't index folders you didn't intend, such as your home folder. Paths are resolved before they are checked, sodocs/../secretsdoesn't get around it.Hidden folders (
.git,.ssh, ...), symbolic links andnode_modules,binandobjfolders are skipped.An index remembers which embedding model built it. Searching it with a different model is refused instead of silently returning wrong results.
Design notes
Chunking follows the document's structure. Markdown is split at headings and PDFs by page before being cut into chunks, so every passage knows where it came from. Chunks break at paragraph boundaries when they can, and overlap a little so an idea that spans two chunks can still be found.
Each chunk is embedded with its context. The text sent to the embedding model starts with the file name and heading (for example
travel-and-expenses.md > Hotels). A short passage like "220 EUR in Paris" then still matches a question about hotel budgets.Brute-force cosine search over SQLite. Vectors are stored as blobs and compared with
TensorPrimitives.CosineSimilarity, which uses SIMD. For personal and team document sets (up to tens of thousands of chunks) this stays fast and needs no native vector extension. A vector index is on the roadmap for larger sets.Content hashes make re-indexing cheap. Each file's SHA-256 is stored, so running
index_folderagain only calls the embedding model for files that changed.Provider-agnostic. The server depends only on
IEmbeddingGeneratorfrom Microsoft.Extensions.AI. Supporting another provider means changing one factory class.
Development
dotnet build
dotnet testThe tests use a deterministic fake embedding model, so they need no network. Two of them start the real server process and talk to it over MCP, the way an assistant does.
To check everything against a real model (Ollama by default):
dotnet run samples/smoke.cs -- "How much can I spend on a hotel in Paris?"src/DocsRagMcp/
Program.cs host, dependency injection, MCP server setup
DocsRagOptions.cs settings and validation
Tools/DocsTools.cs the four MCP tools
Indexing/DocumentIndexer.cs folder sync: hash, read, chunk, embed, store
Indexing/PathGuard.cs allowed-folder checks
Ingestion/DocumentReader.cs Markdown, text and PDF reading
Ingestion/TextChunker.cs chunking with overlap
Storage/ChunkStore.cs SQLite storage and vector search
Embeddings/ Ollama, OpenAI and Azure OpenAI clients
tests/DocsRagMcp.Tests/ unit and end-to-end tests
samples/ sample documents and the smoke testRoadmap
Word (
.docx) and HTML filesHybrid search that combines keyword (SQLite FTS5) and vector scores
A vector index for very large document sets
Exposing indexed files as MCP resources
Contributions are welcome. Open an issue to discuss an idea first.
License
Available Tools
4 toolsindex_folderAIdempotent
Indexes the documents in a folder and its subfolders (Markdown, text and PDF files) so they can be searched with search_docs. Files that haven't changed since the last run are skipped, and files that were deleted are removed from the index.
Inputs: path (required).
list_sourcesARead-only
Lists the files in the index, with their number of chunks and when they were last indexed.
Inputs: no named parameters.
remove_from_indexADestructiveIdempotent
Removes a file, or every file inside a folder, from the index. Files on disk are not touched.
Inputs: path (required).
search_docsARead-only
Searches the indexed documents by meaning and returns the most relevant passages, with their file and section. Use it to answer questions from the user's own documents, and cite the files you used.
Inputs: query (required), topK, folder.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 4 tools
Each tool maps to a distinct operation in the RAG lifecycle: indexing, searching, listing, and removing. There is no overlap between them, and the descriptions explicitly cross-reference each other (index_folder mentions search_docs) to reinforce boundaries.
All four names are snake_case with a leading verb and a noun object, giving a predictable pattern. The only minor deviation is remove_from_index, which uses a prepositional phrase rather than a direct object, though it remains immediately readable.
Four tools is exactly right for a small document-RAG server: ingest, query, inspect, and delete. Each tool earns its place with no redundant or filler operations.
The surface covers the full index lifecycle (create, query, list, delete) with sensible details like incremental re-indexing and folder-level removal. A minor gap is the absence of a tool to fetch a full document or chunk by id, forcing agents to rely solely on search snippets.
Maintenance
Related MCP Connectors
Search and reason over your Obsidian-style Markdown vault, right from ChatGPT.
Personal context for every AI: search, read, and write back to your private Markdown library.
Your own memory inside ChatGPT and Claude, with the source of every note.
Long-term memory for Claude, ChatGPT, Cursor: search, save and organize notes, links, docs, videos.
Related MCP Servers
- AlicenseNot gradedqualityNot gradedmaintenanceTurns Claude Desktop into a personal document question-answering system using local vector search. Index PDF, TXT, and Markdown documents into collections and get answers based strictly on your documents with zero hallucination.10 npm-
- FlicenseNot gradedqualityBmaintenanceEnables storing and searching personal notes, documents, and snippets using semantic search and RAG capabilities across Claude Desktop, VS Code, and Open WebUI.2-
- AlicenseAqualityAmaintenanceEnables local semantic search over documents and code for Claude Code and Claude Desktop, running entirely offline with local embeddings and vector storage.147MIT
- AlicenseNot gradedqualityDmaintenanceEnables Claude Code to index and semantically search through PDFs, code, and documents with exact citations and zero hallucinations.MIT