DocSlicer
io.github.DocSlicer由 GitHub 帳號 DocSlicer 發布v0.2.5更新於 Oct 25, 2026
Answer questions from documents too large to fit in context, reading only the sections you need.
發布方自己的服務:slicer Competitor Watch
概覽
本機文件解析伺服器,讓助理先看大型 PDF、Word、PowerPoint 和 HTML 的大綱,再只讀取需要的章節。
- 可以做什麼
- 解析本機檔案或網址,回傳文件代號、標題、頁數與標題大綱,並標示各章節的讀取成本,結果快取到磁碟以便重複使用。在大綱超出上下文後重新取得大綱。依大綱中的標題讀取一個或多個章節的正文,並插入頁碼標記以便引用。以整詞比對和 BM25 搜尋標題與分段,找出接下來該讀哪裡。把整份文件匯出成磁碟上的 Markdown 並回傳檔案路徑。
- 適用情境
- 適合需要從法律文件、技術 SOP、財務申報或法遵文件等長篇商業文件回答問題,而整份文件放不進上下文視窗時,讓助理只取相關章節,而不是把全文做嵌入。
- 執行需求
- 以本機 stdio 程序執行,可透過 .mcpb 擴充安裝,或以 uvx 執行 PyPI 套件;需要 Python 3.10+ 與 uv。必須設定 DOCSLICER_MCP_ROOT 來限定可讀寫路徑。選用擴充提供以 Playwright 與 Chromium 為基礎的網址/HTML 渲染、以 Tesseract 為基礎的 OCR,以及加密 Office 檔案支援。不需帳號或 API 金鑰。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 DocSlicer,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
DocSlicer
[PyPI] [Python versions] [License: AGPL v3] [Commercial license available]
[Install in VS Code] [Add to Cursor] [Download .mcpb for Claude Desktop]
Lightning-fast (31 pages/sec), deterministic document parser and chunker for business documents. No LLM calls or heavy ML models.
DocSlicer turns PDFs, Word documents, HTML pages, and PowerPoint files into clean chunks, structured blocks, tables, charts, markdown and a navigable heading hierarchy.
Top score on BizDocBench (0.88 overall vs 0.70 for the next-best tool). 0.80 table accuracy, 0.98 content faithfulness, 0.85 heading recognition and hierarchy preservation, and 0.76 RAG retrieval performance.
Two ways to use it:
- As a Python library — classic RAG. The layout-aware chunker gives you clean, non-overlapping chunks, each carrying its full heading breadcrumb, ready to embed. Jump to the API ↓
- As an MCP server — vectorless RAG. For when you want an answer out of a document right now. Claude, Cursor, or VS Code pulls the outline, picks the section it needs, and reads only that — no embedding, and no 200-page document in the context window. Jump to setup ↓
Quick start
Features
- No LLM, VLM, or ML models — fully deterministic; no model weights to download, no GPU required, no cold-start delay
- Lightweight — ~630 KB wheel with no heavy ML dependencies
- Agentic-friendly — reduces token spend on long documents: have the agent inspect the outline first, then pull only the relevant chunks into context instead of feeding a 500-page document verbatim; well-suited for legal texts, technical SOPs, financial filings, and compliance documents
- Deep hierarchy extraction — works for both numbered (
1.,1.2.,1.2.3) and free-form headings; uses font size, bold weight, and document structure — not inference; handles re-entry after exhibit breaks and repeated navigation headings across pages - Structure-aware chunking — splits at heading and paragraph boundaries, preserving semantic coherence
- Zero character overlap — chunks are non-overlapping by default; no duplicated tokens in your context window
- Unified result object —
chunks,blocks,tables,charts,metadata, andhierarchyin one place - Structured tables — tables come back as cells, not flat text; export as Markdown, JSONL, or melted format
- Multiple export formats — CSV, Markdown, JSONL, Parquet, JSON, plain text, and DataFrames
- Reading order preserved — including multi-column PDF layouts
- Supports
pdf,docx,pptx, andhtml— including JS-rendered pages via Playwright - Robust URL fetching — always renders pages in a real browser, handling cookie banners and bot protection out of the box; also preserves styling signals like boldness that raw HTML omits, producing sharper heading detection and chunk quality
- OCR fallback — auto-detects scanned pages and falls back to Tesseract when the extra is installed
Benchmarks
Measured with BizDocBench — an open benchmark for multi-format business document parsing. All scores are 0–1 (higher is better); pages_per_sec_aggregate is throughput across the full corpus.
Install
The core install is dependency-light. Optional features are available as extras:
Extras can be combined: pip install 'docslicer[html,ocr,llm]'.
Requires Python 3.10+
What you get back (ParseResult)
parse_document returns a ParseResult:
Each Chunk carries:
Every chunk carries its full heading breadcrumb, no matter how deeply nested. For example, a paragraph six levels deep in a financial filing:
This lets downstream code filter or group chunks by any level of the hierarchy without re-parsing the document.
Supported formats
Not supported: .doc, .ppt (legacy Office formats), .xlsx.
Parsing
parse_document auto-detects the format from the file extension or magic bytes. Pass a file path, URL, raw bytes, or a file-like object:
Parsing & content options
parse_document (and the format-specific functions) accept options that control what
gets parsed and how, before it's chunked. Format-specific toggles are accepted everywhere
for a uniform API but only take effect for the relevant format.
Chunking options
How merge_small_chunks works
Because DocSlicer is structure-aware, it initially produces one chunk per heading or paragraph boundary. For documents with many short sections this can yield a lot of small chunks. With merge_small_chunks=True (the default), sibling sections under the same parent heading are merged together until they reach min_chunk_size — but never across heading boundaries into a different parent.
For example, these five short sections all fall under ## Products and Services Performance:
Instead of four tiny chunks, they get merged into one coherent chunk that still carries the correct path for each paragraph. Set merge_small_chunks=False if you need one chunk per section regardless of size.
Table representation formats
table_representation controls how tables are serialised into chunk text. Given a
financial table with multi-row column headers:
"markdown" (default) — preserves the original 2D layout:
"melted" — one row per cell, headers joined with >. Good for sparse or
pivot-style tables where individual cell retrieval matters:
"jsonl" — one JSON object per row, multi-row headers joined with _. Useful
when chunks are fed into structured extraction or tool-use pipelines:
Batch processing
Point parse_all at a folder (or pass a list of paths/URLs). It yields (source, result)
pairs, and a file that fails to parse yields the Exception instead of aborting the batch.
Any parse_document keyword — chunk sizes, include_*, etc. — is forwarded per document.
Reuse config across documents
DocumentParser holds a fixed ParseConfig across many documents and keeps a single
browser open across HTML/URL inputs (launched lazily on the first HTML parse), so a batch
of URLs starts Chromium once instead of once per document. Use it as a context manager so
that browser is always released:
Two levels of parallelism
There are two independent knobs, and they compose:
ParseConfig(max_workers=N)— within a single document: parallelizes PDF word extraction, cell building, and OCR across processes (default: auto, sized to CPU cores). Best when documents are large.DocumentParser(config, workers=N)— across documents: fans whole documents out overNworker processes, each with its own config and browser. Best when you have many documents. Results arrive in submission order (this path isn't lazy per-document).
Setting workers alone defaults each worker's max_workers to 1, so nested pools don't
oversubscribe the machine; set both explicitly to run both levels at once. The workers
path can't forward a browser session or on_stage callback across processes — leave
workers unset when you need those.
Guard your entry point. DocSlicer uses a
ProcessPoolExecutorwhenever there's real CPU work to fan out — any PDF over ~50 pages, any scanned/OCR PDF of any length, and both parallelism knobs above. This is not opt-in: a plaindocslicer.parse_document("big.pdf")triggers it too. On macOS and Windows, Python spawns workers by re-importing your script top to bottom, so a parse that runs at module level makes each worker re-run it and spawn again — raisingRuntimeError: An attempt has been made to start a new process before the current process ... bootstrapping phase. Put your parsing code inside a function behind anif __name__ == "__main__":guard:
Navigating the hierarchy
Most chunking libraries give you a flat list of text segments. DocSlicer also gives you a navigable tree of the document's heading structure, extracted deterministically from the document itself.
This is particularly useful for agents and retrieval pipelines working with long documents: rather than feeding the entire document into context, the agent can inspect the outline first to understand the structure, decide which sections are relevant, and then pull only those chunks — keeping token usage proportional to the task.
Inspect the outline
Drill into a section
.level(n) returns all headings at depth n. Pass a parent to scope it to a
specific subtree — the typical pattern for an agent navigating a long document:
Retrieve content under a heading
find_heading matches any node whose text contains the search term (case-insensitive).
All retrieval methods recurse into subsections by default.
Navigate by page
Parse once, navigate many times
A parsed result is plain data, so you can persist it and reload it later. When an agent asks many questions about the same document, there's no need to parse it again on every question:
A reloaded result supports the full API — hierarchy, find_heading,
chunks_under, tables — so a long-running agent session or document server can
keep documents open across requests without re-parsing.
Export
save() decides what to write from the path you give it.
Only result.json round-trips — the collection and directory forms write flat rows
without the heading hierarchy, so ParseResult.load() can't read them back.
Debug mode
OCR
parse_document automatically detects scanned pages and falls back to OCR when the
[ocr] extra is installed. No configuration needed — result.metadata.has_ocr
tells you whether OCR was used.
MCP server
DocSlicer ships an MCP server, so LLM clients (Claude Desktop, Claude Code, Cursor, …) can parse and read documents directly.
Claude Desktop / Cowork — one-click install
Download docslicer-X.Y.Z.mcpb from the
latest release and
double-click it, or drag it onto the Claude Desktop window. You pick the folder
DocSlicer is allowed to read and write during install; no config file, and no
Python of your own — uv provisions the interpreter.
Other clients
Every client below launches the server over stdio. uvx needs nothing
installed ahead of time:
If you'd rather install it once and skip the resolve on every launch, use
pip install 'docslicer[mcp]' (or uv tool install) and set
"command": "docslicer-mcp" with no args.
On GUI-launched clients, prefer the
.mcpb. An app started from the dock does not inherit your shellPATH— on macOS that excludes/opt/homebrew/bin— so a bareuvxordocslicer-mcpcan work in a terminal and fail when the client spawns it. Use an absolute path (which uvx) if you hit this. The extension sidesteps it entirely.
How it works
A parsed document is far larger than a model's context window, so the server
never returns one in a single call. parse registers the document and hands
back a doc_id handle plus a heading outline. Every other tool takes that
handle and returns a bounded slice — the model pulls in only what it needs.
Every outline line carries what reading it would cost:
That figure is the same estimate read reports back, so a budget made from the
outline holds when it is spent. Sizes are cumulative — a parent never costs less
than the children beneath it — which is what makes "descend or just read it" a
decision the model can make before spending the context rather than after.
read takes heading text exactly as the outline prints it. Where a heading
appears twice, prefixing any ancestor disambiguates it ("Notes > Revenue");
the full chain is never required. Returned text is interleaved with [Page X]
markers using the document's own page labels (S-23, iv), so a quotation can
be cited to the page it actually came from rather than to wherever its section
began.
search is the fallback for when the outline does not settle the question —
headings that name nothing useful (Note 14, Item 7A), or a figure buried in
a table no heading mentions. It combines a whole-word literal match with BM25
over the chunks, and returns places, not answers: each hit is a heading to
pass to read. Query terms that appear nowhere in the document are reported
back, so a query that scored well on one rare word can be recognised as the bad
query it was.
to_markdown is the escape hatch for when the user wants the document itself
rather than an answer drawn from it. It writes to disk and returns a path, so
nothing enters the model's context and document size stops mattering.
Parsed results are cached on disk, so re-parsing the same file with the same
options is free. The cache key includes the file's size and mtime — edit the
document and the next parse re-parses it automatically.
Configuration
Set DOCSLICER_MCP_ROOT when exposing the server to anything but yourself —
without it, any readable path on the machine is parseable, and to_markdown
can write anywhere the server process can.
Documents dropped into a chat. Attaching a file to a Claude conversation
does not hand the server the path you know it by: the app first copies it into
a per-session workspace under its own data directory (~/Library/Application Support/Claude on macOS, %APPDATA%\Claude on Windows), which is nowhere near
the folder you would have picked as your root. That directory is therefore
allowed alongside DOCSLICER_MCP_ROOT, so both routes work — the folder you
chose, and whatever you drop into the chat. It is only ever added to a root
you set; leaving DOCSLICER_MCP_ROOT unset still means no sandbox at all, not
a sandbox of that one directory. Set DOCSLICER_MCP_ALLOW_CLAUDE_DIR=0 to opt
out and accept only your own roots.
to_markdown writes beside the source document, except for a document dropped
into a chat: that copy lives in a session folder you cannot navigate to, so the
markdown goes to your first DOCSLICER_MCP_ROOT instead.
Command line
docslicer parses one document to JSON on stdout — for a quick look at a file,
or to pipe into jq.
It takes the same parsing and chunking options as parse_document; run
docslicer --help for the full list.
Format-specific functions
If you know the format upfront and want explicit failure on unexpected input, use the
format-specific variants. They accept the same arguments as parse_document:
Privacy Policy
Full policy: https://docslicer.ai/privacy
What is collected. Nothing. DocSlicer has no telemetry, analytics, crash reporting, or usage tracking, and requires no account, licence key, or registration.
How your documents are used. Parsing runs entirely on your own machine, in a
local process. Document contents are used only to produce the outline, text
slices, search results, and markdown you ask for, and are returned only to the
caller. Documents are never uploaded to DocSlicer or to any third party. When
running as an MCP server, DOCSLICER_MCP_ROOT bounds which directory tree may
be read from and written to.
Where data is stored, and for how long. Parsed results are cached on your
own disk — by default ~/.cache/docslicer-mcp, configurable with
DOCSLICER_MCP_CACHE. The cache is pruned to a size ceiling
(DOCSLICER_MCP_CACHE_MAX_MB, default 2048 MB); otherwise it persists until you
delete it, and deleting the directory removes it permanently with no copy
retained elsewhere. Nothing is written outside the cache directory and any
output path you supply.
Network access and third parties. No network request is made for a local
file. Requests leave your machine only when you pass an http(s) source: that
URL is fetched directly from the host you named, and for HTML pages Playwright
may load the subresources that page references, exactly as a browser would.
Requests to sec.gov send a User-Agent header identifying the client, as the
SEC fair-access policy requires. These hosts are third parties chosen by you,
not by DocSlicer, and their own policies govern what they log. Set
DOCSLICER_MCP_ALLOW_URLS=0 to reject remote sources entirely.
Third-party clients. When DocSlicer runs as an MCP server, the client (Claude, Cursor, …) handles the conversation under its own privacy policy. DocSlicer is not a party to that and receives nothing from it.
Contact. Privacy questions: [email protected] · Issues: https://github.com/DocSlicer/DocSlicer/issues
License
DocSlicer is dual-licensed:
- AGPL-3.0 — free to use, modify, and distribute, provided you comply with the AGPL's terms, including making the complete source of any application that uses DocSlicer available to its users (including over a network).
- Commercial license — for embedding DocSlicer in a closed-source or proprietary product, or offering it as part of a hosted/SaaS service without releasing your source.
See LICENSE-COMMERCIAL.md for details, or reach out about a commercial license.
mcp-name: io.github.DocSlicer/docslicer
來源:README.md,提交 b6070ac
工具
0版本歷史
1- v0.2.5最新Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分
其他 Slicer 整合
slicer Competitor Watch
dev.slicer官方發布者
slicer 遠端伺服器,讓助理讀取競品漏斗的變化(含截圖、廣告和電子郵件),並啟動新的監控任務。

SlicerBridge
由 GitHub 帳號 UnicornGraveyard 發布
本機 MCP 伺服器,把多色 3MF 專案轉換成適用於 34 款多色 3D 印表機、經過檢查的成品檔案。

cadloop Slicer
由 GitHub 帳號 richardofortune 發布
把 OpenSCAD 模型一路做到可列印的 G-code:檢查、預覽、量測、驗證是否放得下熱床並切片,全程不需圖形介面。