pdf-parse-mcp
A server (MCP) for precisely extracting PDF content and rendering pages, aimed at reconstructing design files from PDFs.
pdf_info: Get document-level info (page count, per-page size/rotation, metadata, optional password/maxPages).
pdf_extract: Extract per-page text, vector shapes (with styles and path geometry), and image placements; supports filtering by category, region/limit, box vs full detail, precision, clip shapes, password, and flags hidden text layers (
covered, recovered color).pdf_render: Rasterize a page to PNG/JPEG with scale/dpi, optional region zoom, background control, and saving to file.
Coordinates are in top-left origin, y-down, points (pt); output includes bounding boxes, colors, stroke widths, rotations, font info, and pattern/bitmap metadata.
Also supports programmatic usage (
openPage,extractPage,renderPage, overlay debug images).
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@pdf-parse-mcp Extract text, shapes, and images with coordinates from page 1 of the PDF"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
@ai-zen/pdf-parse-mcp
English | 简体中文
An MCP server that takes PDFs apart precisely for agents: coordinates and sizes for text, vector shapes, and bitmaps — plus on-demand raster rendering.
Built for the "reconstruct a design file from a PDF" use case — you get the position, size, color, and stroke width of every glyph, line, and rectangle in the file, instead of one blob of plain text.
npx -y @ai-zen/pdf-parse-mcpWhat it actually gives you
You want | You get |
Where a glyph is, how big it is | Baseline origin |
The shape of a rect / line / curve | Subpath geometry ( |
What it looks like | Fill color, stroke color, alpha, line width, cap/join/dash |
Where the images are | Placement box of every bitmap plus its intrinsic pixel size |
To just look at it | Rasterize the whole page or any region to PNG/JPEG |
All coordinates use a top-left origin, y down, in points (1pt = 1/72 inch) — the intuitive coordinate system of screens and design tools, instead of PDF's internal "bottom-left origin, y up".
Related MCP server: MCP PDF
Install / wiring
Add a snippet to any MCP client (Claude Desktop, Cline, Cursor, your own agent…):
{
"mcpServers": {
"pdf-parse": {
"command": "npx",
"args": ["-y", "@ai-zen/pdf-parse-mcp"]
}
}
}No system dependencies: the canvas implementation (@napi-rs/canvas) and all font/cmap/wasm assets ship as prebuilt artifacts inside the package.
Requires Node.js ≥ 22.13 (pdfjs 6 requirement).
Tools
pdf_info
Document-level information: page count, per-page size and rotation, metadata.
{
"path": "design.pdf",
"pages": 3,
"unit": "pt",
"coord": "top-left origin, y down",
"metadata": { "Title": "Home screen design", "Producer": "Figma" },
"pageSizes": [{ "page": 1, "width": 595.28, "height": 841.89, "rotation": 0 }]
}Parameters: path (required), password, maxPages (default 100).
pdf_extract
Extract everything on a single page. This is the core tool.
Parameters:
Parameter | Description |
| PDF path (required) |
| Page number, 1-based (required) |
| Return only a subset of |
|
|
| Decimal places for coordinates, default 3 |
| Also return clip-region shapes ( |
| Only extract items intersecting this rect |
| Max items per category, default 5000 (exceeding it is flagged in |
| Password for encrypted documents |
Return shape (truncated; the shapes entries below show what detail:"full" gives):
{
"page": 1,
"width": 595.28, "height": 841.89, "rotation": 0,
"unit": "pt", "coord": "top-left origin, y down",
"counts": { "text": 42, "shapes": 17, "images": 2 },
"text": [
{
"text": "Hello World",
"x": 72, "y": 92, // baseline origin
"width": 124.008, "height": 26.813, // visual width / line height
"fontSize": 24, "rotation": 0,
"bbox": [72, 70.28, 196.01, 97.09],
"color": "#000000",
"fontName": "g_d0_f1", "fontFamily": "sans-serif"
}
],
"shapes": [
{
"paint": "fill", // fill | stroke | fillStroke | clip | shading
"bbox": [100, 542, 300, 692],
"fill": "#3366e6", "fillAlpha": 1,
"subpaths": [
{ "closed": true, "bbox": [100, 542, 300, 692],
"segments": [
{ "t": "M", "x": 100, "y": 692 },
{ "t": "L", "x": 300, "y": 692 },
{ "t": "L", "x": 300, "y": 542 },
{ "t": "L", "x": 100, "y": 542 }
] }
]
},
{
"paint": "stroke",
"bbox": [98.5, 490.5, 401.5, 493.5], // stroke box already expanded by line width
"stroke": "#ff0000", "strokeWidth": 3,
"lineCap": 0, "lineJoin": 0, "miterLimit": 10,
"subpaths": [ /* … */ ]
}
],
"images": [
{ "kind": "image", "name": "img_p0_1",
"intrinsicWidth": 800, "intrinsicHeight": 600,
"bbox": [400, 132, 550, 232] },
{ "kind": "image", "name": "img_p0_3", // bitmap from a tiling pattern cell
"intrinsicWidth": 300, "intrinsicHeight": 300,
"bbox": [24, 668, 56, 700], "pattern": true }
],
"fonts": { "g_d0_f1": { "family": "sans-serif", "ascent": 0.905, "descent": -0.212 } }
}A few conventions:
bboxis always[x0, y0, x1, y1], top-left origin, y down.Path segment coordinates are already in device space (page CTM and current transform applied), so you can use them directly as design-file coordinates.
Curve segments keep their control points (
C= cubic Bézier,Q= quadratic);bboxis the tight box of the whole path.A
nullstroke color means a pattern/gradient stroke;paint: "shading"means the region was originally a gradient fill (render gradients withpdf_render).Text color is recovered by nearest-in-paint-order matching; if it can't be determined we omit it rather than inventing one.
Clip regions (
paint: "clip") are omitted by default: they are never painted, they only constrain visibility; passincludeClip: trueto get them.regionfilters only: items whose box intersects it are returned unchanged, geometry is not clipped, and coordinates stay in page space (so they line up withpdf_render'sregionmagnifier).Shapes give boxes and styles by default (
detail: "box"): a full path often runs to hundreds of segments, which is noise when you only need the layout. ⚠️ Don't usedetail: "full"unless you know what you're doing — it exists for "redraw this shape exactly" work and can multiply the payload by tens (demo1: 66 shapes, 8,078 segments, 550 KB). If you need the geometry, scope it withregionfirst.A bitmap tagged
"pattern": truecomes from a tiling pattern (TilingPattern) cell — the "use an image as fill" trick (very common in Skia/Chrome exports). The cell is tiled across the page byXStep/YStep; we report only the visible part of that one cell, not the full tiled extent.
pdf_render
Rasterize a single page to an image.
Parameter | Description |
| Required |
| Zoom factor (relative to 72dpi), default 1 |
| Target DPI (equivalent to |
|
|
| Default |
|
|
| If given, write the file and return path info only; otherwise the image itself is returned to the agent |
region plus a large scale is a magnifying glass: checking whether an icon or a line is really aligned beats a full-page thumbnail by a mile.
Typical workflow for reconstructing a design
1. pdf_info → how many pages, how big each page is
2. pdf_extract(page, detail:"box")
→ all boxes and styles first, to see the layout skeleton
3. pdf_extract(page, include:["text"])
→ copy, font size, weight, color
4. pdf_render(page, scale:1) → full-page thumbnail to verify layout
5. pdf_render(page, region:[x0,y0,x1,y1], scale:4)
→ zoom in on a detail to verify alignment
6. rebuild the design from 1–5, then render and compare (to replicate a shape exactly, re-extract that page with `detail:"full"` for its path segments)Overlay debug images (visual check)
To find out "is the extracted geometry actually accurate", an overlay image is the fastest answer — the render as backdrop, the geometry drawn on top:
npm run overlay -- pdfs/demo1.pdf # → tmp/overlay/demo1-p1-overlay.png
npm run overlay -- pdfs/demo3.pdf --page all --scale 3
npm run overlay -- design.pdf --layers render,shapes,text,labels
npm run overlay -- design.pdf --region 0,0,300,300 --line 2Layer | Draws | Default |
| rendered page as backdrop | ✅ |
| text boxes (blue) + baseline origin and width (pink) | ✅ |
| shape outlines: fill magenta / stroke green / shading red / clip gray dashed | ✅ |
| image boxes (orange, labeled with intrinsic pixel size) | ✅ |
| legend with per-layer counts (top-right) | ✅ |
| text content of each item (yellow) | — |
| shape bounding boxes (dashed) | — |
Programmatic interface:
import { renderOverlay } from "@ai-zen/pdf-parse-mcp";
const { buffer, counts } = await renderOverlay(page, { scale: 2 });The overlay is a debug view: it turns includeClip on, so clip regions are drawn as well (gray dashed). Great for regression: after changing extraction logic, run the overlay on real documents and any drift or missed item is obvious at a glance.
Programmatic usage
The main use of this package is the MCP server, but the core is exported as well:
import { openPage, extractPage, renderPage } from "@ai-zen/pdf-parse-mcp";
const page = await openPage("design.pdf", 1);
const content = await extractPage(page, { precision: 2 });
const png = await renderPage(page, { scale: 2, region: [0, 0, 300, 300] });extractPage also takes three optional switches (same semantics as the MCP tool): includeClip (also return clip regions as shapes, off by default), region (keep a single area — it filters, it does not clip) and applyClip (off by default: drop items whose box does not intersect the active clip region at all). applyClip is deliberately conservative and never returns clipped geometry; on real Skia exports it often drops nothing at all, so don't count on it for visibility cleanup.
Documents are cached and reused by "path + mtime"; call closeAllDocuments() to release them.
Hidden text layers (important)
Chrome/Skia-style exporters commonly do this: visible text is painted as vector outlines, with an invisible text object underneath (for searchability/selection). That text layer's color — sometimes even its position — has nothing to do with what is visible.
This tool detects the pattern and does two things:
Text fully covered by later, opaque artwork is marked
"covered": true(don't treat it as visible content);If a "text outline" shape sits at the same spot, its color is used to recover
color, and"colorFrom": "outline"is set; if none is found, nocoloris reported at all.
{ "text": "Mailboxes", "x": 24, "y": 56.64, "fontSize": 24,
"color": "#e8e8ea", "covered": true, "colorFrom": "outline",
"bbox": [24, 37.44, 141.79, 61.44] }In other words: for text with covered: true, the string content is trustworthy; color and geometry should be taken from the recovered values.
Measured on real documents (mobile design exports from Skia/PDF m117): 13/13 and 20/23 text items had their colors recovered correctly.
Known limitations
Text color: regular PDFs use the color from the drawing operators directly; hidden text layers go through the recovery logic above, and if recovery fails no color is reported (never a wrong one).
Gradients are only marked positionally (
paint: "shading"); color stops are not extracted.Pattern (TilingPattern) fills:
fillisnull(a pattern has no single color); bitmaps painted inside the pattern cell are extracted and taggedpattern: true, but only the portion of that one cell intersecting the filled area is reported — tiled copies are not expanded into separate entries.Transparency groups (isolated): inner coordinates are mapped through to the final composited position and are correct in normal cases; rare form XObjects with a custom
group.matrixmay be slightly off.Bitmaps report placement and intrinsic pixel size only, not pixel data (use
pdf_renderto look at them).When artwork is covered by later opaque fills, text is marked
covered; shapes do not track occlusion yet.Mind the output size on very large pages: control it with
detail: "box",include, andlimit.
Development
npm install
npm run build # tsc → dist/
npm test # build + core assertions + MCP stdio end-to-end
npm run overlay -- pdfs/demo1.pdf # generate an overlay for visual inspectionscripts/make-sample.mjs generates three minimal PDFs on the fly as golden fixtures:
tmp/sample.pdf— vector shapes / text / bitmaps / CTM transforms;tmp/sample-hidden.pdf— hidden text layer + covered by an opaque background + outline-recovered color;tmp/sample-pattern.pdf— a rectangle filled with a tiling pattern (TilingPattern) whose cell embeds a bitmap.
npm test also uses pdfs/demo1~3.pdf (real design exports from Skia/PDF m117) as golden fixtures: it asserts semantics only (page size, hidden-text color recovery, pattern bitmap placement) and never locks item counts, so normal extraction improvements will not turn it red.
License
MIT
Available Tools
3 toolspdf_extractA
抽取 PDF 某一页的全部内容,用于从 PDF 精确还原设计稿:
text:文本片段(字符串、基线坐标 x/y、宽高、字号、旋转角、颜色、外框 bbox)
shapes:矢量图形(填充/描边色、透明度、线宽、外框 bbox、以及子路径几何:M/L/C/Q/Z 线段;paint="clip" 是不可见的裁剪区)
images:位图贴图(外框 bbox、原始像素尺寸、对象名) 坐标:左上原点、y 向下、单位 pt(1pt=1/72 英寸)。 注意:Chrome/Skia 导出的 PDF 常把可见文字画成矢量轮廓,另垫一层不可见的文本对象;这类文本会被标 "covered":true,颜色则由同位置的轮廓反推并标 "colorFrom":"outline"。 建议先整体抽取一次看清结构,图形很多时用 detail="box" 只取外框与样式,再对重点区域用 pdf_extract + pdf_render 局部细看。
Inputs: page (required), path (required), limit, detail, +3 more.
pdf_infoA
读取 PDF 的文档级信息:页数、每页尺寸与旋转角、元数据(标题/作者/生成器等)。用于在抽取前了解文档结构、确定要处理哪些页。坐标:左上原点、y 向下、单位 pt(1pt=1/72 英寸)。
Inputs: path (required), maxPages, password.
pdf_renderA
把 PDF 某一页栅格化成图片(PNG/JPEG)。可用于:整体查看版面、放大局部核对细节、验证还原结果。
默认返回图片本身(base64),Agent 可直接查看;给 save 则写入文件并只返回路径信息。
region 可只渲染局部([x0,y0,x1,y1],pt,左上原点),配合较大 scale 相当于「放大镜」。 坐标:左上原点、y 向下、单位 pt(1pt=1/72 英寸)。
Inputs: page (required), path (required), dpi, save, +5 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 3 tools
Each tool has a clearly distinct purpose: pdf_info inspects document-level metadata, pdf_extract pulls structured content from a page, and pdf_render rasterizes a page or region to an image. There is no overlap in their primary functions.
All three tools follow a consistent pdf_<verb> pattern: pdf_info, pdf_extract, pdf_render. The naming clearly communicates the action and is uniform across the set.
Three tools is well-scoped for a PDF parsing server: inspect, extract structured content, and render. Each tool covers a distinct need without redundancy or bloat.
The set covers the core PDF inspection workflow: document info, page content extraction, and rasterization. Minor gaps exist such as no direct text search or page-range extraction, but the described workflow is complete for design-reconstruction use cases.
Maintenance
Related MCP Connectors
High-fidelity PDF to structured Markdown conversion and document field extraction.
Extract tables, text and formulas from PDFs, including scanned pages and broken text layers.
Turn documents into structured data: parse, extract, classify, split, and fill PDF forms.
Extract text, Markdown and metadata from PDF URLs or uploads via Apify, per document or per page.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables comprehensive PDF processing including text extraction, image extraction, and OCR capabilities for reading text within images across multiple languages.13MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI-powered extraction and analysis of PDF documents with 40+ specialized tools for text, tables, images, layout analysis, security assessment, and document intelligence. Supports both text-based and scanned PDFs with OCR capabilities.216 PyPI11MIT
- AlicenseNot gradedqualityDmaintenanceProvides random access to PDF contents with selective page extraction, text search, outline navigation, image extraction, and page rendering capabilities. Reduces token usage by allowing targeted content extraction instead of processing entire documents.4MIT
- AlicenseAqualityDmaintenanceEnables PDF processing and analysis including text extraction, metadata retrieval, search, page manipulation, splitting/merging, conversion to images, and form handling.10MIT