@tscodex/mcp-pdf
v0.1.1
Published
MCP server for generating PDF documents from Markdown, HTML, and URLs using Playwright
Maintainers
Readme
@tscodex/mcp-pdf
MCP server for generating PDF documents from Markdown, HTML, and URLs using Playwright.
Official website: http://tscodex.com/
Built on @tscodex/mcp-sdk - This project uses the official TSCodex MCP SDK for server infrastructure, authentication, configuration management, and protocol handling.
Managed by MCP Manager - Use the MCP Manager desktop application for workspace isolation, visual configuration, and seamless integration with Cursor. The MCP Manager Bridge VS Code extension provides a bridge to manage MCP servers directly from your IDE.
Features
- PDF from Markdown - Convert
.mdfiles or content to styled PDF with themes - PDF from HTML - Convert
.htmlfiles or content to PDF - PDF from URL - Generate PDF from web pages
- Custom Styling - CSS themes, syntax highlighting
- Page Formatting - Sizes, margins, headers, footers, page numbers
- RTL Support - Hebrew, Russian, English with auto-direction
- Table of Contents - Auto-generated TOC from headings
- Multiple Files - Concatenate multiple markdown files into one PDF
Installation
npm install @tscodex/mcp-pdfAfter installation, Playwright will automatically install Chromium.
Tools
pdf_from_markdown
Convert Markdown to PDF with styling and syntax highlighting.
{
"content": "# Hello World\n\nThis is **markdown**.",
"outputPath": "docs/hello.pdf"
}Or from file:
{
"filePath": "README.md",
"outputPath": "docs/readme.pdf",
"theme": "github",
"toc": true
}Or multiple files (comma-separated, keeps your order):
{
"files": "docs/intro.md, docs/api.md, docs/examples.md",
"outputPath": "docs/full-documentation.pdf",
"theme": "docs",
"toc": true,
"title": "API Documentation"
}Or with glob pattern (auto-sorted by numeric prefix):
{
"glob": "docs/*.md",
"outputPath": "docs/full-documentation.pdf",
"theme": "docs",
"toc": true
}Glob sorting: Files matched by glob are automatically sorted by numeric prefix:
1.intro.md→2.api.md→10.appendix.md→readme.md- Files without prefix are sorted alphabetically at the end
Using baseUrl for dynamic image URLs:
In your markdown, use {{BASE_URL}} placeholder:
Then provide baseUrl in the tool call:
{
"filePath": "docs/readme.md",
"baseUrl": "https://prod.example.com",
"outputPath": "docs/output.pdf"
}Parameters:
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| content | string | * | Markdown content |
| filePath | string | * | Path to .md file |
| files | string | * | Comma-separated .md file paths (keeps order) |
| glob | string | * | Glob pattern for .md files (auto-sorted by numeric prefix) |
| outputPath | string | ✓ | Output PDF path |
| title | string | | Document title |
| coverImage | string | | Cover image URL (HTTPS only) |
| baseUrl | string | | Base URL for {{BASE_URL}} substitution (http/https) |
| theme | enum | | github, minimal, docs |
| css | string | | Custom CSS |
| codeHighlight | boolean | | Syntax highlighting (default: true) |
| toc | boolean | | Generate table of contents |
| tocDepth | number | | TOC depth 1-6 (default: 3) |
| author | string | | PDF metadata |
| subject | string | | PDF metadata |
| keywords | string[] | | PDF metadata |
| pageSize | enum | | A4, Letter, Legal |
| landscape | boolean | | Landscape orientation |
| margins | object | | {top, right, bottom, left} |
| displayHeaderFooter | boolean | | Show header/footer |
| headerTemplate | string | | HTML header template |
| footerTemplate | string | | HTML footer template |
*One of content, filePath, or files is required.
pdf_from_html
Convert HTML content or file to PDF.
{
"content": "<html><body><h1>Report</h1></body></html>",
"outputPath": "reports/report.pdf"
}Parameters:
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| content | string | * | HTML content |
| filePath | string | * | Path to .html file |
| outputPath | string | ✓ | Output PDF path |
| pageSize | enum | | Page size |
| landscape | boolean | | Landscape orientation |
| margins | object | | Page margins |
| printBackground | boolean | | Include backgrounds (default: true) |
| scale | number | | Scale factor 0.1-2.0 |
| displayHeaderFooter | boolean | | Show header/footer |
| headerTemplate | string | | HTML header |
| footerTemplate | string | | HTML footer |
*One of content or filePath is required.
pdf_from_url
Generate PDF from a web page.
{
"url": "https://example.com/article",
"outputPath": "saved/article.pdf"
}With wait options:
{
"url": "https://app.example.com/dashboard",
"outputPath": "reports/dashboard.pdf",
"waitForSelector": ".charts-loaded",
"waitFor": 1000,
"printBackground": true
}Parameters:
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| url | string | ✓ | Web page URL |
| outputPath | string | ✓ | Output PDF path |
| pageSize | enum | | Page size |
| landscape | boolean | | Landscape orientation |
| margins | object | | Page margins |
| printBackground | boolean | | Include backgrounds |
| waitFor | number | | Wait ms after load |
| waitForSelector | string | | Wait for element |
| timeout | number | | Page load timeout |
| displayHeaderFooter | boolean | | Show header/footer |
| headerTemplate | string | | HTML header |
| footerTemplate | string | | HTML footer |
Themes
github (default)
GitHub-flavored markdown styling:
- Clean sans-serif typography
- Styled code blocks with syntax highlighting
- Tables with borders
- Blockquotes with left border
minimal
Print-optimized minimal styling:
- Serif font for readability
- Simple black & white
- Good for printing
docs
Professional documentation style:
- Modern sans-serif typography
- Beautiful light design
- RTL support for Hebrew, Russian, English
- Professional look with subtle colors
Header/Footer Templates
Playwright supports special CSS classes:
<!-- Footer with page numbers -->
<div style="font-size: 10px; text-align: center; width: 100%;">
Page <span class="pageNumber"></span> of <span class="totalPages"></span>
</div>Available classes:
pageNumber- current pagetotalPages- total pagesdate- formatted datetitle- document title
Configuration
Create .mcp-pdf.json in your project:
{
"defaultPageSize": "A4",
"defaultTheme": "github",
"codeHighlight": true,
"defaultMargins": {
"top": "20mm",
"right": "20mm",
"bottom": "20mm",
"left": "20mm"
}
}License
MIT
