RAG Factory
Automated RAG pipeline optimization and serving. It interviews users, builds and evaluates candidate configurations on their data, and registers the best ones as a fleet queryable via MCP.
README
RAG Factory — AutoML for RAG
RAG Factory turns RAG configuration from guesswork into measurement. From a short conversation plus a sample of your own documents, it recommends candidate RAG configurations, builds an isolated sub-environment for each, evaluates it on your own data, and optimizes across the candidate grid — then registers the winning environments as a persistent fleet you can query directly or over MCP.
Status: v1.0 snapshot. This repository is a curated portfolio snapshot of a project that continues to evolve in a private development repository.
📸 Screenshots / demo of the web UI will be added here.
The problem
A good RAG setup cannot be reliably predicted up front. MTEB scores do not predict performance in your domain, and the chunking strategy can matter as much as the embedding model. The only trustworthy answer is to measure candidates on your own corpus — but doing that by hand (generating a QA set, building indexes, running ranking metrics, comparing) is slow and expensive.
The solution
RAG Factory closes the loop:
[Recommender] -> [Factory] -> [Evaluator]
input build measure
^ |
+-------- optimization loop ------+
- Recommender (input). A conversational interview plus a data-profile turns your intent and a document sample into a search space of candidate configurations — not a single guessed "truth".
- Factory (build). For a given configuration it builds a sub-environment: parsing → chunking → embedding → index.
- Evaluator (output). It measures each candidate on your own data (MRR, NDCG, faithfulness / completeness), and the result feeds back to select the winner.
- Registry (fleet). Winning environments are persisted and can be served — locally, via a Gradio web UI, or through an MCP server.
What is built here vs. adopted
Honesty about the boundary matters, so it is explicit:
| Layer | Decision | Why |
|---|---|---|
| Build + eval + optimize core, ranking metrics (MRR/NDCG) | Adopted — AutoRAG | The optimizer and validated metrics are a solved problem; reimplementing them would be worse and slower |
| QA ground-truth generation | Adopted (engine-provided) | Hand-curating a test set dominates development time |
| Conversational recommender (input layer) | Built here | No existing tool offers this; the unique, agentic part |
| Fleet registry / environment manager | Built here | Tools optimize "one best pipeline for one dataset"; they do not manage N persistent environments |
| MCP server + Gradio web UI + optimization orchestration | Built here | The serving and human-in-the-loop layer wrapping the engine |
Principle: reinvent zero metrics and zero optimizer; build exactly what is new.
Tech stack
Python · AutoRAG · LlamaIndex (OpenAI-compatible LLMs) · MCP (FastMCP) · Gradio · pandas / numpy · langdetect · PyYAML · LLM access via OpenRouter.
Package layout
| Module | Responsibility |
|---|---|
ragfactory/interview.py, profiler.py |
Conversational recommender: intent interview + data profiling |
ragfactory/recommendation.py, grid.py |
Candidate search space & finalist recommendation |
ragfactory/corpus.py, solution.py, yaml_builder.py |
Corpus prep, QA generation, environment build (AutoRAG YAML) |
ragfactory/runner.py, optimize.py, _optimize_worker.py |
Build/eval execution and the optimization loop |
ragfactory/generation.py, reports.py, emission.py |
Answer generation, reporting, artifact emission |
ragfactory/registry.py, serving.py |
Fleet registry & query serving |
ragfactory/mcp_server.py |
MCP server (FastMCP, stdio) exposing the fleet |
ragfactory/app.py, web_ui.py |
Gradio web application |
Getting started
# 1. Environment
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
# 2. Configure access (copy the template and fill in your key)
cp .env.example .env
# then edit .env: OPENROUTER_API_KEY, OPENROUTER_BASE_URL, OPENROUTER_MODEL
Run the web application:
python -m ragfactory.app
Run the MCP server (stdio transport):
python -m ragfactory.mcp_server
# optional: RAGFACTORY_REGISTRY_DIR=/path/to/registry python -m ragfactory.mcp_server
Note: some build/evaluation paths run AutoRAG and may require an embedding model and a GPU. A corpus is not bundled — you point RAG Factory at your own documents.
Testing
pytest # unit / fast tests (default; costly tests deselected)
pytest -m integration # slower tests that run AutoRAG / GPU
pytest -m costly # tests that spend money on live LLM calls (OpenRouter)
The suite is substantial (24 test modules) and mirrors the production package closely.
Markers are defined in pytest.ini.
Documentation
docs/ARCHITECTURE.md— design decisions, the build-vs-adopt rationale, and evaluation methodology.
License
Released under the MIT License © 2026 Dariusz Poślad.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。