xfa-pdf-mcp
Enables ChatGPT and OpenAI Agents SDK/Responses API workflows to read and fill XFA-PDF forms, including field listing, batch filling, dynamic row management, and PDF download.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
xfa-pdf-mcp
An MCP (Model Context Protocol) server for reading and filling XFA-PDF form fields. Built for Canadian immigration forms (IRCC IMM series) but works with any XFA-PDF.
Tested against 95+ IRCC immigration forms with 100% roundtrip success.
Quick Start (Hosted)
No installation required. Connect to the hosted MCP server with one step.
ChatGPT
Go to Settings > Developer Mode (enable if needed)
Go to Connectors > Add MCP Server
Enter URL:
https://xfa-pdf-mcp.vflo.app/mcpName it "XFA PDF Filler" and save
Then ask ChatGPT: "Upload imm5257e.pdf and fill in FamilyName=KIM, GivenName=YULBIN"
Claude Code
claude mcp add --transport http xfa-pdf https://xfa-pdf-mcp.vflo.app/mcpClaude Desktop
Add to claude_desktop_config.json:
{
"mcpServers": {
"xfa-pdf": {
"type": "streamable-http",
"url": "https://xfa-pdf-mcp.vflo.app/mcp"
}
}
}OpenAI Agents SDK / Responses API
# Connect as an MCP tool source
tool = {"type": "mcp", "server_url": "https://xfa-pdf-mcp.vflo.app/mcp"}Related MCP server: omapdf-mcp
Self-Hosted Setup
Option 1: Docker (Recommended)
docker run -p 8080:8080 ghcr.io/visaflo/xfa-pdf-mcpThen connect Claude:
claude mcp add --transport http xfa-pdf http://localhost:8080/mcpOption 2: Local (stdio)
Requires Python 3.11+.
git clone https://github.com/VisaFlo/xfa-pdf-mcp.git
cd xfa-pdf-mcp
python3 -m venv .venv
.venv/bin/pip install -e .claude mcp add --transport stdio --scope user xfa-pdf-mcp \
/path/to/xfa-pdf-mcp/.venv/bin/python -- -m xfa_pdf_mcp.serverHow It Works
XFA-PDFs embed form definitions and data as XML inside a PDF container. This server:
Opens the PDF with
pikepdfExtracts the XFA
datasetsXML (form data) andtemplateXML (field definitions)Builds a metadata cache of all fields, including LOV (List of Values) dropdown options
Fills fields by modifying the datasets XML, auto-resolving labels to codes
Writes the modified XML back and saves a new PDF
No Adobe Acrobat needed for filling. Output PDFs must be opened in Adobe Reader/Acrobat to render correctly (browsers don't support XFA).
Tools
Tool | Description |
| Upload a PDF via URL or base64. URL is preferred for large files. |
| List all fillable fields with paths, types, values, and dropdown options |
| Get current values for specific field paths |
| Batch-fill fields with auto-resolution of labels, checkboxes, and dates |
| Download the filled PDF as base64 |
| Close and free resources |
| List dynamic row sections (dependants, children, employment, etc.) |
| Add a new row to a repeating section |
Upload options:
upload_pdfaccepts eitherpdf_url(HTTP/HTTPS link to the PDF) orpdf_base64(inline base64). URL is recommended for large files to avoid payload size limits.For local stdio mode,
upload_pdf/download_pdfare replaced byopen_pdf(file path) /save_pdf(file path).
Workflow
upload_pdf -> list_fields -> fill_fields -> download_pdf -> close_pdfFor forms with dynamic rows:
upload_pdf -> list_repeating_sections -> add_row (repeat) -> download_pdf -> close_pdfSmart Value Resolution
The server automatically resolves human-readable values to the correct form codes.
Dropdowns (choiceList)
Pass display labels instead of codes. The engine extracts LOV (List of Values) from the form's datasets XML and resolves automatically.
"Canada" -> "511"
"Married" -> "01"
"Korea, South" -> "258"
"BC" -> "11"
"Vancouver" -> "8634"Cascade-dependent dropdowns (province depends on country, city depends on province) are handled by merging all LOV lists.
Checkboxes (checkButton)
Pass boolean-like values. The engine reads the correct on/off values from the template.
"true" -> "Y" (or "N", "1", etc. depending on the field)
"false" -> "" (or "0", etc.)Accepted inputs: true/false, yes/no, checked/unchecked, on/off, 1/0
Dates (dateTimeEdit / picture)
Pass dates in any common format. The engine normalizes to YYYY-MM-DD.
"01/15/2025" -> "2025-01-15"
"20250115" -> "2025-01-15"
"January 15, 2025" -> "2025-01-15"
"2025/01/15" -> "2025-01-15"Dynamic Rows
Some forms have repeating sections (dependants, children, employment history, etc.) where rows can be dynamically added:
# List available repeating sections
sections = list_repeating_sections(doc_id)
# -> [{"path": "IMM_5707/page1/SectionB/Child", "max": -1, "current_count": 4, ...}]
# Add a new row
add_row(doc_id, "IMM_5707/page1/SectionB/Child", {
"FamilyName": "SIMPSON",
"GivenName": "BART",
"Relationship": "Son",
"DOBYear": "2005",
})Example
"Open the IMM5257 form at ~/Downloads/imm5257e.pdf, list the personal details fields, fill in: FamilyName=KIM, GivenName=YULBIN, Sex=Male, PlaceBirthCountry=Korea South, Citizenship=Korea South, DOBYear=1990, DOBMonth=01, DOBDay=15. Save to ~/Desktop/imm5257_filled.pdf"
Field Types
Type | Description |
| Free text input |
| Dropdown with LOV options (auto-resolved) |
| Checkbox (auto-resolved from true/false) |
| Date picker (auto-normalized to YYYY-MM-DD) |
| Number input |
| Masked input (dates, postal codes) |
| Auto-generated barcode (read-only) |
| Signature field |
Testing
# All tests (42 total)
.venv/bin/pytest tests/ -v
# Unit tests only
.venv/bin/pytest tests/test_engine.py tests/test_engine_bytes.py -v
# Integration tests (require IMM PDFs in ~/Downloads/)
.venv/bin/pytest tests/test_integration.py -vTested Forms
Verified with 95+ IRCC immigration forms including:
Form | Description |
IMM 0008 | Generic Application Form for Canada |
IMM 1283 | Financial Evaluation |
IMM 1294 | Application for Study Permit |
IMM 1295 | Application for Work Permit |
IMM 1344 | Application for Sponsorship |
IMM 5257 | Application for Temporary Resident Visa |
IMM 5406 | Additional Family Information |
IMM 5409 | Statutory Declaration of Common-law Union |
IMM 5476 | Use of a Representative |
IMM 5490 | Sponsorship Agreement and Undertaking |
IMM 5532 | Relationship Information |
IMM 5562 | Supplementary Information - Your Travels |
IMM 5645 | Family Information |
IMM 5707 | Family Information (IMM 5707) |
IMM 5708 | Application for Visitor Permit |
IMM 5709 | Application for Study Permit (in-Canada) |
IMM 5710 | Application for Work Permit (in-Canada) |
IMM 5768 | Financial Evaluation for Super Visa |
Architecture
+------------------+
| XfaPdfEngine |
| (pikepdf+lxml) |
+--------+---------+
|
+---------------+---------------+
| |
+---------v----------+ +-----------v-----------+
| Local MCP Server | | Remote MCP Server |
| (stdio) | | (streamable-http) |
| server.py | | server_remote.py |
+--------------------+ +-----------------------+
| |
Claude Code/Desktop ChatGPT, Claude Desktop,
(local install) Claude Code, OpenAI Agents
(hosted — no install)Deployment
Google Cloud Run
gcloud run deploy xfa-pdf-mcp --source . --region us-central1 --allow-unauthenticatedDocker
docker build -t xfa-pdf-mcp .
docker run -p 8080:8080 xfa-pdf-mcpLimitations
Output PDFs must be opened in Adobe Reader/Acrobat (not Chrome, Preview, or Firefox)
Fields with
bind="none"in the template cannot be filled via datasetsEmbedded JavaScript validation only runs in Adobe Reader
Digital signatures are stripped on save (required to avoid "certification invalid" warnings)
A small number of forms (e.g. IMM 5444) have no LOV data; dropdowns require raw code values
Non-XFA PDFs (AcroForm only) are not supported
License
MIT
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
PDF tools for AI agents: fill, merge, edit, read text and tables, create, protect and invoice PDFs.
File tools for your AI chat: PDF tables to Excel, merge PDFs, images to PDF, fill PDF forms.
AI-powered PDF tools: fill forms via natural language
Fill existing fillable, flat and scanned PDF forms from structured data; save reusable templates
Related MCP Servers
- AlicenseAqualityBmaintenanceFill any PDF form with AI agents — ML field detection on scans, visual review loop, reusable templates, and native AcroForm fill via justfill.app.1440 PyPIMIT
- AlicenseNot gradedqualityCmaintenanceGives AI agents tools to read PDFs, list form fields, apply operations, highlight, add notes, fill fields, place signatures, list signatures, and flatten PDFs.1AGPL 3.0
- FlicenseNot gradedqualityCmaintenanceEnables AI agents to perform comprehensive PDF operations locally, including compression, text extraction, PII redaction, page organization, splitting, merging, watermarking, creation, and form filling, all without cloud uploads.22 npm-
- FlicenseAqualityCmaintenanceEnables AI agents to automatically inspect and fill web application forms on job application sites through a logged-in Chrome, supporting text, select, radio, date, cascading dropdowns, and dynamic row operations.4-