Folio
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.
Folio
Turn a folder of documents into a search tool for Claude, Cursor and any other MCP client: hybrid vector + Chinese BM25 retrieval, a reranker, and auto-merged passages, one Folio_<folder> tool per folder.
Documentation · 繁體中文 · Roadmap · Changelog

Folio is an open-source retrieval-augmented generation (RAG) server for the Model Context Protocol.
Each folder becomes a Folio_<folder> tool with three modes, search, list and read, and
one folio_find tool finds documents across all your folders by topic, tags or metadata. It
is an OAuth 2.1 resource server: it verifies tokens offline and never issues them, and pairs
with MCP Gate as the authorization server. Folio was
called Agentic RAG up to v1.1.0; the database names (agentic_rag) and the storage layout keep
the old name, and nothing needs migrating.
What's new
1.4.1: folders belong to the person, not to one token, so every personal access token and OAuth sign-in of one MCP Gate user sees the same folders; signing out ends the console session on the server; answers come in the question's language. See the CHANGELOG, and the ROADMAP for what comes next (1.5: a Docker image, backups, and documents and speech read through OpenAI-compatible APIs).
Changed in 1.5 (on
dev, not released yet):config/config.yamlis split into six files underconfig/with every secret and per-machine value in.env, and the old file is no longer read;rag.answer_llmandrag.eval_llmare removed (answers and evaluation userag.llm).scripts/split_config.pyconverts a 1.4 config: see Upgrading from 1.4.
Removed in 1.5 (on
dev): every in-process OCR, layout and speech model, and the/v1media endpoints (now 410 Gone). PDFs and images are read by an OpenAI-compatible vision model when you set one (rag.parsing.vision, e.g. Qwen3-VL on Forgeyard); without one, PDFs are read from their text layer (a scanned page becomes a marker) and image uploads are refused. Audio goes to an OpenAI-compatible transcription endpoint (rag.asr, e.g. whisper-large-v3-turbo). A config that still hasrag.docling,rag.parsing.images,rag.parsing.pdf: local/cloudor an old speech provider stops the start. See Upgrading to 1.5.
Related MCP server: RAG3 MCP Server
Key features
Hierarchical chunks that merge back. Small leaves for precise matching, large parents for context, never across a section; several hits in one passage come back as the whole passage.
Hybrid search, tuned for Chinese. Dense vectors (pgvector) and BM25 fused with Reciprocal Rank Fusion; Chinese is word-segmented first (CKIP, jieba or bigram).
Cross-encoder reranking (
mxbai-rerank-base-v2,bge-reranker-v2-m3), and MCP search says when nothing relevant was found.Contextual retrieval. An LLM writes a short context line for each chunk at index time; re-indexing an edited file only redoes the chunks that changed. Files indexed by an older chunking pipeline or another embedding model are marked for re-indexing.
Per-person folders. You only see the folders of your MCP Gate account, over MCP, REST and the console alike.
Tags and metadata on documents. Label files with tags and flat key/value metadata (client, year, a due date…), then filter a search or list documents across all your folders by them (document filters).
Search across folders, by document. One search over all your folders (or some), reranked once over every folder's candidates, answered as passages or as documents ranked by their best passage with snippets (search across folders).
Many formats. PDF, Office (including legacy and RTF), OpenDocument, HTML and MHTML, Markdown, EPUB, email, scanned PDFs and images (read by a vision model such as Qwen3-VL, tables kept as tables; without one, PDFs are read from their text layer), and audio (transcribed by an OpenAI-compatible endpoint, with Simplified Chinese turned into Traditional).
Measured, not guessed. A public 205-question golden set and an evaluation harness; the console scores your own folders on Recall@k, MRR and nDCG@k.
A console at
/admin: a Library of every document with tag, metadata, folder, type and date filters, content search, bulk tag / metadata edits and a document panel; folders and files, a Search Playground with the per-signal trace, index jobs, query analytics and knowledge gaps, evaluation, live settings, health and an audit log.Backup and restore in one command.
main.py backuparchives the database, every folder's vectors and the stored files together, with a manifest thatmain.py restorechecks; the server can also back up on a schedule.main.py export-folder/import-foldermove one folder, with its files and index, to another Folio or keep a copy of it — also from the console's Folders page.Prometheus metrics at
/metrics: requests, per-stage search latency, MCP tool calls, index jobs and model endpoint calls, with no folder or user names in any label.Self-hosted or cloud models. Embeddings, LLM, reranker, vision and speech-to-text run behind OpenAI-compatible endpoints on your own GPUs (e.g. Forgeyard) or a cloud API; the only in-process models, CKIP segmentation and optional HuggingFace embeddings, run on the CPU.
Installation
With Docker (the lightweight cloud-profile image, tonyhuang1101/folio, plus PostgreSQL with
pgvector; every model is an OpenAI-compatible endpoint such as Forgeyard or vLLM):
git clone https://github.com/xianhong1208/folio-rag.git && cd folio-rag
cp .env.example .env # POSTGRES_PASSWORD, the model endpoints and names, MCP Gate: the "Docker" section
docker compose up -d # add COMPOSE_PROFILES=mcp-gate to .env to run MCP Gate in the same stackThe deploy guide covers the image, the model endpoints, matching the issuer and the audience with MCP Gate, a reverse proxy with HTTPS, backups and upgrades.
From source (needed for the in-process models of the local and hybrid profiles). You need:
Python 3.12 and uv;
PostgreSQL with the pgvector extension;
OpenAI-compatible endpoints for the embedding, LLM and reranker models (vLLM, Ollama, Forgeyard or a cloud provider);
LibreOffice (
soffice) for legacy Office files and RTF.
git clone https://github.com/xianhong1208/folio-rag.git
cd folio-rag
# In-process models (CKIP, HuggingFace embeddings) need the `local` extra, which brings the
# CPU build of torch. All-cloud: plain `uv sync`.
uv sync --extra local
cp .env.example .env # DATABASE_URL (PostgreSQL + pgvector), model endpoints and keys,
# MCP_GATE_URL / FOLIO_AUDIENCE: every secret and per-machine value
# models, retrieval tuning, port: config/models.yaml, retrieval.yaml, system.yaml (no secrets there)
uv run python main.py # creates the schema and runs migrations on startFolio listens on http://0.0.0.0:5039: the MCP endpoint is /mcp and the console is /admin.
Run it as the user that owns .venv: NLTK 3.10.4+ refuses data files owned or writable by another
account, and long plain-text paragraphs then fail to split (chown -R <service user> .venv).
Quick start
Folio authenticates through MCP Gate. Register Folio there first: MCP Gate only issues tokens for audiences it knows.
1. Register the server in MCP Gate. Services → Register Service, with this server's host, port
and path (/mcp). The audience defaults to the MCP URL, for example http://127.0.0.1:5039/mcp.
2. Point Folio at MCP Gate in .env (config/auth.yaml reads them):
MCP_GATE_URL=http://localhost:4568 # MCP Gate base URL (RS256 JWKS issuer)
FOLIO_AUDIENCE=http://127.0.0.1:5039/mcp # must equal the audience registered in MCP Gate3. Create a folder and add documents, in the console (Folders → New Folder → Upload Files, signed in with a personal access token from MCP Gate) or over REST:
curl -X POST http://127.0.0.1:5039/api/folders/ \
-H "Authorization: Bearer <TOKEN>" -H "Content-Type: application/json" \
-d '{"name":"product-docs"}'4. Connect a client. An OAuth-capable client needs nothing up front:
claude mcp add --transport http folio http://127.0.0.1:5039/mcpOn first use the client registers with MCP Gate and shows the consent screen; then the
Folio_product-docs tool appears. For scripts, pass a personal access token as a bearer header.
5. Ask.
Folio_product-docs mode="search" query="how do I rotate the signing key?"You get the matching passages, merged where they belong together, each with a relevance score and its source file and heading.
Not sure which folder holds it? Find the documents first, then search inside them:
folio_find query="signing key rotation" filters={"tags_any": ["runbook"]}
Folio_product-docs mode="search" query="how do I rotate the signing key?" file_ids=["<file_id>"]folio_find ranks your documents across every folder (each with its folder tool, tags, metadata and
short snippets); without a query it lists documents by tags, metadata, type or upload date. See
MCP tools.
Deployment options
Profile | Models | Install |
| Anything goes. The shipped config calls self-hosted embedding, LLM and reranker endpoints, and runs CKIP segmentation in-process; the vision model and speech-to-text are always endpoints |
|
| The same, for a mix of self-hosted and cloud endpoints; API keys written literally in the config files are warned about | as |
| Every role is an HTTP endpoint and keys must be |
|
Set it with rag.profile; see Cloud profile. The Docker
image is the cloud profile, with a compose file for PostgreSQL + pgvector and an optional MCP
Gate; the in-process models need an install from source. Keep the console on a trusted network or
behind a reverse proxy with HTTPS; /mcp and
/api/rag/* need a valid token. The deploy guide has nginx and Caddy examples,
backups and upgrades. The database and storage/ (the uploads) belong together: startup refuses
when one of them is missing, rather than starting without the data.
Documentation
the pipeline, retrieval in detail (BM25, segmentation, reranking, latency, relevance cutoff), measuring retrieval, every feature in detail | |
the Docker image and compose file, model endpoints (Forgeyard, vLLM), the issuer and audience with MCP Gate, a reverse proxy with HTTPS, backups, upgrades | |
the six config files and | |
the vision model for PDFs and images (Qwen3-VL on Forgeyard) or the text layer, speech-to-text through an endpoint, a private CA, what happens to an old configuration | |
folder ownership by MCP Gate user, and the token revocation feed | |
signing in, the two permission tiers, each page, re-indexing after an upgrade or an embedding model change | |
MCP, REST, console and health endpoints | |
| |
connection budget and database upkeep | |
Prometheus | |
architecture, checks, CI and releasing | |
the golden set, the harness and the baselines |
Contributing
Issues and pull requests are welcome. Branch off dev and open the pull request into dev. Code and comments are in
English; the console is English only by decision. Run the checks in
docs/development.md first: uv run pytest, uvx ruff check ., and
npm test plus npm run build in frontend/ when you change the console.
Licence
MIT. PDF pages are rendered with PDFium (pypdfium2, Apache-2.0 / BSD-3-Clause), not
the AGPL-licensed PyMuPDF.
Third-party licences
Folio's own code is MIT. Some optional parts carry other licences; check them before you redistribute an install or an image that includes them:
--extra local:ckip-transformersand the CKIP models it downloads are GPL-3.0. Thejieba(MIT) andbigramsegmenters avoid it; the published Docker image does not include it.The Docker image adds PostgreSQL's client tools (PostgreSQL Licence) and Debian packages, each under its own licence.
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
Safe folder access for ChatGPT and Claude: read, write and search files, risky tools opt-in.
Team docs served to AI agents over MCP - search, Markdown reads, version pinning, read audit.
Cloud or self-hosted knowledge for AI agents: hybrid search, reranking, GraphRAG, scoped MCP tools.
Read-only MCP tools for AI agent discovery, structured resources, and NIULAI information.
Related MCP Servers
- AlicenseAqualityBmaintenanceEnables AI agents to connect local knowledge bases, preview and index selected directories, search for traceable snippets with source metadata, and read indexed document versions through MCP tools.6MIT
- AlicenseNot gradedqualityBmaintenanceEnables users to index and retrieve local documents through semantic, BM25, or hybrid search, with tools for chunk reads and page images accessible from MCP clients such as Codex and ChatGPT web.MIT
- AlicenseNot gradedqualityBmaintenanceEnables querying a folder of company documents over MCP and retrieving matching passages with file:line citations for Claude to answer from. Supports keyword and multilingual hybrid search over an incrementally indexed SQLite knowledge base.Apache 2.0
- AlicenseAqualityCmaintenanceEnables MCP clients to search a folder of markdown notes and read individual notes through two read-only tools, using hybrid dense-vector and BM25 retrieval.2MIT