
Rag
io.github.fieldcure由 GitHub 账号 fieldcure 发布v2.5.1更新于 Oct 24, 2026
MCP RAG server with hybrid search, multi-KB support, and AI-powered chunk contextualization.
概览
一个本地 MCP 服务器,把文档文件夹索引成可检索的知识库,让助手对其做关键词与语义混合搜索。
- 可以做什么
- 列出知识库及其文件数、分块数和索引状态,查看索引元数据、队列状态和上下文化健康状况,或在不调用 API 的情况下试运行文件系统变更扫描。以 BM25 加向量的混合方式检索文档,也可只用关键词或只用语义模式,并按 ID 取回某个分块的完整内容。提交重建索引请求,支持范围合并与强制、延迟标记,或取消尚未开始的队列条目。索引本身由单独的命令行流程完成:从 DOCX、HWPX、PDF、Excel、PowerPoint、Markdown 和音频中抽取文本,切分分块,可选地用大模型补充上下文,再写入 SQLite。
- 适用场景
- 适合本地存有一批文档、希望助手基于这些文档回答问题并定位到具体分块的场景,尤其是韩文与英文资料或扫描版 PDF。也适合多个项目共用一个服务器、需要同时服务多个知识库的情况。
- 运行要求
- 以 .NET 8.0 或更高版本的 dotnet 工具在本地运行,通过 serve 命令和基础路径启动。每个知识库需要一份 config.json 指定源文件夹。嵌入或上下文化提供方是可选的,不配置时仍可用纯关键词检索。API 密钥来自环境变量,例如 OPENAI_API_KEY、ANTHROPIC_API_KEY、GEMINI_API_KEY、GROQ_API_KEY 或 VOYAGE_API_KEY,也可通过 MCP 询问获取。OCR 仅支持 Windows x64,音频转写仅限 Windows。
安装
README
FieldCure MCP RAG Server
A Model Context Protocol (MCP) server for indexing and searching local document collections. Supports DOCX, HWPX, PDF (with OCR), Excel, PowerPoint, and audio (Whisper transcription, Windows-only), with hybrid keyword + semantic search optimized for Korean and English.
Built with C# and the official MCP C# SDK.
Commands
- serve — read-only MCP server serving all knowledge bases under the base path. Single process handles multiple KBs via
kb_idparameter. Can run while exec is indexing (SQLite WAL). - exec — scans source folders, chunks documents, contextualizes with AI, embeds, stores in SQLite.
--partialre-runs only downstream stages when models change, preserving OCR output. - exec-queue — sequential orchestrator consuming a deferred indexing queue. One entry at a time, no GPU contention.
--sweep-allprocesses deferred entries too (used at app shutdown). - prune-orphans — deletes orphan KB folders (GUID-named, no config.json). Protected folders (
.,_prefix,-backup-) are never touched. - smoke-ocr — diagnostic mode. Loads a scanned PDF through the OCR fallback parser, prints recognized text to stdout, and exits
0on a non-empty result. SurfacesDllNotFoundException/BadImageFormatExceptiondistinctly so a missing or arch-mismatched native is immediately visible. Useful for verifying that the OCR native path is wired correctly on a given host (notably win-arm64 dnx installs).
Features
Search
- Hybrid BM25 + vector search with Reciprocal Rank Fusion (RRF)
- BM25-only fallback when no embedding provider is configured
- Korean-optimized chunking (sentence boundary, decimal protection, parenthesis-aware)
- SIMD-accelerated cosine similarity via
System.Numerics.Vector - FTS5 trigram index for substring and CJK-friendly keyword matching
Indexing
- Incremental indexing with SHA256 change detection
- AI-powered chunk contextualization with bilingual keyword enrichment (see Chunk Contextualization)
- 2-commit pipeline preserves expensive upstream work across embedding failures (see How Indexing Works)
- Math equation extraction from DOCX/HWPX as
[math: LaTeX]blocks - PDF with OCR fallback (Tesseract eng+kor) for scanned pages
- Audio transcription (
.mp3,.wav,.m4a,.ogg,.flac,.webm) via Whisper.net — Windows-only. Model size (Tiny→Large) is auto-selected from detected GPU/RAM/cores at startup; each transcript chunk recordsaudio.model_sizeandaudio.transcribed_atfor future reindex auditing - Cross-process indexing lock with stale PID auto-cleanup
- Orphan cleanup for deleted files
Queue Orchestrator
- All indexing requests flow through
start_reindexMCP tool — no direct exec spawn - Scope merge rules: full ⊃ contextualization ⊃ embedding (duplicate requests upgrade, not duplicate)
- PID-based orchestrator lock with reuse defense (
orchestrator.lock) - Logical KB deletion (config.json removal) +
prune-orphansphysical cleanup - Deferred indexing for app-shutdown batch processing (
--sweep-all)
Operations
- Multi-KB serve: single process serves all knowledge bases under a base path, lazy-loaded per KB
- SQLite WAL mode allows search during indexing
- Graceful shutdown via
cancelfile - Per-KB
config.jsonwith provider configuration
Integration
- Ollama native — embedding via
/api/embed, contextualization via/api/chatwithkeep_aliveandnum_ctxsupport. Requires Ollama 0.4.0+. - OpenAI-compatible — embedding via
/v1/embeddings, contextualization via/v1/chat/completions. Works with OpenAI, Azure OpenAI, Groq, LM Studio, Together AI. - Gemini native — embedding via
/v1beta/models/{model}:embedContentwithtask_typeasymmetric retrieval (RETRIEVAL_DOCUMENT/RETRIEVAL_QUERY) and Matryoshka dimension truncation (768 / 1536 / 3072).gemini-embedding-2, multilingual, 8k token input. - Anthropic — contextualization via
/v1/messages. - API keys via environment variables —
OPENAI_API_KEY,ANTHROPIC_API_KEY, etc. Batch indexing commands (exec,exec-queue) are env-var-only. Interactive MCP search can fall back to MCP elicitation when the client supports it. - Standard MCP stdio transport (JSON-RPC over stdin/stdout)
Chunk Contextualization
Standard RAG chunking loses context — a sentence about "the protocol" becomes ambiguous when ripped from its surrounding paragraphs. This server addresses that with Unified Chunk Contextualization: a single LLM call per chunk that produces both contextual framing and bilingual (Korean + English) keywords in one pass.
The result is stored alongside the original chunk text:
- Original text is preserved for accurate retrieval display
- Contextualized text is what gets embedded and indexed in BM25
- Bilingual keywords enable cross-lingual search — a Korean query can retrieve English documents and vice versa
This is enabled by setting contextualizer in config.json. It can be disabled (set provider/model to empty) if you prefer raw chunk indexing.
How Indexing Works
The exec command runs a 5-stage pipeline per file:
- Extract — text from document (DOCX, PDF OCR, audio transcription, etc.)
- Chunk — split into ~1000 char windows
- Contextualize — LLM enrichment (optional, see above)
- Embed — vector embedding via API
- Persist — save to SQLite
For large files, Stage 1 alone can take 20+ minutes — OCR on a 596-page scanned PDF, or Whisper transcription of a multi-hour audio recording. The first audio file in any KB also pays a one-time ggml model download (cached under {UserProfile}/.fieldcure/whisper-models/). To prevent expensive upstream work from being lost when later stages fail, the pipeline uses a 2-commit model:
Why this matters: A 25-minute OCR result is persisted on disk before any embedding API call. If Stage 4 fails (network error, rate limit, token limit, process crash, even power loss), the chunks survive. The next exec hash-skips the file (no OCR re-run) and the deferred retry pass attempts only Stage 4.
Per-Chunk Failure Isolation (Binary Split)
If a single chunk in a file exceeds the embedding model's token limit (e.g., a math-dense page in a textbook), the binary split algorithm isolates that one chunk:
Result: 1249 chunks indexed, only chunk 846 marked Failed. The file's status becomes Degraded — partially searchable instead of completely missing.
Deferred Retry Pass
Each exec ends with a retry pass over any chunks left in PendingEmbedding state from previous runs:
- Reads enriched text from DB — no OCR or contextualization re-run
- Calls the embedding API only — typically seconds, not minutes
- Up to 3 retries per chunk; on exhaustion, the chunk is marked
Failed - Auth errors (401/403) flag the provider as unavailable and skip the rest of the pass
File States
Schema Versioning
Each KB DB carries a PRAGMA user_version tag. The exec command migrates older schemas automatically as part of InitializeSchema(). The serve command opens DBs read-only and never triggers migration — older-schema KBs continue to serve search queries correctly while their new-feature columns remain unused.
Installation
dotnet tool (recommended)
From source
Requirements
- .NET 8.0 Runtime or later
- OCR: Windows x64 only — Tesseract OCR for scanned PDFs loads lazily on first use (Windows only). On other platforms, PDFs with embedded text work normally; scanned pages without a text layer are silently skipped.
- An embedding provider (Ollama, OpenAI, etc.) — optional, BM25 search works without it
- Ollama 0.4.0 or later (if using Ollama for embedding or contextualization)
Quick Start
Index a folder and search it without any embedding setup (BM25 only):
For full retrieval quality with semantic search and contextualization, add embedding and contextualizer blocks to config.json — see Usage below.
Usage
1. Create a knowledge base folder
API keys are resolved from environment variables: apiKeyPreset: "OpenAI" → OPENAI_API_KEY, "Claude" → ANTHROPIC_API_KEY, "Gemini" (or "Google") → GEMINI_API_KEY.
Gemini embedding example — asymmetric retrieval with 1536-dim Matryoshka truncation (50% storage of full 3072 with identical MTEB score):
2. Index documents
3. Start MCP search server
A single serve process handles all knowledge bases under the base path. Tools accept a kb_id parameter to target a specific KB.
Claude Desktop
Add to claude_desktop_config.json:
config.json Reference
Tools
All tools (except list_knowledge_bases) require a kb_id parameter to specify the target knowledge base.
Search Modes
Supported Formats
Document formats are provided by FieldCure.DocumentParsers:
- DOCX — Microsoft Word (with math equation extraction)
- HWPX — Korean standard document (OWPML, with math equation extraction)
- XLSX — Excel spreadsheets
- PPTX — PowerPoint presentations
- PDF — PDF text extraction with
## Page Nheaders; OCR fallback for scanned pages (Tesseract, eng+kor) - TXT, MD — Plain text / Markdown
Project Structure
Data Storage
Knowledge base data is stored at %LOCALAPPDATA%\FieldCure\Mcp.Rag\{kb-id}\:
config.json— knowledge base configurationrag.db— SQLite database (chunks, embeddings, FTS5 index, file hashes, indexing lock)
Queue and lock files at %LOCALAPPDATA%\FieldCure\Mcp.Rag\:
.deferred-queue.json— pending indexing requestsorchestrator.lock— PID lock for the queue orchestrator
Development
See Also
Part of the AssistStudio ecosystem.
License
来源:README.md,提交 ddfdb4f
工具
0版本历史
1- v2.5.1最新Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分