
Enterprise Internal Knowledge Base: Production-Ready RAG + MCP
io.github.kimsb2429由 GitHub 帳號 kimsb2429 發布v0.1.0更新於 Oct 24, 2026
Production-ready RAG + MCP demo: eval-in-CI merge gate, Langfuse traces, structure-aware chunking.
概覽
一個本機 RAG 示範型 MCP 伺服器,以公開的退伍軍人事務部教育手冊語料回答問題,回傳附引用的排序片段。
- 可以做什麼
- 透過單一 query 工具與依來源 ID 存取的文件的資源,在 pgvector 儲存的 VA 教育手冊語料中檢索並回傳附引用的排序片段。提供引用提示詞,方便讓回答建立在檢索到的片段上。
- 適用情境
- 適合體驗或研究具備評估、追蹤與結構化切分的正式環境 RAG 流程,或針對內建的 VA 教育手冊範例語料提問。
- 執行需求
- 以 Python 腳本透過 stdio 在本機執行。需要 Python 與此儲存庫的相依套件、以 Docker 執行監聽 5433 埠的 Postgres 加 pgvector,並還原固定資料庫傾印。生成使用 Claude Sonnet,意味著需要 Anthropic API 金鑰;追蹤使用 Langfuse Cloud。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Enterprise Internal Knowledge Base: Production-Ready RAG + MCP,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
Enterprise Internal Knowledge Base — Production-Ready RAG + MCP
A public Retrieval-Augmented Generation pipeline exposed as an MCP server. Sample content from Veterans Affairs education manuals.
The repo implements evaluation, observability, and structure-aware ingestion. Cost/latency tuning, tenant-level access control, and other production concerns are discussed in the article linked below.
📖 Full writeup in Towards AI: Enterprise Internal Knowledge Base RAG MCP: POC-to-Production
Why this exists
RAG demos tend to focus on the quality of the retrieval pipeline, without recognizing that production RAG fails on the next ten steps: prompt or model changes that pass code review but tank answer quality, cost and latency drift that cannot be traced to specific queries, cross-tenant leakage that only surfaces in audit. This repo shows what catching them looks like in practice.
The corpus is public (VA Education manuals — 238 documents, 9,000+ chunks) so anyone can clone, run, and adapt the pipeline.
Quickstart
Consuming from Claude Desktop
Add to ~/Library/Application Support/Claude/claude_desktop_config.json:
Then ask Claude things like "What RPO handles GI Bill claims in Texas?" — the MCP server returns ranked chunks with citations.
Architecture
Ingestion (one-time per corpus):
Query (per MCP tool call):
Stack:
- Vector store: Postgres + pgvector (Docker, port 5433);
content_tsvGIN index for hybrid-ready - Embeddings: mxbai-embed-large (1024 dims, local via sentence-transformers) — $0 API cost
- Reranker: mxbai-rerank-base-v2 (full eval) / FlashRank MiniLM (CI fast mode, 22M ONNX, ~2s/query)
- Generation: Claude Sonnet
- MCP server: FastMCP 3.2.4 — Tools (
query), Resources (document://{source_id}), Prompts (cite_from_chunks) - Observability: Langfuse Cloud, per-trace public sharing
- Eval: DeepEval + 110-query golden set + GitHub Actions merge gate
Eval scores
Full 110-question golden set, contextualized chunks + reranker:
🔗 Live Langfuse trace (public, no login).
Notable result: Anthropic's Contextual Retrieval pattern produced modest lift on top of reranking (+4.8pp AnsRel, +4.1pp CtxPrec) at this scale — well short of the +35% recall their published numbers suggested. Reported as found; juiced numbers would defeat the point.
Eval-in-CI as a merge gate
Every PR runs the golden set in fast mode (FlashRank reranker, ~3-4 min wall, $0.30 in Sonnet calls) against a fixture DB. PRs that regress more than ±5pp on top1/topk/keyword_recall, or +10pp on idk_rate, are blocked.
Forever-artifact: PR #5 — a deliberate failing-then-passing PR. Red CI catches a 20pp top1 regression; green CI confirms the fix. The Actions tab is the proof.
Workflow: .github/workflows/eval-gate.yml.
What this repo doesn't cover
A few production-shape items are seams, not implementations:
- Multi-tenant scoping —
auth_contextparameter present on every MCP tool, typed, currently unused (labels the SSO/ACL seam) - Ingestion concurrency — single-threaded chunker + embedder; production would use a modulus-distributed worker pool
- Hybrid search wiring —
content_tsvGIN index is live; BM25 + RRF fusion at query time stays a post-launch addition
The writeup linked above covers these topics.
Repo layout
Reproducing from raw corpus (~30 min)
Each script is idempotent and resume-safe.
Then python scripts/run_eval.py --fast to verify the eval baseline reproduces.
Further reading
- Full demo writeup: Enterprise Internal Knowledge Base RAG MCP: POC-to-Production (Towards AI, Medium)
docs/2026-04-11-engineering-rag-evidence-and-howtos.md— engineering analysis, evidence base, Zero-to-MCP plandocs/2026-04-12-rag-pipeline-buy-vs-build.md— buy-vs-build map per pipeline stagedocs/deep-dive/2026-04-16-docs-vs-code-rag-adjudication.md— when unified RAG stops working
License
MIT — see LICENSE.
來源:README.md,提交 e1bd519
工具
0版本歷史
1- v0.1.0最新Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分