Simple RAG MCP Server
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.
Simple RAG
本地 RAG(检索增强生成)服务,提供文档索引与语义检索问答两项能力:先把文档切块存入向量库,提问时检索相关内容并交给大语言模型生成答案。
父子切块机制:索引时先按文档标题结构切出保留完整原文的父块,再把父块细分为用于向量化入库的子块;检索时只匹配小块召回,命中后回查子块所属的父块全文交给模型,兼顾小块匹配的精准与大块上下文的完整。
检索链路:父子切块 → 稠密 + 稀疏混合召回(RRF 融合)→ cross-encoder 精排 → 父块回查 → LLM 生成答案。
支持的文件格式:Markdown(.md / .markdown)、PDF(.pdf)、纯文本(其他后缀按文本处理)。
部署
环境要求
Python 3.12+
Qdrant 向量库(可用 Docker Compose 启动,也可自行安装运行)
大模型服务 API Key(OpenAI 兼容端点即可,模型自选,在
config.yaml中配置)
步骤
安装依赖(建议使用虚拟环境):
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple启动 Qdrant(二选一):
使用项目自带的 Docker Compose(需 Docker):
docker compose up -d服务地址为 http://localhost:26333,数据持久化在 data/qdrant_data/。
或自行安装并启动 Qdrant,然后在
config.yaml中把base.database.qdrant.url改为实际地址。
设置 API Key 环境变量(变量名与
config.yaml中rag.llm.api_key_env保持一致):
$env:TOKEN_PLAN_API_KEY = "你的APIKey"按需修改
config.yaml(见下文配置说明)。
首次运行会自动从魔塔社区(ModelScope)下载三个本地模型(合计约 2GB)到配置的模型目录(rag.model_dir),耗时数分钟,请耐心等待:
模型 | 作用 | 说明 |
| 稠密向量 | 中文语义嵌入模型,负责检索的语义召回 |
| 稀疏向量 | BM25 关键词打分,体量极小,补足专有术语的精确匹配 |
| 精排 | cross-encoder,对双路召回融合后的候选块重排序 |
Related MCP server: RAG MCP Server
使用方式
交互式命令行
python cli.py启动后进入 rag> 提示符,可用命令:
命令 | 说明 |
| 索引文档,标题自动取文件名,重复文档自动跳过 |
| 检索并流式生成答案,结束后显示引用的上下文来源 |
| 列举知识库中的文档文件名 |
| 按文件名删除文档及其全部数据 |
| 查看帮助 |
| 退出(也可按 Ctrl+D) |
输入 / 后按 Tab 补全命令;/index 时补全文件路径;/delete 时补全知识库中的文档名。
示例:
rag> /index rag_test/md_docs/docker_networking.md
rag> /ask Docker 的 bridge 网络是怎么工作的?MCP 服务
python mcp_server.py以 streamable-http 传输启动,端点为 http://127.0.0.1:9933/mcp(可在 config.yaml 的 mcp 段修改)。提供两个工具,均为非流式,且都需传入 collection(集合名前缀):
index_doc(source_path, collection):索引服务端本机的文档retrieve(query, collection, top_k):检索并生成答案,top_k可省略
MCP 客户端超时建议设置 ≥300 秒(首次加载模型耗时较长)。
配置说明
配置集中在根目录 config.yaml,常用项:
配置项 | 说明 |
| Qdrant 地址,默认 |
| CLI 使用的默认集合名前缀 |
| 本地模型根目录 |
| 问答模型名、API 端点、API Key 环境变量名 |
| 子块大小与重叠 |
| 召回候选数、精排阈值、top_k |
| MCP 服务监听地址与端口 |
每个前缀自动派生三张集合:{前缀}_chunks(子块向量)、{前缀}_parents(父块全文)、{前缀}_meta(文档元信息)。日志写入 data/logs/rag.log。
更多架构与开发细节参见 AGENTS.md。
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
Query your own PDFs and documents from any MCP client. Every answer cites the page it came from.
Cloud or self-hosted knowledge for AI agents: hybrid search, reranking, GraphRAG, scoped MCP tools.
Turn a GitHub repo or docs site into agent-ready context: pack it or search it, over MCP.
Related MCP Servers
- FlicenseNot gradedqualityBmaintenanceEnables any MCP-compatible AI assistant to search, filter, and retrieve information from a local document collection using a hybrid search pipeline with vector, BM25, reranking, and LLM enrichment.4-
- FlicenseNot gradedqualityNot gradedmaintenanceProvides tools for ingesting documents into a local vector database and retrieving relevant information via semantic search, enabling retrieval-augmented generation for MCP clients.9-
- FlicenseNot gradedqualityDmaintenanceEnables local document question-answering and retrieval via MCP, supporting multi-turn conversation, intent recognition, and tools for document search, Q&A, and summarization.5-
- FlicenseNot gradedqualityCmaintenanceEnables MCP hosts to index local PDFs and ask grounded questions over them, retrieving semantically relevant passages with optional reranking and source-attributed, citation-backed answers.-