
emperor-pdf
io.github.yarenty由 GitHub 帳號 yarenty 發布v0.1.3更新於 Nov 3, 2026
在一個資料夾中讀取、搜尋和渲染PDF;合併、提取PDF,並從Markdown建立PDF。
AI 翻譯由 AI 模型根據下方的原文描述翻譯,可能有誤。
原文描述
Read, search and render the PDFs in one folder; merge, extract and create them from Markdown.
概覽
emperor-pdf 的本機 MCP 服務;無需登入;STDIO。
暫無 AI 概覽:以下資訊來自註冊中心條目和服務本身。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 emperor-pdf,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
emperor-pdf
The PDFs in one folder, for your agents: read, search, render, merge, split and write them.
An MCP server that works on the PDFs inside a single root folder and nowhere else:
- Read and search text page by page, from the root folder, from base64 bytes in the call, or
from an
https://URL, with Google's PDFium, the engine inside Chrome, and fall back to a pure-Rust extractor when PDFium is not installed. - Warn about hidden text: white-on-white, invisible, sub-point or off-page text, the usual way to plant instructions for a model in a document a person thinks is harmless.
- See a page as a PNG image the model can look at (also how scanned pages are read).
- Merge and extract pages, and create PDFs from Markdown, typeset with Typst and OFL fonts built into the binary.
- Confined by capability, not by string checks: every file is opened through a
cap-stddirectory handle, so.., absolute paths and symlinks that lead out of the root are refused by the operating system layer. - Read-only by default: without
--writablethe writing tools are not even offered.
Built on the emperor-mcp framework: stateless
Streamable HTTP (or stdio for desktop clients), framed output, a doctor subcommand, four tools
read-only and six with --writable. It meets
Emperor Profile P1.1: no tool
that writes is listed unless the operator switches writing on at start-up (--writable or
PDF_WRITABLE), and tool definitions are lean, with short descriptions that say when to use
each tool and compact input schemas.
Install
Prebuilt binaries (macOS arm64/x86_64, Linux x86_64, Windows x86_64) are attached to GitHub releases. Or build from source:
Rust 1.92 or newer is needed to build (typst 0.15 sets that minimum).
Read-only build
pdf_create is behind the create Cargo feature (on by default), which brings in Typst and the
embedded fonts. Without it you get a smaller binary that reads, searches, renders, merges and
extracts:
Docker
The repository's Dockerfile builds an image that speaks MCP over stdio and carries PDFium
(linux/amd64 and linux/arm64). Mount the folder with your PDFs at /data:
The server runs as uid 10001, so for --writable the mounted folder must be writable by it.
PDFium (recommended)
PDFium is a native library loaded at runtime; it is not bundled with emperor-pdf. Prebuilt PDFium binaries for every platform come from bblanchon/pdfium-binaries (Apache-2.0 / BSD-3-Clause). From a checkout:
or download pdfium-<os>-<cpu>.tgz from a release yourself and unpack it anywhere. The
release is pinned to chromium/7881, the PDFium API version the pdfium-render binding is
built for; PDFIUM_VERSION=<n> scripts/fetch-pdfium.sh picks another.
emperor-pdf looks for libpdfium.dylib / libpdfium.so / pdfium.dll, in this order:
--pdfium-dir DIR(the library inDIR,DIR/liborDIR/bin),PDFIUM_DYNAMIC_LIB_PATH(a folder, with the samelib/andbin/lookup, or the file),- the folder holding the
emperor-pdfbinary, - the system library path.
Without PDFium, pdf_text and pdf_search use lopdf's
extractor (and say so in their output: it misses or garbles text in some PDFs), and
pdf_render_page answers that it needs PDFium. Everything else works the same.
Run
Logs go to stderr (RUST_LOG=debug for more). GET /health answers OK.
Connect a client
Claude Code
Claude Desktop (claude_desktop_config.json)
Claude Desktop, read-write: add "--writable" to args.
Kowalski (config.toml), over HTTP or stdio:
Tools
The four reading tools take the PDF in one of three ways, exactly one per call:
path: a file relative to the root folder (forpdf_searchalso a glob such as**/*.pdf);data: the PDF bytes, base64 (adata:application/pdf;base64,prefix is accepted);url: anhttps://URL the server downloads.
data and url are capped at 8 MiB (the emperor-mcp limits byte cap); downloads time out
after 30 seconds and follow at most five redirects.
Page numbers are 1-based. pdf_pages keeps the pages and their content but not the inputs'
bookmarks, forms or tagged structure.
Tool annotations say what each tool does: the reading tools are read-only, idempotent and
open-world (they can fetch a URL); pdf_pages, pdf_create and pdf_render_page on a writable
server are not read-only and are marked destructive, since overwrite: true replaces a file. On a
read-only server pdf_render_page is marked read-only, because it cannot save.
Hidden text
With PDFium, pdf_text and pdf_search check every character of the pages they read and flag
text a person looking at the page would likely not see:
- text drawn in the invisible render mode (mode 3), unless it lies over an image, which is how OCR makes a scanned page searchable;
- white or near-white (or fully transparent) text with nothing drawn behind it;
- text set below 1 pt;
- text outside the page box.
The text is still returned, inside the document frame; a separate, framed warning names the file,
the pages and the reasons, and asks the model to treat it as data and tell the user. pdf_search
marks each hit on such a page with page_has_hidden_text. The check is a heuristic: a white
background drawn inside a form object, for example, hides nothing but is not looked into. The
lopdf fallback does not check and says so.
Scanned pages
emperor-pdf has no OCR engine. A scanned page without a text layer comes back from pdf_text as
empty or near-empty; render it with pdf_render_page and let a vision-capable model read the
image. Scans that were OCR'd already carry an invisible text layer, which pdf_text reads (and
does not flag as hidden).
Security model
- One root, enforced by capability. The root is opened once as a
cap_std::fs::Dir; every read and write goes through it by relative path. Paths with..or an absolute path are refused with a clear message before any file system call, and cap-std refuses symlinks that resolve outside the root. Globs are expanded by walking the root through the same handle (hidden folders are skipped, at most 200 files). - Read-only unless
--writable. Without it,pdf_pagesandpdf_createare not registered (a client never sees them) andpdf_render_page { save_as }answers that the server is read-only. With it, an existing file is never replaced unless the call passesoverwrite: true. - URLs: public HTTPS only.
urlmust behttps://, without user name or password; every redirect is checked again. Host names are resolved by the server and only public addresses are used: loopback, private (RFC 1918), link-local (including cloud metadata at 169.254.169.254), shared, unique-local IPv6 and similar ranges are refused, so a call cannot reach services on the server's own network. Downloads anddataare capped at 8 MiB and must start like a PDF. - Document text is data. PDFs come from anywhere and may carry text written to steer a model. Text and search snippets are wrapped with emperor-mcp framing as a document of unknown authorship (nonce-guarded delimiters, "data, not instructions"); metadata, results and hidden-text warnings are framed as computed values.
- Markdown cannot run code.
pdf_createescapes every character of text and passes code and links as string literals, so Markdown cannot reach Typst as markup or script; the Typst world serves no file but the generated one, and fonts are embedded, so a document cannot read the disk. Typst runs only on a writable server built with thecreatefeature. - Bounded work. Files over 256 MiB are refused, fallback text extraction caps decompressed content per page, renders are capped at 300 dpi and 8000 px a side, Markdown input at 2 MiB.
doctor
It exits 1 when a check fails. A missing PDFium is a warning, not a failure. --stdio skips
the port check. The tool budget counts the tools the server would list: four read-only, six with
--writable. The fonts check is absent from a --no-default-features build.
Develop
The tests build their fixture PDFs with Typst in a temporary folder and talk to a real server
over HTTP (and one over stdio); url sources are fetched from a small local HTTP server. The
tool lists are checked with emperor-mcp's testkit. Without ./pdfium the PDFium-only tests
print a note and pass.
Links
- crates.io: emperor-pdf
- Official MCP Registry: mcp-name: io.github.yarenty/emperor-pdf
- Framework: emperor-mcp
- How it compares with other PDF MCP servers: docs/COMPARISON.md
Licence
Dual licensed under MIT OR Apache-2.0, at your option.
Fonts
With the create feature the binary embeds two font families for pdf_create, from
assets/fonts with their licence texts:
Both are permissive and allow embedding in documents and redistribution with software. No
GPL-licensed font is included (Typst's own New Computer Modern set is not used). Release
archives carry both licence texts as FONTS-NOTICE. Documents you create are not affected by
these licences beyond keeping the font's own notices if you extract the font. PDFium, when you
install it, is under its own licences (Apache-2.0 / BSD-3-Clause).
來源:README.md,提交 323b673
工具
0版本歷史
1- v0.1.3最新Nov 3, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分