OmniDocs-RAG-CN

OmniDocs-RAG-CN

Enables AI agents to index and search local files, websites, GitHub repos, and packages with hybrid AI-powered retrieval, all locally through IDE chat.

Category
Visit Server

README

<div align="center">

🧠 OmniDocs-RAG-CN

匀箱即甚的 AI Agent 䞪人知识库 — 原生䞭文支持 🇚🇳

玢匕本地文件、眑页、GitHub 仓库、npm/PyPI 包 → 混合 AI 检玢匕擎 → IDE 聊倩框内盎接搜玢。100% 本地运行䞀条呜什安装。

License Python MCP Chroma BGE-M3

English | äž­æ–‡

</div>


猘起

最初只是想搭䞪䞪人知识库䜆埈快发现 Obsidian 对 Agent 并䞍友奜——目圕树、双向铟接、党文搜玢这些䞺人讟计的功胜圚 Agent 県里只是䞀堆需芁遍历的文件路埄。Agent 芁的䞍是"翻文件"而是"语义检玢"甚自然语蚀问䞀䞪问题从知识库䞭召回最盞关的片段再基于这些片段生成回答。

于是自然想到了向量数据库。把䞪人文档向量化存起来Agent 甚向量盞䌌床来"扟䞜西"而䞍是翻文件倹。䜆翻遍 GitHub没有䞀䞪现成的工具胜盎接做到这䞀点——芁么猺 MCP 接口芁么对䞭文支持几乎䞺零分句错、分词烂、BM25 倱效。

所以基于 OmniDocs-RAG v3.4 做了䞭文化适配和 MCP 接口封装改出了 OmniDocs-RAG-CN。

最终的䜿甚场景是这样的

人通过 IDEClaude Code / Cursor跟 Agent 对话问䞀䞪问题Agent 通过 MCP 协议调甚 OmniDocs-RAG-CN 的 search_docs圚䞪人向量知识库䞭做混合检玢语义 + 关键词 + 重排序拿到最盞关的文档片段后组织回答。

人和 Agent 从䞀䞪"端口"访问同䞀䞪䞪人数据库人看到的是 IDE 聊倩窗口里的自然语蚀回答Agent 看到的是 chroma_db 里经过向量化的知识片段。人的入口是对话Agent 的入口是 MCP 工具调甚——同䞀仜知识䞀种访问方匏。

这就是"人䞎 Agent 协䜜"的知识管理䞍是人翻了文件喂给 Agent也䞍是 Agent 替代人去读文档而是人决定"哪些知识倌埗存"Agent 莟莣"圚需芁的时候粟准扟到"人再做最终的刀断和创造。知识库从䞀䞪人的第二倧脑变成了人和 Agent 共享的倖郚记忆。


人-Agent 协䜜架构

┌─────────────────────────────────────────────────────────┐
│                      人 👀                              │
│   IDE 聊倩框                                            │
│   "垮我查䞀䞋讀证逻蟑怎么实现的"                          │
│   → 看到自然语蚀回答做决策、创䜜                          │
└──────────────────────┬──────────────────────────────────┘
                       │ 自然语蚀对话
                       ▌
┌─────────────────────────────────────────────────────────┐
│                    Agent 🀖                              │
│   Claude Code / Cursor 等                                │
│   → 理解问题 → 调 MCP 工具 → 绌合回答                     │
└──────────────────────┬──────────────────────────────────┘
                       │ MCP 协议search_docs
                       ▌
┌─────────────────────────────────────────────────────────┐
│               OmniDocs-RAG-CN                            │
│   ┌───────────────────────────────────────────────┐     │
│   │  混合检玢匕擎                                    │     │
│   │  向量语义 + BM25 关键词(jieba) + RRF 融合        │     │
│   │  + Cross-Encoder 重排序 + 去重                   │     │
│   └───────────────────────────────────────────────┘     │
│                         │                                │
│                         â–Œ                                │
│   ┌───────────────────────────────────────────────┐     │
│   │  ChromaDB 向量数据库 (chroma_db/)               │     │
│   │  䜠的文档 → 向量化 → 语义可检玢                   │     │
│   └───────────────────────────────────────────────┘     │
└─────────────────────────────────────────────────────────┘

䞀䞪端口同䞀仜知识。人从对话进去Agent 从 MCP 进去。


🚀 快速匀始

1. 环境芁求

  • Python 3.10+
  • git

2. 䞀键安装

git clone https://github.com/ybhuang995-dev/OmniDocs-RAG-CN.git
cd OmniDocs-RAG-CN
python install.py

install.py 自劚完成䞀切pip 䟝赖安装 → GPU 检测 + PyTorch 安装 → AI 暡型䞋蜜~2.3GB仅銖次→ IDE 的 MCP 连接自劚配眮。

3. 䜿甚

盎接圚 IDE 聊倩框里诎人话

垮我玢匕我的文档目圕
搜玢讀证逻蟑怎么实现的
把 https://fastapi.tiangolo.com 的文档也加进知识库
甹 rag_status 看看知识库状态

Agent 自劚调甚 MCP 工具䞍需芁䜠点任䜕按钮。


✹ 功胜特性

🔍 混合搜玢管道

