fayna-rag-mcp
Officialfayna-rag-mcp — 基于 RAG 与 MCP 的本地知识库
由 Fayna Digital 开发 作者: Volodymyr Shevchenko
问题: 团队在文件中收集文档(政策、手册、笔记),但在自然语言层面很快便失去了对这份资料的方便访问——按文件名搜索或 Ctrl+F 缩放性差,而且把内部文档发送到云端 LLM 服务不一定总是可接受,隐私方面就是一个问题。
解决方案: 一个基于本地 LLM(Ollama)的本地 RAG 流水线(FAISS + 多语言嵌入模型)——同一套检索器/Q&A 对外暴露为 MCP 服务器,因此任何 MCP 客户端(Claude Desktop/Code 等)或外部自动化作案都可以通过简单的 REST 路由使用它。任何数据都不会离开此机器。
效果: 用于语义搜索、RAG Q&A(带来源)、文档读取和离线编目的五个 MCP 工具加四条 REST 路由,几分钟内即可接入 Claude 或 n8n,完全无需云端依赖。
能力
工具(MCP) | 用途 |
| 从知识库中读取完整文件(在 |
| 列出所有文档( |
| FAISS 语义搜索 → 最相关 top-k chunks |
| RAG 回答:FAISS 检索 + Ollama LLM,并携带来源 |
| 文档标签的只读目录(主题/类型/语言/受众) |
Related MCP server: OpenLMlib
技术栈
Python 3.10+ · FAISS(faiss-cpu)· sentence-transformers · tiktoken · Ollama · FastMCP · Tesseract/poppler/Whisper(用于多格式的内容摄取) · Docker。
RAG 流水线
docs/ → load (.txt/.md/.pdf/.docx) → chunk (tiktoken) → embed (mpnet) → FAISS → retrieve → Ollama → answer + sources分块(chunking)—— 按
tiktoken(cl100k_base)的 token 来分,不是按字符分。 默认CHUNK_SIZE=700tokens,CHUNK_OVERLAP=100tokens。嵌入模型:
paraphrase-multilingual-mpnet-base-v2—— 多语言(UA/PL/EN/RU 等)的模型,让查询不依赖具体语言。LLM: 任意 Ollama 模型,默认
qwen2.5:7b。索引: FAISS
IndexFlatIP(余弦相似度),TOP_K=5。
快速开始
pip install -r src/requirements.txt
# Przykład: demo-korpus na kilka dokumentów (sample-docs/)
export DOCUMENTS_DIR=./sample-docs
python -m src.main build-index # → src/index/index.faiss + chunks.pkl
# Interaktywne Q&A (CLI)
python -m src.main
# Serwer MCP (transport z env MCP_TRANSPORT: stdio|http)
python -m src.mcp.server测试:
pip install -r tests/requirements-dev.txt
pytest -qDocker
docker compose up -ddocker-compose.yml/Dockerfile 里的默认值都是为运行在宿主机(通过 host.docker.internal)的 Ollama 设计的;请根据你自己的网络结构调整 OLLAMA_URL(Linux 上为 docker 网络地址,或独立的容器化 Ollama 等)。
配置(src/config.py,全部通过 env 设定)
Env | 默认值 | 说明 |
|
| 知识库根目录 |
|
| 嵌入模型 |
|
| RAG 回答使用的 LLM |
|
| Ollama 的 endpoint |
|
| token 数量( |
|
| 检索返回多少个 chunk |
|
|
|
|
|
|
连接 MCP 客户端(比如 Claude Code)——通过其 MCP server 的配置,用命令 python -m src.mcp.server(stdio)或通过容器的 URL(http)。
结构
src/
├── config.py # wszystkie env-zmienne + domyślne
├── main.py # CLI: build-index | interaktywne Q&A
├── assistant.py # CompanyKBAssistant (LLM decyduje czy wołać MCP-toolki)
├── catalog.py # offline-klasyfikacja dokumentów przez Ollama → JSON+HTML
├── ingest.py # multi-formatowy ingest: OCR skanów, vision-opis diagramów, Whisper-transkrypcja
├── rag/
│ ├── ingest.py # load_document (.txt/.md/.pdf/.docx)
│ ├── chunk.py # chunk_text (tiktoken cl100k_base, overlap)
│ ├── embed.py # embed_chunks (sentence-transformers)
│ ├── build_index.py # build_index → FAISS + pickle
│ └── query.py # retrieve / build_prompt / ask
└── mcp/
├── server.py # FastMCP: 5 MCP-toolków + 4 trasy REST
└── client.py # MCPClient (JSON-RPC przez subprocess)多格式内容摄取(用 Tesseract OCR 扫描到的文档、用 vision 模型描述图片/示意图、用 Whisper 转录音频/视频)—— 这是一个独立的、依赖更重的 route,对于上面的基础文本语料(仅基础文本)不是必需的。
许可证
MIT —— 见 LICENSE。© Fayna Digital.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseNot gradedqualityAmaintenanceA headless local knowledge library and RAG substrate that enables LLM clients to search, retrieve chunks, and list documentation packs through read-only MCP tools.MIT
- AlicenseNot gradedqualityAmaintenanceProvides AI assistants with a local knowledge base and research library, enabling semantic and full-text retrieval, memory persistence, and multi-agent collaboration via 58 MCP tools.2MIT
- AlicenseNot gradedqualityDmaintenanceA knowledge base MCP server backed by Qdrant vector database with local embeddings for semantic search and document management.51ISC
- FlicenseNot gradedqualityCmaintenanceEnables users to build and query a private knowledge base by uploading documents, which are embedded and stored locally, then accessible via MCP for semantic search and retrieval.
Related MCP Connectors
Your memory, everywhere AI goes. Build knowledge once, access it via MCP anywhere.
Shared, governed long-term memory for AI agents across tools and sessions via MCP and REST.
Private-by-default, local-first memory/context/task orchestrator for MCP apps and agents.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/fayna-digital/fayna-rag-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server