Precision PDF MCP Server
Precision PDF MCP Server lets AI agents inspect PDF form/worksheet layouts and inject clean, precisely positioned answers.
Generate temporary Virtual Excel grid inspector images with Set-of-Marks slot badges and a JSON catalog of detected slots, including grid addresses, context, question hints, type, baseline, and size.
Fill detected slots by slot ID with answers, supporting multi-line text, Unicode/diacritics, option circles, cross marks, connector lines, and option underlines.
Ensure baseline-snapped, box-centered, auto-wrapped, and auto-scaled text while keeping final PDFs clean with no grid or badges.
Render final clean PDF pages to PNG images for visual QA verification.
Provide backward-compatible aliases for inspection, filling, and render verification.
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., "@Precision PDF MCP Server inspect the answer slots in /home/user/worksheet.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.
π― Precision PDF MCP Server (precision-pdf-mcp)
Pixel-Perfect PDF Form and Worksheet Filling for AI Coding Agents.
Powered by Hybrid Vector-Raster Geometry, Set-of-Marks (SoM), and Virtual Excel Grounding.
π‘ Why Precision PDF?
Filling assignment worksheets, tax forms, and scanned PDF workbooks has always been a painful failure mode for Large Language Models (LLMs):
β The "Floating Text" Bug: LLMs guess raw
(x, y)floats, causing answers to float aimlessly above or below lines.β The "Collision" Bug: Answers smash directly into printed text (e.g.,
Heis going,Parentsmust,1)wear).β The "Scanned PDF" Blindspot: Most PDF tools rely only on vector drawings. Scanned workbooks have 0 vector lines, leaving AI completely blind.
β Multi-Line Truncation: Long answers get crammed into line 1 or truncated because the agent doesn't realize two lines are printed for that question.
Precision PDF solves this once and for all.
Related MCP server: doc-intel MCP server
π Key Innovations
[ Input PDF: Digital or Scanned Workbook ]
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β 1. Tri-Layer Hybrid Detector β
β β’ Vector Lines & Rects (pdfplumber) β
β β’ In-Memory Morphological Line Scanner (NumPy) β
β Detects physical lines in scanned images in RAM! β
β β’ Text Anchors & Gap Numbers (1), 2., He_________) β
βββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β 2. Context Guards & Smart Layout β
β β’ Padding Guard: Auto +6pt..+10pt margin after β
β printed subjects (He, You, Jenny...) β
β β’ Multi-Line Grouping: Detects stacked lines & auto- β
β wraps long sentences at natural word boundaries β
β β’ Auto-Scale Font: Scales down font to prevent crash β
βββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β 3. Virtual Excel Matrix & Set-of-Marks (Agent View) β
β β’ Renders Top Columns (A, B, C...) & Rows (1, 2, 3) β
β β’ Badges targets: [S01], [S02], [S03]... β
β β’ STRICTLY VIRTUAL: Only for the agent to inspect! β
βββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β 4. Clean Vector Injection (Output PDF) β
β β’ Baseline Snapped: Text rests 1.2pt above line β
β β’ Centered in Boxes: Dead-center horizontally & vert β
β β’ Crisp Circles / Underlines: Vector option markers β
β β’ ZERO GRID POLLUTION: Output PDF is 100% clean! β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββπ¦ Installation & Quickstart
Method 1: Instant Run with uvx (Recommended)
No installation required. Run directly in Claude Desktop or Cursor via uvx:
uvx precision-pdf-mcpMethod 2: Install via pip
pip install precision-pdf-mcpMethod 3: From Source (Local Development)
git clone https://github.com/zuan412/precision-pdf-mcp.git
cd precision-pdf-mcp
pip install -e .π οΈ MCP Client Configuration
1. Claude Desktop
Add to your claude_desktop_config.json:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"precision-pdf": {
"command": "uvx",
"args": ["precision-pdf-mcp"]
}
}
}2. Cursor IDE
Add to Cursor Settings -> MCP Servers (~/.cursor/mcp.json):
{
"mcpServers": {
"precision-pdf": {
"command": "uvx",
"args": ["precision-pdf-mcp"]
}
}
}3. Antigravity / Gemini CLI / Windsurf / Cline
In your mcp_config.json:
{
"mcpServers": {
"precision-pdf": {
"command": "python",
"args": ["-m", "precision_pdf"]
}
}
}π§° Available MCP Tools
hpe_inspect_virtual_grid
Generates a temporary Virtual Excel Matrix inspector image with Set-of-Marks badges ([S01], [S02]...) and returns a JSON catalog of detected slots enriched with Semantic Context Grounding.
Arguments:
pdf_path(string, required): Absolute path to the PDF.page_number(int, required): 1-based page number.dpi(int, optional, default: 150): Image resolution.
Returns:
inspector_image_path: Path to the image for agent visual inspection.slots: Dictionary of slots containing:grid_address: Virtual Excel coordinate (e.g.Col D, Row 14).context: Preceding prompt text extracted from the page (e.g."1. Jenny decided to ________").question_hint: Question number or letter (e.g."1").type,baseline_y,width,height.
hpe_fill_slots
Injects answers directly into the target PDF using Slot IDs or explicit primitives with 100% Unicode & Diacritics support.
Arguments:
pdf_path(string, required): Absolute path to the PDF.page_number(int, required): 1-based page number.slot_answers_json(string, required): JSON string of answers.Slot map:
{"S01": "must have left", "S02": "tiαΊΏng Viα»t cΓ³ dαΊ₯u"}Multi-line wrap:
{"S03": ["first line text", "second line text"]}Option circle (scoped):
{"circle_option": {"word": "B", "question_hint": "3"}}Cross mark:
{"cross_01": {"cx": 120.0, "cy": 350.0}}Connector line:
{"connector_01": {"from": [100, 200], "to": [300, 250]}}Option underline:
{"underline_option": "Shall"}
output_path(string, optional): Output PDF path. If omitted, safely updates in-place.
Guarantees:
100% baseline snap (rests naturally on the printed line).
Full Unicode Vietnamese support (auto-embeds TTF with proper diacritics).
Zero grid pollution (no rulers or badges in final output).
hpe_render_clean_verify
Renders the final, clean PDF page to an image for visual QA verification.
Arguments:
pdf_path(string, required): Path to the completed PDF.page_number(int, required): 1-based page number.dpi(int, optional, default: 150): Output DPI.
π§ͺ Testing
Run the included unit test suite:
python -m unittest discover -s testsπ‘οΈ Zero Disk Pollution & Safety Guarantee
Precision PDF is engineered to run in memory:
All morphological line detection and raster scanning execute in RAM via NumPy arrays and
io.BytesIO.Temporary inspector previews use OS-standard
tempfile.gettempdir()/precision_pdfor the$PRECISION_PDF_TEMP_DIRenvironment variable.Stdio JSON-RPC communication is 100% isolated: all logs, warnings, and internal debug outputs route strictly to
sys.stderr.
π License
MIT License. See LICENSE for details. Built with β€οΈ for the AI agent pair-programming community.
Available Tools
6 toolshpe_fill_slotsA
Inject answers into the PDF using Slot IDs (e.g. {"S01": "answer", "S02": "B"}). Guarantees:
100% baseline snap on printed lines (zero floating text).
100% center alignment in boxes (zero off-center boxes).
Automatic multi-line wrapping across consecutive lines for long answers.
Automatic font scaling to avoid text collision or overflow.
100% CLEAN OUTPUT: Final PDF contains ONLY answers (zero grid lines, zero badges). Args: pdf_path: Path to target PDF. page_number: 1-based page number. slot_answers_json: JSON string mapping slot tags to answers: e.g. '{"S01": "went", "S02": ["line 1 text", "line 2 text"], "circle_option": "A"}'
output_path: Optional output path. If omitted, overwrites safely via atomic replace. Returns status JSON with saved path.
Inputs: pdf_path (required), page_number (required), slot_answers_json (required), output_path. Returns: result
hpe_inspect_geometryC
Backward compatibility alias for hpe_inspect_virtual_grid.
Inputs: pdf_path (required), page_number (required). Returns: result
hpe_inspect_virtual_gridB
Generate a temporary Virtual Excel Grid Inspector Image with Set-of-Marks (SoM) slot badges. This image overlays:
Top Excel column letters (A, B, C...)
Left Excel row numbers (1, 2, 3...)
Labeled slot pill badges: [S01], [S02], [S03]... on every detected blank, underline, or box. Returns JSON containing:
inspector_image_path: Path to the image (view it via view_file to visually inspect the layout!)
slots: Catalog of detected slots with tag, type, baseline, and Excel grid address (e.g. Col K, Row 9). NOTE: This is strictly a virtual guide for the agent's eyes; it does NOT alter the PDF!
Inputs: pdf_path (required), page_number (required), dpi. Returns: result
hpe_render_clean_verifyB
Render the final, clean PDF page (with answers, WITHOUT any grid or badges) to a high-resolution PNG image for visual QA before submission.
Inputs: pdf_path (required), page_number (required), dpi. Returns: result
hpe_render_verifyC
Backward compatibility alias for hpe_render_clean_verify.
Inputs: pdf_path (required), page_number (required), dpi. Returns: result
hpe_snap_fillC
Backward compatibility alias for hpe_fill_slots.
Inputs: pdf_path (required), page_number (required), operations_json (required), output_path. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogβ¦
TDQS
Scored across 6 tools
Three of the six tools (hpe_inspect_geometry, hpe_snap_fill, hpe_render_verify) are explicit backward-compatibility aliases that duplicate hpe_inspect_virtual_grid, hpe_fill_slots, and hpe_render_clean_verify respectively. An agent faces real ambiguity about which name to call, even though the descriptions confess the aliasing. Only three genuinely distinct purposes exist.
Every tool uses the same hpe_ prefix and snake_case verb_noun convention (render_clean_verify, inspect_virtual_grid, fill_slots, inspect_geometry, snap_fill, render_verify). The pattern is predictable throughout with no style mixing.
Six tools nominally sits in a healthy range, but half are redundant aliases, leaving an effective surface of only three distinct operations. That makes the set feel thin for the scope despite the raw count looking fine.
The core lifecycle is covered: inspect the virtual grid to find slots, fill slots with answers, and render a clean page for visual QA. Minor gaps exist (no PDF text extraction or batch/multi-page handling), but the primary workflow has no dead ends.
Maintenance
Related MCP Connectors
Detect, review and fill existing PDF forms from JSON or Excel; reuse saved templates
Verified OCR with per-value coordinates, plus a workspace agents can file documents into and query.
Read PDFs, photos and emails into structured fields; check, correct and approve the results.
Detect fillable fields in any PDF with AI, scans included, then fill and sign it.
Related MCP Servers
- 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
- FlicenseNot gradedqualityDmaintenanceEnables AI agents to extract structured data from PDFs with confidence scores and provenance, and to search, review, and correct documents via MCP tools, resources, and prompts.-
- AlicenseNot gradedqualityCmaintenanceInteractive PDF workspace shared by a human operator and an AI agent, enabling navigation, search, text extraction, annotations, form filling, and save actions via a PDF.js viewer.MIT
- AlicenseBqualityBmaintenanceLets AI assistants read, search, edit, annotate, sign, redact and OCR PDF files entirely on the local machine, with no uploads and non-destructive writes to new files. It also merges, splits and reorganises pages, fills forms, compares versions to detect tampering, and converts documents between PDF, Word, Excel, images and text, including turning bank statements into spreadsheet rows.22AGPL 3.0