Docs-to-AI
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Docs-to-AI: local RAG to search local PDFs, Word files, and any folder
Docs-to-AI is a local RAG (retrieval-augmented generation) server for your own documents. It indexes one folder tree of PDFs, Word files, spreadsheets, Markdown, PowerPoint, HTML, TXT, and CSV, and hands the index to any LLM that speaks MCP. The LLM searches the index and answers with quotes from your files.
The recommended way to run it is the Docker image, which serves MCP over HTTP on port 38777. Start the container once and every MCP client on your network can use it. A local Python install is also supported for development and for stdio-only clients.
No cloud service and no API key are involved. The embedding and re-ranking models run on the same machine, so no document text leaves it.
Supported extensions: .pdf, .docx, .doc, .xlsx, .xls, .xlsam, .xlsb, .md, .pptx, .html, .htm, .txt, and .csv.
Contents
Docs-to-AI: local RAG to search local PDFs, Word files, and any folder
What you can do with it
Search local PDFs and other files with natural language.
Find exact phrases, invoice numbers, ticket IDs, and product codes in PDFs.
Search your files from Claude Desktop or any other MCP client.
Point the server at one folder and get a topic for every subfolder.
Filter results by topic, date range, phrase, or regex.
Search scanned PDFs. Pages without a text layer are read with OCR automatically.
Keep the index current with a folder watcher.
Run a fully offline documents RAG: the embedding and re-ranking models run locally.
Related MCP server: Antigravity PDF MCP Server
Quick start: Docker with HTTP
You need Docker Desktop or Docker Engine. Budget about 5 GB of disk: the image already carries the embedding and re-ranking models, and the index grows on top of that. Disk space breaks the figure down.
1. Put your documents in ./my-docs
Create a folder called my-docs next to the compose file and copy your documents into it. Subfolders become topics, so my-docs/contracts/lease.pdf is indexed under the topic contracts. The container mounts this folder read-only.
2. Save the compose file
Save this as docker-compose.yaml next to my-docs:
services:
docs-to-ai:
image: dmeric/docs-to-ai
container_name: docs-to-ai
volumes:
- ./cache/chromadb:/app/cache/chromadb # vector store
- ./cache/doc_cache:/app/cache/doc_cache # extracted text
- ./my-docs:/app/my-docs:ro # your documents, read-only
- ./logs:/app/logs # server.log and detail.jsonl
# only needed for stdio over `docker exec` (see Connect an MCP client)
stdin_open: true
tty: false
environment:
- MCP_TRANSPORT=http # serves http://localhost:38777/mcp
- MCP_HOST=0.0.0.0
- MCP_PORT=38777
- LOG_DIR=/app/logs # server.log and detail.jsonl
ports:
- "${MCP_PORT:-38777}:${MCP_PORT:-38777}"
restart: unless-stopped
## Uncomment to enable GPU acceleration on an Nvidia GPU.
# deploy:
# resources:
# reservations:
# devices:
# - driver: nvidia
# count: all # or device_ids: ['0'] to pin one GPU
# capabilities: [gpu]The image is published on Docker Hub as dmeric/docs-to-ai. The repository ships its own docker-compose.yml, which is the same service plus a build: block, all build args, and a comment on every setting. Use that file when you want to build the image yourself as mcp/docs-to-ai, for example to change build args or run unreleased code after docker compose build.
3. Start the container
docker compose up -dNote on GPU usage:he GPU host needs an NVIDIA driver, R580 or newer (the normal GeForce driver on Windows): the image ships a CUDA 13 PyTorch build. On Linux it also needs the NVIDIA Container Toolkit (nvidia-container-toolkit). Docker Desktop needs the WSL2 based engine, which is the default. No CUDA toolkit install is needed, because the image already ships the CUDA-enabled PyTorch wheel. GPU inside Docker shows the reservation file in full, the log check, and the .env alternative.
Either way, the container keeps running and serves MCP at http://localhost:38777/mcp. The log line names every address a client can use:
2026-11-27 13:56:18 SUCCESS ✅ [MCP Server] Listening on 0.0.0.0:38777/mcp
From inside the container or machine: http://172.23.0.2:38777/mcp
From this Docker host or a browser on it: http://localhost:38777/mcp
From another machine: http://<host-ip>:38777/mcp4. Connect your MCP client
Point the client at the HTTP endpoint:
{
"mcpServers": {
"docs-to-ai": {
"url": "http://localhost:38777/mcp",
"transport": "http"
}
}
}Some clients want "type": "http" instead of "transport": "http". Use whichever key your client documents. From another machine, replace localhost with the host's IP address. Connect an MCP client covers the alternatives, including clients that only speak stdio.
5. Confirm the first scan
A fresh container has an empty index, so the server scans /app/my-docs at startup even though FULL_SCAN_ON_BOOT defaults to False. A 500-chunk corpus takes several minutes to embed on CPU. Watch the progress, and check that the mount actually contains your files:
docker exec docs-to-ai ls /app/my-docs # must list your files
docker logs -f docs-to-ai # shows the scan progressOnce the scan reports chunks, ask the LLM in your client: "What documents do you have access to?". The answer comes from list_all_documents, so it proves the index is reachable.
To re-index later, ask the LLM to call scan_all_my_documents, or run it yourself:
docker exec docs-to-ai uv run --no-sync python -m app.scan_all_my_documents --doc-dir /app/my-docsThe folder watcher runs at startup by default (FOLDER_WATCHER_ACTIVE_ON_BOOT=True), so a file you drop into ./my-docs is indexed after DEBOUNCE_SECONDS without any further action.
Docker reference
Volumes and ports
Four bind mounts hold everything that must survive a container rebuild:
Host path | Container path | Why it matters |
|
| The vector store. Without this mount the index is rebuilt on every container start. The path must match what the app reads: |
|
| Extracted text per document, so a second scan skips the parsing and the OCR. |
|
| Your documents. Mount it |
|
|
|
Port 38777 publishes the HTTP endpoint for MCP clients. Keep the host port and MCP_PORT equal; if you publish a different host port, set MCP_PUBLIC_URL so the startup banner and the tool output show the address clients should use.
To index a folder that is not ./my-docs, add a second mount and point DOCS_DIR at it inside the container:
volumes:
- ./contracts:/app/contracts:ro
environment:
- DOCS_DIR=/app/contractsChange settings without rebuilding
The compose file passes every setting to the container as ${SETTING:-default}, so a value in .env changes both the build args and the runtime environment. Copy .env.example, or add lines with echo:
echo "FULL_SCAN_ON_BOOT=True" > .env
echo "FOLDER_WATCHER_ACTIVE_ON_BOOT=True" >> .env
echo "CHUNKING_STRATEGY=by_paragraph" >> .env # cheaper than the semantic default
echo "CHUNK_SIZE=512" >> .env
docker compose up -dThe container does not read .env itself: Compose substitutes the values into the service definition. Transport, logging, OCR, and every other setting from Configuration can be changed this way, and a restart applies them without a rebuild.
Frequent runtime settings:
Setting | Effect | Default |
| Re-index every document at server start |
|
| Watch the documents folder and index changes at server start |
|
| Port for the HTTP transport, inside the container and on the host |
|
| Folder inside the container that is scanned for documents |
|
| Texts embedded per batch; lower it when the machine runs out of memory |
|
|
|
|
| Where Marker keeps its OCR models, for example | empty |
Build args and model baking
Build args bake values into the image. They exist because the build pre-downloads models: the embedding model, the re-ranker, and the tiktoken data must match the settings the container will run with. A runtime environment variable always overrides a baked value, so most build args only matter when you want a different model or OCR engine inside the image.
docker compose build --build-arg CHUNKING_STRATEGY=by_paragraph --build-arg CHUNK_SIZE=512
docker compose up -dPlain docker build works the same way:
docker build --build-arg EMBEDDING_MODEL=Qwen/Qwen3-Embedding-0.6B --build-arg USE_RERANKER=True -t mcp/docs-to-ai .The model, chunking, search, OCR, and startup settings are build args. The transport (MCP_*), logging (LOG_*), DOCS_DIR, and EMBEDDING_QUERY_PROMPT are runtime-only.
Rebuild the image after changing EMBEDDING_MODEL or USE_RERANKER, because those models are downloaded during the build. Chunking and search settings need a re-scan instead, not a rebuild.
Scanned PDFs need the optional OCR engine, which the default image does not include:
docker compose build --build-arg INSTALL_MARKER=TrueThat adds Marker, its PyTorch build, and the OCR models to the image: about 110 MB of models for the default fast mode. Leave it out if you only index files that already carry text. Without it the container logs one warning and scanned pages stay empty. MARKER_MODE=balanced and vllm also need vllm and an NVIDIA GPU inside the container, so build those images from a base that has vllm.
Changing EMBEDDING_MODEL, EMBEDDING_DIMENSION, or CHROMA_SPACE forces a new collection, because ChromaDB cannot change the vector size or the distance space in place. The server records the model name and dimension in the collection metadata, detects a stale collection at startup, and recreates it. Re-scan after the recreate:
docker exec docs-to-ai uv run --no-sync python -m app.scan_all_my_documents --doc-dir /app/my-docs --resetThe vector store is a cache built from your documents, so a recreate never touches the source files.
GPU inside Docker
A container sees only the GPUs that Docker passes to it. Without a device reservation the log says No GPU is visible inside this container, even when the host has a GPU.
A host without a GPU fails docker compose up as soon as the reservation is active, so docker-compose.yml ships the block commented out under # Uncomment to enable GPU acceleration on an Nvidia GPU. Uncomment it on a GPU host, or keep the base file untouched and merge the override file instead:
docker compose -f docker-compose.yml -f docker-compose.gpu.yml up -dIf you followed step 3 with the pull-image compose file, the same block is saved there as docker-compose.gpu.yaml, so use that file name instead.
To keep plain docker compose up -d working, add one line to .env. The separator is ; on Windows and : on Linux and macOS.
COMPOSE_FILE=docker-compose.yml;docker-compose.gpu.yml # Windows
COMPOSE_FILE=docker-compose.yml:docker-compose.gpu.yml # Linux/macOSdocker-compose.gpu.yml only adds the device reservation:
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: all # or device_ids: ['0'] to pin one GPU
capabilities: [gpu]Requirements:
An NVIDIA driver on the host, R580 or newer, because the image ships a CUDA 13 PyTorch build. On Windows that is the normal GeForce driver.
On Linux, the NVIDIA Container Toolkit (
nvidia-container-toolkit).On Docker Desktop for Windows, the WSL2 based engine, which is the default. Do not switch to Hyper-V.
The CUDA toolkit is not required: the image already contains the CUDA-enabled PyTorch wheel and its CUDA libraries, so no rebuild is needed either. The container's PyTorch reports the CUDA version it was built for:
docker compose exec docs-to-ai uv run --no-sync python -c "import torch; print(torch.__version__, torch.version.cuda, torch.cuda.is_available(), torch.cuda.device_count())"
docker compose exec docs-to-ai nvidia-smi # driver and GPU list, once the container runs
docker compose logs | grep "Compute device"Expected log line: Compute device: cuda:0 (NVIDIA GeForce RTX 5090, 32 GB VRAM).
A plain docker run needs --gpus all, and because the entrypoint is the MCP server itself, any other command has to go through --entrypoint: docker run --rm --gpus all --entrypoint nvidia-smi mcp/docs-to-ai. Without --gpus all the container starts on CPU. GPU acceleration covers the settings and the measured speed-up.
Connect an MCP client
MCP_TRANSPORT selects how clients talk to the server, and one transport runs per process:
Transport | Endpoint | Use it for |
|
| Docker and any long-running server. This is what the compose file sets. |
| no port, stdin and stdout | A client that starts the process itself, or |
|
| Older HTTP clients that need Server-Sent Events. |
HTTP transport
The container already serves HTTP, so the client only needs a URL:
{
"mcpServers": {
"docs-to-ai": {
"url": "http://localhost:38777/mcp",
"transport": "http"
}
}
}Some clients want
"type": "http"instead of"transport": "http". Use whichever key your client documents.From another machine, replace
localhostwith the host's IP address, and make sure the port is reachable through the host firewall.Any number of clients can share one container, and they share one index.
Do not put
docker run -i --rm dmeric/docs-to-aiin a client config.docker runstarts a fresh container for every connection, with no volumes and no index, so the client sees an empty document folder and re-scans from scratch each time.
stdio inside the running container
A client that only speaks stdio can run the server inside the running container. This reuses the same container, mounts, and index:
{
"mcpServers": {
"docs-to-ai": {
"command": "docker",
"args": ["exec", "-e", "MCP_TRANSPORT=stdio", "-i", "docs-to-ai", "uv", "run", "--no-sync", "python", "mcp_server.py"]
}
}
}Two details matter here. The command goes through uv run, because the image keeps its packages in a virtualenv. It also sets MCP_TRANSPORT=stdio, because the container already owns the HTTP port. The container has to be running before the client connects.
SSE clients
Older clients use http://localhost:38777/sse with "transport": "sse". Start the server with MCP_TRANSPORT=sse (or --sse) if the client cannot use the /mcp endpoint.
The URL printed at startup
With http or sse, startup prints every address a client may need:
2026-11-27 13:56:18 SUCCESS ✅ [MCP Server] Listening on 0.0.0.0:38777/mcp
From inside the container or machine: http://172.23.0.2:38777/mcp
From this Docker host or a browser on it: http://localhost:38777/mcp
From another machine: http://<host-ip>:38777/mcpSet MCP_PUBLIC_URL when the host port differs from MCP_PORT, or when a proxy sits in front of the server:
MCP_PUBLIC_URL=http://myserver.lan:8080/mcpClaude Desktop with a local Python install
A local install has no HTTP port unless you start one, so Claude Desktop usually launches it over stdio:
{
"mcpServers": {
"docs-to-ai": {
"command": "python",
"args": ["C:/[UPDATE_PATH_TO_DOCS-TO-AI]/docs-to-ai/mcp_server.py"]
}
}
}To use a locally started HTTP server instead, start it with MCP_TRANSPORT=http (or --http) and use the same URL config as HTTP transport.
How search works
Documents (PDF, Word, Excel, Markdown, PowerPoint, HTML, TXT, CSV)
→ text extraction (scanned PDF pages go through OCR)
→ chunking (semantic by default, 1024 tokens)
→ embeddings (Qwen3-Embedding-0.6B, 1024-dim)
→ ChromaDB (cosine HNSW, topic tags on every chunk)
↓
hybrid retrieval: BM25 + dense → RRF → cross-encoder re-rank
↓
MCP tools → Claude or any MCP clientDense vectors catch meaning, BM25 catches exact strings, RRF merges both ranked lists, and a cross-encoder re-scores the merged candidates. Documents are parsed once at index time, so a search only touches the index. Retrieval pipeline walks through the five stages, and Production RAG settings explains why each stage is configured the way it is.
Folder topics: how to search a folder
The server maps folders to topics, and a topic narrows a search. One folder tree becomes one browsable index.
Each folder name becomes a topic.
Nested folders become nested topics, joined with
>.Files with the same name in different folders stay separate, so two
introduction.pdffiles do not overwrite each other.
my-docs/
├── Machine_Learning/
│ ├── neural_networks.pdf
│ └── introduction.pdf
├── Python_Programming/
│ ├── basics.pdf
│ └── introduction.pdf # separate document, separate topic
└── Data_Science/
└── statistics.pdfMCP tools
Search and discovery:
search_documentsruns hybrid search over all documents. Filters:topic,phrase_search,date_from,date_to,regex_pattern.list_all_documentslists every indexed document, grouped by first topic. Filter withtopic.list_topiclists the documents of one topic (folder), including its subfolders, with the full path of each file. It acceptslegal,legal > contracts, orlegal/contracts, and falls back to matching the folder name at any depth.list_topicslists topics.get_collection_statsreports chunk counts, document counts, file types, and index details.
Read documents in full:
read_file_metadatareturns one document's metadata: path, topics, type, size, created and last-modified dates, chunk count, page numbers with chunks, OCR pages, and whether the file changed on disk since the last scan.read_filereturns one document's whole text, page by page, with the same metadata block. Usepageto read a single page andmax_charsto cap the response. The text is re-read from the source file, so it is complete even when the chunks are split; if the file is gone, the text is rebuilt from the indexed chunks and the response says so.read_multiple_filestakes a list of names and returns the same metadata and text for each one as a JSON list.max_charscaps the text of each file. A name that does not resolve comes back as an entry with anerrorfield, so one miss does not hide the rest.read_file_rawreturns the original file as a base64 string, with MIME type, byte count, and SHA-256, so the client can save or forward the real PDF, DOCX, or image.max_bytesdefaults to 1 MB because base64 inflates a file by a third; raise it to fetch something bigger.
All four reading tools take the same document names: a filename, a full path, or part of either, as shown by list_all_documents or list_topic. If a name matches more than one document, the tool answers with the candidates instead of guessing.
Document management:
scan_all_my_documentsre-indexes the document folder.start_watching_folderstarts the folder watcher.stop_watching_folderstops the folder watcher.get_time_of_last_folder_scanreports the last scan time and the next full scan.
Example questions for the LLM
Find something in a PDF:
"What documents do you have access to?"
"Which file mentions the payment terms?"
"Find the exact phrase 'net 30 days' in my PDFs."
"Show me the page where invoice INV-2026-0042 appears."
Read a whole document:
"Show me the full text of the UzKor K-sure policy."
"How big is the Commercial Terms Agreement, and when was it last changed?"
"Send me the actual Investment Agency Agreement file."
"Read the Commercial Terms Agreement and the Investment Agency Agreement together."
Search a folder by topic:
"Search the Python_Programming topic for decorators."
"List all documents under Machine_Learning, including subfolders."
"Find data visualization notes in Data_Science."
Narrow a search with filters:
"Search for 'neural networks' as an exact phrase."
"Find Python documents modified after 2024-01-01."
"Search for items matching
\d{3}-\d{4}."
Keep the index fresh:
"Scan all my documents."
"Start watching my documents folder."
"When was the last scan?"
"Stop watching the folder."
Install with local Python
A local install runs the same server outside Docker. It uses uv for Python packages.
Install uv:
# macOS / Linux
curl -LsS https://astral.sh/uv/install.sh | sh
# Windows
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"Install dependencies, index ./my-docs, and start the server:
uv sync # install dependencies
python -m app.scan_all_my_documents # index ./my-docs
python mcp_server.py --http # serve MCP at http://localhost:38777/mcpWindows helper scripts sit in the repo root: 1.setup-python-env.ps1, 2.scan-all-my-documents-in-python.ps1, 3.run-mcp-server-in-python.ps1.
The first scan downloads the embedding model (about 1.2 GB) and the re-ranker (about 90 MB). Pre-download both with python -m app.download_models. Disk space lists every model, its size, and the total a setup needs.
Scanned PDFs are read by Marker, which is optional: without it every other file type still indexes.
uv sync --extra marker # adds marker-pdf, its torch build, and the OCR modelsThe fast mode needs no extra server and downloads about 110 MB of models on first use. balanced and vllm need vllm (NVIDIA GPU) or llama.cpp; see OCR for scanned PDFs.
Checking the install: python mcp_server.py --show-config prints the effective settings, including OCR_STATUS=ready (Marker ...) once Marker and its models are reachable.
Scan options
python -m app.scan_all_my_documents --doc-dir ./my-docs # index another folder
python -m app.scan_all_my_documents --reset # wipe the index, then re-indexThe scan walks the folder tree, derives topics from folder names, extracts and chunks the text of each file, and stores every chunk in ChromaDB with its topic tags.
Example output:
Found 15 PDF files
Base directory: /path/to/pdfs
Detected topics: Data_Science, Machine_Learning, Python_Programming
[1/15] Processing: neural_networks.pdf
Topic: Machine_Learning
✓ Added 45 chunks
INGESTION SUMMARY
==================
Total PDFs processed: 15
Successful: 15
Failed: 0
Total chunks added: 523Inside Docker, run the same command through the container:
docker exec docs-to-ai uv run --no-sync python -m app.scan_all_my_documents --doc-dir /app/my-docsTransports and command-line flags
python mcp_server.py --http --host 0.0.0.0 --port 38777 # same as MCP_TRANSPORT=http
MCP_TRANSPORT=http MCP_PORT=38777 python mcp_server.py
MCP_TRANSPORT=sse python mcp_server.py --port 38777
python mcp_server.py # stdio, the local default--websocket still works as an alias for --http. --show-config prints the effective configuration and exits, and --help prints every setting with its default. Server transport lists the transport settings, and Connect an MCP client shows the matching client config.
Configuration
Every setting has a default, and you can override any of them without editing code. Values are resolved in this order:
Environment variables win over everything. Example:
CHUNKING_STRATEGY=semantic python mcp_server.py.A
.envfile next topyproject.tomlsets values for one machine. Real environment variables still win. Copy .env.example and edit it: each line ends with a comment that gives what the setting does, the valid options, and the default. Inline#comments work, and a value with spaces needs quotes, for exampleTOPIC_SEPARATOR=" > ".Docker build args bake defaults into an image. Most build args are also passed to the container as runtime variables when it starts, so a
.envline changes both. See Build args and model baking.
Print the effective values with python mcp_server.py --show-config (in Docker: docker exec docs-to-ai uv run --no-sync python mcp_server.py --show-config). Print every setting and default with python mcp_server.py --help.
Chunking
Setting | Env var | Default | Description |
Strategy |
|
|
|
Chunk size |
|
| Tokens per chunk ( |
Chunk overlap |
|
| Overlap between chunks, same unit as |
Token chunking |
|
| Measure chunk sizes in tokens instead of characters |
Tokenizer |
|
| tiktoken tokenizer ( |
Preserve headings |
|
| Split on headings, keep the heading in each chunk |
Max heading chunk |
|
| Max size per heading chunk, same unit as |
Min chunk size |
|
| Drop fragments below this size |
Semantic chunking is the default. The chunker embeds consecutive sentences and cuts where the sentence similarity drops below a percentile. The sizes below are always token counts.
Setting | Env var | Default | Description |
Split percentile |
|
| Similarity percentile that becomes a cut point (0-100) |
Min size |
|
| Minimum tokens per chunk |
Max size |
|
| Maximum tokens per chunk, hard split above this |
Buffer size |
|
| Neighbouring sentences averaged when computing similarity |
Pick a chunking strategy for your corpus:
semanticgives the most coherent chunks. Ingest is slower because every sentence is embedded.by_paragraphcosts the least. Published tests find paragraph chunking matches semantic chunking up to about 5k tokens.semantic_headingkeeps document structure and splits long sections atMAX_HEADING_CHUNK_SIZE.fixed_sizeslices atCHUNK_SIZEand ignores structure.
Token counts come from tiktoken, not from the embedding model tokenizer, so the two differ by a small margin.
OCR for scanned PDFs
A scanned PDF stores a picture of each page, not text. Text extraction finds nothing and the page would be indexed empty. When a page's text layer holds fewer than OCR_MIN_TEXT_CHARS characters, that page is read by Marker, which runs layout analysis before OCR, so multi-column scans, tables, and forms come back in reading order. The recognised text is indexed like any other text, and each chunk records that it came from OCR, so results and read_file mark those pages (OCR).
Marker is an optional dependency because it brings its own PyTorch build and models:
uv sync --extra marker # local install
docker compose build --build-arg INSTALL_MARKER=True # DockerWithout it the server still runs: every other file type indexes, and one warning says how to install Marker.
Setting | Env var | Default | Description |
OCR on |
|
| Read pages that have no usable text layer |
Scan threshold |
|
| A page below this many characters is treated as a scan |
Pages per document |
|
| Ceiling on scanned pages read per document; |
Marker mode |
|
|
|
Marker device |
| empty |
|
Model cache |
| empty |
|
Marker modes, from Marker's own benchmarks:
Mode | Hardware | Speed | Best for |
| CPU or GPU, in-process ONNX | ~7 pages/s mixed | Everyday scans. No |
| GPU, needs | ~17 pages/s | Tables, maths, and difficult scans |
| GPU, needs | ~4.5 pages/s | Degraded scans, handwriting, dense formulas |
| any | fastest | Text-layer PDFs only; scans are skipped |
How it behaves:
Only pages that need it are read. A PDF with a text layer costs nothing extra, and a mixed PDF hands Marker just its scanned pages (Marker's
page_range).Blank pages are skipped, because a page with no image and no drawing has nothing to read.
Every scanned page is read by default:
OCR_MAX_PAGES=9999is no practical limit, and the setting stays as a ceiling for pathological files. When a document hits it, the log says how many pages were left.OCR_MAX_PAGES=0turns OCR off.OCR runs once per document. The extracted text lands in
cache/doc_cache, so later scans andread_filereuse it.Turning OCR on, or changing
MARKER_MODE,OCR_MIN_TEXT_CHARS, orOCR_MAX_PAGES, makes the cached text of PDFs stale. The next scan re-reads those PDFs, so previously empty scans fill in. Other file types keep their cached text.MARKER_MODE=balancedorvllmwithoutvllmor allama-serverbinary is reported at startup instead of failing mid-scan.Models live in the Hugging Face cache (about 110 MB for
fast). SetMARKER_MODEL_CACHEto keep them on a mounted volume, or bake them into a Docker image by building withINSTALL_MARKER=True.Reading runs at index time, not at search time.
fastreads a page in well under a second on CPU after the models load, and the first document of a run pays a few seconds for model loading.
The log reports the outcome per document:
[OCR] OCR is available: Marker 2.2.0, mode fast, device cpu
[OCR] Marker read 12 page(s) of contract.pdf in 2.4s (0.2s per page)
[OCR] OCR read 12 of 20 scanned page(s) in contract.pdf
[OCR] contract.pdf: OCR stopped after OCR_MAX_PAGES=10 page(s), so 8 more scanned page(s) stay empty.Search
Setting | Env var | Default | Description |
Default results |
|
| Results returned when the client asks for no count |
Max results |
|
| Hard cap on results per search |
Re-ranker |
|
| Re-score fused candidates with a cross-encoder |
Re-ranker model |
|
| Cross-encoder model name |
Re-rank candidates |
|
| Candidates passed to the re-ranker |
Hybrid search |
|
| Merge a BM25 ranking with the dense ranking |
BM25 weight |
|
| RRF weight of the BM25 list, |
BM25 k1 |
|
| BM25 term-frequency saturation |
BM25 b |
|
| BM25 length normalisation (0-1) |
RRF k |
|
| Reciprocal Rank Fusion constant |
On CPU, re-ranking 50 candidates costs about 1.8 s per search, so lower RERANKER_TOP_N when a search feels slow. Raise EMBEDDING_BATCH_SIZE to 64 or 128 on a GPU and keep the default 32 on CPU.
Embedding model
Setting | Env var | Default | Description |
Model |
|
| Sentence-transformer model, 1024-dim, 32K context |
Dimension |
|
| Vector dimension, must match the model |
Batch size |
|
| Texts encoded per batch |
Query prompt |
| empty | Instruction prefix for queries. Empty uses the model query prompt, which Qwen3 ships |
Models cache in the Hugging Face cache (~/.cache/huggingface). python -m app.download_models pre-downloads the embedding model, the re-ranker, and the tiktoken encoding. The Docker image does this at build time.
GPU acceleration
Embedding is the expensive step. The embedding model and the cross-encoder go on a GPU automatically when a usable device exists.
Setting | Env var | Default | Description |
GPU if available |
|
| Use CUDA or Apple MPS when detected, otherwise CPU |
GPU index |
|
| Which CUDA GPU to use, |
Accelerated: dense embeddings for indexing, query encoding, the per-sentence passes of semantic chunking, and cross-encoder re-ranking.
Not accelerated: BM25 scoring (pure Python) and the local ChromaDB HNSW index (CPU only).
Measured on an RTX 5090 against a 16-core CPU, same models, batch size 32, bf16:
Workload | CPU | GPU | Speed-up |
Embedding 32 chunks at about 530 tokens each | 15.5 s | 0.42 s | 37× |
Semantic chunking, 200 sentences | 8.9 s | 0.23 s | 38× |
One search query, batch 1 | 114 ms | 30 ms | 3.8× |
Re-rank 50 candidates | 1810 ms | 36 ms | 50× |
Device selection order:
USE_GPU_ACCELERATION_IF_AVAILABLE=Falseforces CPU.CUDA present:
cuda:<GPU_DEVICE_INDEX>. An out-of-range index logs a warning and uses GPU 0.Apple Silicon:
mps.No accelerator: CPU.
The chosen device is probed with a small allocation, so a CUDA build that cannot run on the installed driver falls back to CPU. Startup prints the device: Compute device: cuda:0 (NVIDIA GeForce RTX 5090, 32 GB VRAM). python mcp_server.py --show-config prints the DEVICE= line.
# force CPU on a GPU machine
USE_GPU_ACCELERATION_IF_AVAILABLE=False
# use the second GPU
GPU_DEVICE_INDEX=1GPU acceleration needs a CUDA-enabled PyTorch build. The CPU wheel reports no CUDA devices, so install a matching wheel:
uv pip install --index-url https://download.pytorch.org/whl/cu128 torch # cu128 for RTX 50xx and newer
python -c "import torch; print(torch.__version__, torch.version.cuda, torch.cuda.is_available(), torch.cuda.device_count())"In Docker the CUDA wheel is already installed and the container only needs the device reservation; see GPU inside Docker.
Topics
Setting | Env var | Default | Description |
Folder as topic |
|
| Build topic tags from folder names |
Default topic |
|
| Topic for documents outside known folders |
Separator |
|
| Separator for nested topics |
Storage
Setting | Env var | Default | Description |
Vector DB dir | none |
| ChromaDB location |
Doc cache dir | none |
| Extracted-text cache location |
Documents dir |
|
| Folder scanned for documents ( |
Collection name |
|
| ChromaDB collection name |
Distance space |
|
| HNSW space: |
ef_search |
|
| HNSW query candidate list size, ChromaDB default is 100 |
ef_construction |
|
| HNSW build candidate list size, ChromaDB default is 100 |
The index uses cosine space, because the embedding model returns normalised vectors and cosine matches normalised vectors. ChromaDB defaults to l2, which fits them poorly. ef_search=200 raises recall at query time and can be changed at runtime. ef_construction only affects newly built index segments.
In Docker the two cache folders are the bind mounts from Volumes and ports, and they cannot be moved with an environment variable.
Startup behaviour
Setting | Env var | Default | Description |
Full scan on boot |
|
| Re-index every document at server start |
Watcher on boot |
|
| Start the folder watcher at server start |
Debounce |
|
| Idle time after the last file change |
Full scan interval |
|
| Days between automatic full rescans |
An empty index is scanned at startup even when FULL_SCAN_ON_BOOT=False, so a fresh container indexes its documents without extra configuration.
Server transport
Setting | Env var | Default | Description |
Transport |
|
|
|
Host |
|
| HTTP bind address |
Port |
|
| HTTP port |
Public URL |
| empty | Address printed at startup and used for client instructions |
MCP_HOST=127.0.0.1 binds inside the container only, so the host cannot connect. Keep 0.0.0.0 unless you bind the port to loopback in the compose file.
Example .env
CHUNKING_STRATEGY=semantic # embedding-based semantic chunking
CHUNK_SIZE=1024 # tokens per chunk when CHUNK_BY_TOKEN=True
CHUNK_OVERLAP=100 # lower overlap, cheaper indexing
USE_BM25=True # BM25 + dense, fused with RRF
BM25_WEIGHT=0.3 # 0.5 gives equal weight
USE_RERANKER=True
DEFAULT_SEARCH_RESULTS=8
USE_GPU_ACCELERATION_IF_AVAILABLE=True
GPU_DEVICE_INDEX=0
OCR_ENABLED=True # read scanned PDFs with Marker
OCR_MAX_PAGES=9999 # ceiling per document; 0 turns OCR off
MARKER_MODE=fast # fast needs no extra backend; balanced/vllm need vllmThe same file works for Docker and for a local install. In Docker, Compose substitutes these values into the service definition; locally, mcp_server.py reads the file itself.
Disk space
The code is small. The models are not: several neural models run locally, and together they need more disk than everything else combined. Budget about 2.8 GB for a CPU install with OCR, and 7 to 16 GB for a GPU install, depending on how much accuracy you ask Marker for. That is a one-time cost per machine, and the index and the extraction cache grow with your corpus on top of it.
Models
Model | What it does | Download |
| Embeds chunks and queries, and the per-sentence passes of semantic chunking. 1136 MB of weights, plus tokenizer files | 1.2 GB |
| Re-scores the fused search candidates | 0.09 GB |
| Counts tokens so a chunk really is 1024 tokens | 2 MB |
| Marker | 0.12 GB |
| Marker | 1.3 GB |
Surya layout, text-detection, and OCR-error checkpoints | Page layout and OCR confidence for Marker | ~0.3 GB |
A base install (embedding, re-ranker, tokenizer) is 1.3 GB of models. Marker fast adds 0.12 GB, because it runs its own small ONNX models and needs no VLM. Marker balanced or vllm adds about 1.6 GB of models and needs vllm (several GB of wheels) or llama.cpp on top.
Weights download on first use and stay cached:
Linux/macOS:
~/.cache/huggingfaceWindows:
%USERPROFILE%\.cache\huggingfaceMarker's models follow
MARKER_MODEL_CACHEwhen it is set (HF_HOME), so they can live on another volume.
Nothing re-downloads after that. python -m app.download_models fetches everything up front, which is what the Docker build does.
Python packages
Setup | What is installed | Disk |
CPU, no OCR | torch (CPU), transformers, chromadb, fastmcp, sentence-transformers | ~1.2 GB |
CPU with Marker | the above, plus Marker, Surya, ONNX runtime, torch 2.15 | ~1.4 GB (measured) |
GPU | the CUDA torch wheel and its CUDA libraries instead of the CPU wheel | 5.5-6.5 GB |
GPU with | plus | +5 to 7 GB |
Totals
Setup | Packages | Models | Total |
CPU, text-layer PDFs only ( | 1.2 GB | 1.3 GB | ~2.5 GB |
CPU with Marker | 1.4 GB | 1.4 GB | ~2.8 GB |
GPU with Marker | 5.5-6.5 GB | 1.4 GB | ~7-8 GB |
GPU with Marker | 11-13 GB | 2.9 GB | ~14-16 GB |
The GPU ranges are wide because the CUDA PyTorch wheel and vllm differ per CUDA version. Measure your own install with du -sh .venv ~/.cache/huggingface (Get-ChildItem -Recurse | Measure-Object Length -Sum on Windows).
Leave a couple of GB free while the models download, because the largest file (1.3 GB) is written to a temporary name before it is moved into the cache.
In Docker the embedding model, the re-ranker, and the tokenizer data are baked into the image at build time, which is why the image is about 2.5 GB before the OCR engine and about 3 GB with INSTALL_MARKER=True. Baked models keep docker compose up from downloading anything. To keep the image small instead, mount a volume for the Marker models and let them download once:
volumes:
- ./cache/marker:/app/cache/marker
environment:
- MARKER_MODEL_CACHE=/app/cache/markerThe index and the cache grow with your documents
Folder | What grows | Measured |
| One vector (1024 floats = 4 KB) plus the chunk text and metadata, plus the HNSW graph | 18 MB for 514 chunks, about 35 KB per chunk |
| The extracted text of each document, so a re-scan skips the parse | Typically 10-30% of the source documents' size |
A rough guide for the vector store: 1 GB per 30,000 chunks, so 10,000 average documents (about 100 chunks each) need around 35 GB. Removing documents does not shrink it, so run a scan with --reset, or delete cache/chromadb, to reclaim the space.
Retrieval pipeline
Dense search: encode the query with Qwen3-Embedding-0.6B, then query the HNSW index in cosine space with
ef_search=200. Queries use the model query instruction prompt.Sparse search: score the query with BM25 over the same chunks. BM25 finds IDs, ticket numbers, product codes, and names.
Fusion: merge both ranked lists with RRF,
score = Σ weight / (RRF_K + rank).BM25_WEIGHTsets the BM25 share.Filters: apply
topic,date_from,date_to,phrase_search, andregex_patternto the fused candidates.Re-rank: score up to
RERANKER_TOP_Ncandidates with the cross-encoder, and return the bestmax_results.
Search output lists topic, source file, page, and a relevance percentage. The percentage is 1 - cosine distance; non-cosine spaces print the raw distance instead.
Production RAG settings
The settings below come from 2026 production RAG research. The marked settings are the current defaults.
# | Recommendation | Status | Why |
1 | Upgrade the embedding model. | Done. Default is | Newer models retrieve better. MiniLM truncates long chunks at 256 tokens. |
2 | Add hybrid BM25 + dense retrieval, fuse with RRF. | Done. | Dense-only search misses exact strings. Hybrid adds about 7% nDCG. |
3 | Keep cross-encoder re-ranking over a wide candidate pool. | Done. | Re-ranking adds 15-30 points of precision@5. Test a reranker on your own corpus, because a generic reranker can hurt niche domains. |
4 | Reduce or drop chunk overlap. | Optional. | Overlap showed no measurable gain in 2026 studies and raised indexing cost. Keep overlap for legal clauses and tables. |
5 | Target 512-1024 tokens per chunk. | Done. | Quality drops past about 2.5k tokens. 512-1024 tokens works best. |
6 | Prefer paragraph or heading chunking. Treat semantic chunking as opt-in. | Overridden. The default is | Recursive chunking matches semantic chunking up to about 5k tokens at lower cost, and semantic chunking can over-fragment. |
7 | Add diversity (MMR) to result selection. | Not exposed as a setting. | MMR raised nDCG@5 by 4-11 points in 2026 benchmarks. |
8 | Tune ChromaDB HNSW for cosine space. | Done. |
|
9 | Add RAG evaluation to CI. | Not implemented. Use RAGAS with 50-100 curated samples and a fixed judge model. | Component metrics separate retrieval failures from generation failures. |
10 | Apply metadata filters before re-ranking. | Optional. The | Filters shrink the candidate pool before scoring. |
Not adopted: contextual retrieval and late chunking. Contextual retrieval runs about 120× slower at indexing, and neither gain is proven on small local corpora. Late chunking can hurt short passages.
Logs
Every line the server writes to stderr starts with a timestamp, a level, and an emoji. Docker shows these lines in docker logs, so a slow scan or a failed file is easy to spot.
2026-11-27 20:45:12 INFO [VectorStore] Loading re-ranker model: cross-encoder/ms-marco-MiniLM-L-6-v2 on cpu
2026-11-27 20:45:14 SUCCESS ✅ [FolderWatcher] Started watching: /app/my-docs
2026-11-27 20:45:14 INFO [FolderWatcher] 9 supported document(s) under /app/my-docs
2026-11-27 20:45:15 WARN ⚠️ [FolderWatcher] No supported documents in /app/my-docs.
2026-11-27 20:45:16 ERROR ❌ [VectorStore] The vector database at /app/cache/chromadb could not be opened.INFOrecords normal progress. No emoji.SUCCESS ✅records something that worked: a model loaded, a folder watched, chunks added.WARN ⚠️records a fallback or a partial problem. The work continues.ERROR ❌records a failure. The message carriesProblem,Cause, andFixlines.
Multi-line messages (scan reports, error explanations) are indented under their first line, so grep ERROR finds the whole block by its first line.
stdout stays clean, because it carries the MCP protocol and the CLI reports (--help, --show-config, scan reports). Log lines never go to stdout, so they cannot corrupt the MCP stream.
Log files
Two files sit in logs/ (/app/logs in Docker, bind-mounted to ./logs on the host):
File | Content |
| Every action of the server: startup, model loading, watcher events, scans, tool calls, searches, errors |
| One JSON object per line for the events needed to debug retrieval: |
ocr_document records what OCR did with one PDF: engine (marker), total_pages, the ocr_pages list with per-page characters, the pages still without text, the pages the OCR engine found nothing in, the pages skipped by OCR_MAX_PAGES, and the pages skipped as blank. Find the documents that needed the most OCR work with:
jq 'select(.event=="ocr_document") | {file, ocr_pages: (.ocr_pages|length), chars: ([.ocr_pages[].chars]|add), empty: (.pages_still_without_text|length)}' logs/detail.jsonlBoth files rotate by size: a full file is renamed to .1, .2, and so on, and the oldest file beyond LOG_BACKUP_COUNT is deleted.
Setting | Env var | Default | Description |
Log dir |
|
| Folder for both files. Docker uses |
Level |
|
|
|
Console |
|
| Also print to stderr, which |
Max size |
|
| Rotate a file after 10 MB |
Backups |
|
| Rotated files kept per log |
Detail log |
|
| Write |
Chunk text |
|
| Chunk text stored per result, |
Slow query |
|
| A search slower than this logs a |
Docker writes the files to the host because the compose file mounts ./logs and sets LOG_DIR=/app/logs. Without both lines the logs land in the container's own filesystem and vanish on the next docker compose down or image update:
volumes:
- ./logs:/app/logs
environment:
- LOG_DIR=/app/logsReading the detail log
One search record answers "why did the LLM get these chunks?". The record holds the query and the filters, the candidate count and the timing for every stage, and every returned chunk with its scores and text.
Every query also logs one line to server.log with the time of each step and the total response time, so a saturated server is visible at a glance:
2026-11-27 22:25:43 INFO [MCP] Search 'PD-ROT-77' -> ok, 1 chunk(s) in 111 ms (prep 0 | encode 80 | chroma 3 | bm25_build 1 | bm25 0 | fuse 0 | dense 83 | filters 0 | rerank 26 | format 0)
2026-11-27 22:26:07 INFO [MCP] Search 'PD-ROT-77 2' -> ok, 1 chunk(s) in 109 ms (...) [3 tool calls in flight]
2026-11-27 22:31:10 WARN ⚠️ [MCP] Search 'annual report' -> ok, 5 chunk(s) in 24500 ms (...) - over SLOW_QUERY_MSField | Meaning |
| Time to get the store and read the index size |
| Query embedding on the CPU or GPU |
| Vector search inside ChromaDB |
| Rebuilding the sparse index, |
| BM25 scoring |
| RRF fusion plus fetching sparse-only chunks |
|
|
| Phrase, date and regex filters |
| Cross-encoder re-ranking |
| Building the text the LLM receives |
| Whole retrieval pipeline |
| Whole tool call, from request to response |
| Tool calls running when this query arrived |
| Highest overlap seen in the process |
| The same numbers as an ordered list |
{
"ts": "2026-11-27T14:17:59.120",
"event": "search",
"query": "turkey hsr termination rights",
"topic": null,
"max_results": 5,
"index_size": 514,
"mode": "hybrid",
"reranker": "cross-encoder/ms-marco-MiniLM-L-6-v2",
"candidate_pool": 50,
"dense_candidates": 50,
"bm25_candidates": 31,
"fused_candidates": 50,
"sparse_only_candidates": 4,
"before_filters": 50,
"after_filters": 50,
"after_topic_filter": 5,
"reranked": 50,
"returned": 5,
"dense_ms": 180.6,
"bm25_ms": 105.8,
"total_ms": 1349.8,
"rerank_ms": 1056.1,
"outcome": "ok",
"results": [
{
"rank": 1,
"chunk_id": "50ae5b218c187f89c7e55ea361f3a1c6",
"file": "MUFG HSR 2 - Commercial Terms Agreement.md",
"page": 1,
"topics": ["Turkey HSR 2"],
"cosine_distance": 0.797,
"rrf_score": 0.0101,
"rerank_score": -9.32,
"chars": 5585,
"text": "..."
}
]
}Useful queries (any JSON Lines tool works, jq below):
# every query the LLM sent, newest last, with the total response time
jq -r 'select(.event=="search") | "\(.ts) \(.response_ms) ms \(.query) -> \(.returned) chunks"' logs/detail.jsonl
# slow searches (more than 500 ms), with the step breakdown
jq 'select(.event=="search" and .response_ms > 500) | {query, response_ms, steps}' logs/detail.jsonl
# which step dominates: total time per step over all queries
jq -r 'select(.event=="search") | .steps[] | "\(.step) \(.ms)"' logs/detail.jsonl \
| awk '{sum[$1]+=$2; n[$1]++} END {for (s in sum) printf "%-12s %8.0f ms total %6.0f ms avg\n", s, sum[s], sum[s]/n[s]}' \
| sort -k2 -rn
# queries that ran while other tool calls were in flight
jq 'select(.event=="search" and .concurrent_tool_calls > 1) | {ts, query, concurrent_tool_calls, response_ms}' logs/detail.jsonl
# highest concurrency seen, per tool
jq 'select(.event=="tool_call") | {tool, peak_concurrent_tool_calls}' logs/detail.jsonl | sort -u
# queries where BM25 found chunks the dense search missed
jq 'select(.event=="search" and .sparse_only_candidates > 0) | {query, sparse_only_candidates}' logs/detail.jsonl
# searches that returned nothing
jq 'select(.event=="search" and .outcome != "ok")' logs/detail.jsonl
# which files the answers came from
jq -r 'select(.event=="search") | .results[] | .file' logs/detail.jsonl | sort | uniq -c | sort -rn
# documents that failed to index
jq 'select(.event=="scan_document" and .ok==false)' logs/detail.jsonlWhat the numbers tell you:
dense_candidatesfar abovereturnedwith lowrerank_scoremeans the re-ranker disagreed with the vector search. Try a domain-specificRERANKER_MODEL, orUSE_RERANKER=Falseto compare.sparse_only_candidatesabove zero means BM25 rescued exact terms the vectors missed. LoweringBM25_WEIGHThides those, so raise it instead.after_topic_filterat zero means thetopicfilter removed everything. Check the exact topic withlist_topics.rerank_msdominatingresponse_msmeans re-ranking is the bottleneck. LowerRERANKER_TOP_N, or run on a GPU.response_msrising whileencode_msandchroma_msstay flat means the machine is queueing work, not searching slowly. Checkpeak_concurrent_tool_callsand theWARN ... over SLOW_QUERY_MSlines.bm25_build_msspiking means the sparse index was rebuilt for that query, which happens after every scan or incremental update.outcome: "empty_index"means nothing was indexed yet.
Troubleshooting: error messages
The server explains each failure in three parts: what happened, the likely cause, and the fix. The list below covers the messages users hit most.
Message you see | Cause | Fix |
|
| Create the folder. Set |
| The container sees an empty documents folder. The bind mount points at a different host folder, | Run |
The index is empty again after every container restart, and the first scan repeats each time | The cache volumes point at the wrong container paths, so the index is written inside the container and thrown away. | Mount |
The LLM gets no answer while the first scan runs | The first scan embeds every chunk on CPU and holds the server until it finishes. A 500-chunk corpus takes several minutes. | Follow the progress with |
|
| Move the documents into a folder and point |
| The folder is empty, or the files have unreadable extensions. | Add PDF, Word, Excel, Markdown, PowerPoint, HTML, TXT, or CSV files, then scan again. |
| Nothing is indexed yet, or the last scan failed. | Run the |
| The words are absent from the chunks, or a filter removed every match. | Try other words. Drop the topic, date, phrase, or regex filter. Call |
| The PDF is encrypted, truncated, or not a real PDF. | Remove the password, repair the file, or re-print it to PDF. Then scan again. |
| The file is empty, or a scanned PDF whose pages OCR could not read. | For a PDF, check |
| The optional OCR engine is missing, so scanned pages stay empty. | Run |
|
| Install |
|
| Raise |
| The page is blank, or | Try |
| Marker raised while converting the document. | The message names the exception. Check |
| The environment does not match | Run |
| Model not downloaded, wrong | Run |
| Hugging Face or PyPI is unreachable, or models were never downloaded. | Connect to the internet and run |
| The embedding batch is too large for the RAM or VRAM. | Lower |
| Another process holds the database, the folder is read-only, or the files are damaged. | Stop the other server or container. Check write access. Delete the cache folder and re-scan. |
| Two servers or containers use | Run one server. Stop the other with |
| The index was built with another embedding model, or | Delete |
| tiktoken could not fetch its BPE data, usually because the machine is offline. | Run |
| The file is not UTF-8 and has no byte-order mark. | Re-save the file as UTF-8, then scan again. |
| The server user cannot read the documents or write the cache. | Grant read access to the documents folder and write access to |
| The vector store or document cache cannot grow. | Free disk space, then scan again. |
| The folder is missing or unreadable, or | Create the folder and check |
| A cache entry was truncated, for example by a crash. | No action needed. The scan re-extracts the file and rewrites the cache entry. |
| PyTorch has no CUDA device: CPU-only wheel, or no driver. | Install a CUDA wheel: |
A new container starts for every LLM connection, and it sees no documents | The client config runs | Point the client at the running container instead: |
| The server runs with | Start it with |
The startup log shows |
| Set |
| Docker started the container without the GPU device reservation, so | Add the override: |
| The host has no NVIDIA driver, no NVIDIA Container Toolkit, or Docker Desktop uses the Hyper-V backend. | Install the NVIDIA driver and, on Linux, the NVIDIA Container Toolkit. On Docker Desktop, enable the WSL2 based engine. Then retry. |
| An older build registered each MCP tool under the same name it imported, so the tool called itself. The current source imports the implementations under private names. | Rebuild the container with the current source: |
| Older build: the watcher used the vector store without importing it, so the empty-index check failed. The watcher still ran, and the initial scan followed | Rebuild the container with the current source. |
Every message also ends with a hint pointing at this section. Copy the Details: line when you report a bug.
The scan command exits with code 0 when every document was indexed, 2 when the report holds a problem (a missing folder, no supported files, or files that failed), and 1 on a fatal error such as an unloadable model.
FAQ: search files and PDFs locally
How do I search my folder for a word or phrase?
Index the folder once, then ask the LLM. The LLM calls search_documents. For an exact string, ask for a phrase search: the server filters result text for the quoted phrase.
How do I search my files without opening each one?
Index the folder once, then ask the LLM for what you need. Every result lists the file name, page, and topic. List topics or documents first to narrow the search to one folder.
Can I search local PDFs offline?
Yes. Embedding and re-ranking run on your machine, and downloads happen once, at install time or at Docker build time. No document text leaves the machine after that.
Can I find text inside a scanned PDF?
Yes. Pages with no text layer are read by Marker at index time, so a scanned PDF becomes searchable like any other. This needs OCR_ENABLED=True (the default) and the optional Marker install: uv sync --extra marker, or a Docker build with INSTALL_MARKER=True. See OCR for scanned PDFs.
Every scanned page is read. OCR_MAX_PAGES is only a ceiling for huge files (9999 by default, so no practical limit), and 0 turns OCR off.
How do I find something in a PDF when I do not know the page?
Ask a question instead of a keyword. Dense search matches meaning, so "when do payments fall due" finds the payment terms clause. Each result lists the source file and page number.
What file types does it index?
PDF, Word (.docx, .doc), Excel (.xlsx, .xls, .xlsam, .xlsb), Markdown, PowerPoint, HTML, TXT, and CSV.
Does this work as a documents RAG for Claude Desktop?
Yes. Point Claude Desktop at the running container over HTTP, or add mcp_server.py to its config for a local install. Claude gets search, listing, and indexing tools, and any MCP client works the same way. See Connect an MCP client.
Do I need a GPU for local RAG?
No, CPU works. A GPU makes indexing about 37× faster and re-ranking about 50× faster. The server detects a usable GPU and falls back to CPU automatically.
How large can a folder be?
The index is a local ChromaDB database. Search cost grows slowly with chunk count, while indexing cost grows linearly and semantic chunking is the slowest strategy. Chunk counts in the low hundreds of thousands are fine on a desktop machine.
How do I keep the index current?
Start the folder watcher. Changed files are re-indexed after DEBOUNCE_SECONDS, and unchanged files keep their existing chunks. Run scan_all_my_documents for a full rebuild, or --reset to wipe the index first.
Why does a search return chunks instead of whole files?
Chunks keep queries precise and contexts small. Each chunk carries its file path, page number, and topic, so the LLM can read it and cite the file.
When the whole document is needed, read_file returns its full text and read_file_raw returns the original file as base64.
Project structure
mcp_server.pyruns the MCP server (FastMCP) and parses the command-line flags.app/mcp_tools.pyholds the tool implementations the server exposes.app/document_processor.pyextracts text and chunks documents.app/extractors/holds the per-format text extractors.app/vector_store.pyruns ChromaDB operations: cosine HNSW, hybrid search, RRF fusion, re-ranking.app/embeddings.pyloads one embedding model per process and encodes queries and passages.app/bm25_index.pyholds the in-memory BM25 index for the sparse side of hybrid search.app/device.pypicks the compute device: CUDA, MPS, or CPU.app/scan_all_my_documents.pyruns batch ingestion.app/ocr.pyreads scanned PDF pages with Marker (optional extra).app/incremental_updater.pyapplies single-file changes.app/folder_watcher.pywatches folders and debounces changes.app/scan_scheduler.pytracks the last scan and triggers the periodic full scan.app/config.pyholds settings and the.envloader.app/errors.pyturns exceptions into theProblem,Cause,Fixmessages..env.examplelists every setting with an inline comment.Dockerfile,docker-compose.yml, anddocker-compose.gpu.ymlbuild and run the container.
License
MIT
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Ingest, manage, and retrieve documents for RAG-powered AI applications
Convert PDFs, Office docs, websites and audio into AI-ready Markdown, then search and ask your docs.
Agentic document processing platform: build workflows that turn documents into structured data.
Turns company documents and external developments into one dated, cited record your AI can question.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to enhance their responses with relevant documentation through a semantic vector search, offering tools for managing and processing documentation efficiently.66MIT
- FlicenseNot gradedqualityDmaintenanceEnables intelligent ingestion and querying of PDF, Markdown, and text files using hybrid search that combines keyword matching and semantic embeddings with citations.3-
- FlicenseNot gradedqualityDmaintenanceEnables retrieval-augmented generation by allowing LLMs to search documents in a local folder using vector similarity, supporting multiple file formats.-
- AlicenseNot gradedqualityDmaintenanceEnables uploading, organizing, and semantically searching documents with support for various file types and embedding providers.MIT