阶段 技术 诎明
查询扩展 CN→EN 同义词映射 17 组䞭文→英文猖皋同义词提升混合文档召回率
向量搜玢 ChromaDB + bge-m3 1024 绎语义向量支持 100+ 语蚀
关键词搜玢 BM25 + jieba 分词 䞭文甚结巎分词英文保持空栌切分
融合排序 RRF (k=60) 向量排名 + 关键词排名数孊融合
重排序 bge-reranker-v2-m3 亀叉猖码噚对候选集粟确打分
去重 >80% 盞䌌床剔陀 移陀近重倍结果

📁 倚源摄入

  • 40+ 文件栌匏 — .md .py .js .pdf .docx .xlsx .pptx 等
  • 眑页 — 匂步 BFS 爬虫支持 robots.txt、sitemap.xml
  • GitHub 仓库 — github://owner/repo 盎接抓取
  • npm / PyPI / ZIP — npm://package pypi://package file:///path.zip
  • JS 枲染页面 — 可选 Playwright 支持

⚡ 性胜

  • GPU 加速 — CUDA 自劚检测玢匕速床提升 ~11x
  • 增量玢匕 — MD5 哈垌只倄理变化的文件
  • BM25 持久化 — pickle 猓存服务重启即恢倍

🛠 管理

  • 倚集合 — 䞍同项目甚䞍同知识库
  • 自劚分类 — YAML frontmatter → H1 标题 → 文件名
  • 文件监控 — watchdog 监听变劚自劚增量玢匕
  • 100% 本地 — 无 API Key、无云服务、无月莹

🛠 MCP 工具9 䞪

工具 诎明
index_documents(path, collection) 玢匕本地文件40+ 栌匏增量玢匕
index_url(uri, collection, ...) 玢匕眑页、GitHub、npm、PyPI、ZIP
search_docs(query, n, ...) 混合搜玢向量 + BM25 + 重排序
rag_status(collection) 系统状态暡型、GPU、BM25、分块数
list_collections() 列出所有知识库集合
list_indexed_files(collection) 列出集合䞭已玢匕的文件
remove_source(filename, collection) 从玢匕䞭删陀指定文件
delete_collection(name, confirm) 删陀敎䞪集合
reindex_collection(path, collection) 区制党量重建玢匕

index_url() 瀺䟋

# 眑页匂步 BFS 爬虫
index_url("https://docs.python.org/3/library/asyncio.html")

# GitHub 仓库
index_url("github://tiangolo/fastapi/docs")

# npm 包
index_url("npm://axios@1.6")

# PyPI 包
index_url("pypi://fastapi")

# ZIP 压猩包
index_url("file:///path/to/docs.zip")

🇚🇳 䞭文适配7 倄改劚

䌘先级 文件 改劚
P0 parsers.py 分句正则补䞭文标点。空栌改䞺可选
P0 parsers.py 语蚀感知分块䞭文按 2000 字笊、英文按 700 词
P0 store.py 眑页重爬按 source URL 枅旧块再写入防僵尞数据
P1 search_engine.py BM25䞭文甚 jieba 分词替换空栌切分
P1 crawler.py 眑页提取新增 Mozilla Readability 䞺策略 1语蚀无关
P2 search_engine.py 查询扩展17 组䞭文→英文同义词映射
P3 parsers.py 重叠量䞭文取前块最后 150 字英文保持 2 句

所有改劚圚代码䞭以 # [䞭文化] 泚释标记。诊见 CHANGES_CN.md。


⚙ 环境变量

变量 默讀倌 诎明
RAG_DOCS_PATH server.py 父目圕 扫描的文档目圕
RAG_DB_PATH ./chroma_db ChromaDB 持久化路埄
RAG_DEVICE auto cuda / cpu / auto有 CUDA 健康检查
RAG_EMBED_MODEL BAAI/bge-m3 嵌入暡型
RAG_RERANK_MODEL BAAI/bge-reranker-v2-m3 亀叉猖码噚重排序暡型
RAG_DASHBOARD 䞍启甚 讟䞺 true 匀启 Web 面板端口 6280
RAG_WATCH_PATH 䞍启甚 文件变劚自劚重玢匕
GITHUB_TOKEN — GitHub API 什牌提升速率限制

❓ 垞见问题

Q: 数据䌚发送到倖郚吗 A: 䞍䌚。100% 本地运行。暡型从 HuggingFace 䞋蜜䞀次后犻线䜿甚无 API Key无云服务。

Q: 需芁 GPU 吗 A: 䞍必须䜆有最奜。CPU 搜玢纊 200msGPU 玢匕加速纊 11x。讟眮 RAG_DEVICE=cuda 匀启。

Q: 劂䜕曎新玢匕 A: 增量玢匕——只有变化的文件䌚重新倄理。再调䞀次 index_documents() 即可或匀启文件监控自劚曎新。

Q: 銖次搜玢䞺什么慢 A: Cross-Encoder~1.1GB圚銖次搜玢时惰性加蜜。后续搜玢即时响应。

Q: 支持䞭文吗 A: 这就是做这䞪项目的原因。原生 jieba 分词、䞭文分句、䞭文分块、CN→EN 查询扩展。bge-m3 还支持 100+ 其他语蚀。

Q: 胜建倚䞪知识库吗 A: 可以。甚 collection 参数区分index_documents(path, collection="项目A")搜玢时指定 collection="项目A"。


📄 讞可证

基于 Apache License 2.0 匀源。诊见 LICENSE。

原项目ElvinBayramov/OmniDocs-RAG

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured