
Doc Extract Mcp
io.github.koraynar由 GitHub 帳號 koraynar 發布v0.1.0更新於 Oct 27, 2026
Document tooling for AI agents: PDF/text reading, chunking, schema-validated JSON output.
概覽
本機 MCP 伺服器,為助理提供確定性的文件工具:列出、讀取與切分 PDF 和文字檔,依 JSON Schema 驗證結果並儲存輸出。
- 可以做什麼
- 在允許的根目錄下列出檔案,支援遞迴 glob 模式
- 讀取 PDF(含頁碼標記與頁碼範圍)、文字、Markdown、JSON 與 CSV 的內容
- 檢視中繼資料,例如類型、大小、頁數與行數
- 將長文件切成帶重疊與頁碼提示的有序區塊
- 依 JSON Schema 驗證 JSON,並以 JSON Pointer 路徑回報所有錯誤
- 在允許的根目錄內把擷取結果寫成 JSON 或 CSV,並回傳列數與位元組數
- 適用情境
- 適合需要把發票、採購單、報告等雜亂 PDF 轉成符合 schema 的 JSON 的情境,並希望檔案存取被限制在單一資料夾、由伺服器完成確定性的切分與驗證,而不是讓模型自行讀取檔案。
- 執行需求
- 以 stdio 方式在本機執行;需要 Python 3.11+ 與 uv,並從專案儲存庫安裝。環境變數 DOC_EXTRACT_ROOT 指定唯一可讀寫的資料夾,未設定時預設為伺服器的工作目錄。僅支援桌面版 MCP 用戶端。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Doc Extract Mcp,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
doc-extract-mcp
An MCP (Model Context Protocol) server that gives an LLM deterministic document tooling for structured-data extraction workflows. The LLM does the reading and extraction reasoning; this server provides the parts that should never be left to a language model: reliable file access, parsing, chunking, JSON Schema validation, and guarded file output.
Built by Koray Nar as a portfolio project for the AI document-automation workflows he is building — the target use case is turning messy PDFs (purchase orders, invoices, reports) into schema-validated JSON. Published as part of a public portfolio. Pairs with Claude Code and Claude Desktop, and with any other MCP client.
Why
An extraction agent fails in predictable places: it hallucinates file contents, loses track of long documents, silently produces JSON that almost matches the target schema, and writes output wherever it likes. This server removes those failure modes:
- File access is confined to one allowed root (
DOC_EXTRACT_ROOT). - PDF text arrives with explicit
--- page N ---markers, so citations of "page 3" mean page 3. - Long documents are chunked deterministically with overlap and page hints.
- Extracted JSON is checked against a JSON Schema (Draft 2020-12) and every error is reported with a JSON Pointer path — not just the first — so the model can fix all mistakes in one pass.
- Output is written by the server (JSON or CSV), inside the same root, with a verifiable row/byte count.
Tools
All path arguments are resolved and refused if they escape the allowed root
(path traversal guard). The glob_pattern argument is confined the same way:
absolute patterns and patterns containing .. are rejected, and any match
that resolves outside the root (for example through a symlink) is silently
dropped from the listing. Guard failures are raised as MCP tool errors, so
the calling model sees the actual reason, not a masked generic error.
Quickstart
Requires Python 3.11+ and uv.
Run standalone (stdio transport):
Claude Code
Claude Desktop
Add to claude_desktop_config.json:
DOC_EXTRACT_ROOT defaults to the server's working directory if unset. Set it
to the folder your documents live in; nothing outside it can be read or
written.
Typical workflow
list_documents(".", "*.pdf")— find the invoices.document_info("invoice.pdf")— check the page count.read_document("invoice.pdf", "1-3")orchunk_document(...)— get text.- The LLM extracts fields into JSON.
validate_json(data, json_schema)— fix every reported error, revalidate.save_structured("out/invoice.json", data, "json")— write the result.
Limitations (honest ones)
- Text-based PDFs only. Extraction uses pypdf; scanned/image-only PDFs yield empty text. There is no OCR.
- Extraction quality varies with how the PDF was produced. Complex layouts (multi-column, heavy tables) may come out with imperfect reading order — that is a pypdf characteristic this server inherits.
- No .docx / .xlsx support. Supported types are
.pdf,.txt,.md,.csv,.json. - The server does no extraction reasoning. It will not find your invoice total; it makes sure the model that does is working from real text and that the result matches your schema.
- This is a working tool, built for the AI-automation work I'm building up and published as part of my portfolio — it is new and has no production mileage yet. It has tests and a path-confinement guard, but it has not been hardened beyond that — review before pointing it at sensitive directories.
Development
The test suite builds a small two-page PDF fixture in-memory (a minimal hand-constructed PDF, no extra dependencies) and covers all six tools, the path-traversal guard, glob-pattern confinement (including symlink escapes), page-range errors, multi-error schema validation, a CSV round-trip, and tool registration plus error propagation through the MCP server object.
License
MIT © 2026 Koray Nar
來源:README.md,提交 409da2e
工具
0版本歷史
1- v0.1.0最新Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分