🚀 @mcp-z/mcp-pdf
Docs: https://mcp-z.github.io/mcp-pdf
このプロジェクトは、ドキュメント、レイアウト、画像エクスポートのためのPDF生成MCPサーバーです。
🚀 クイックスタート
一般的な用途
- テキストやレイアウトからPDFを生成します。
- PDFページを画像としてレンダリングします。
- レイアウト前にテキストのサイズを測定します。
トランスポート
MCPはstdioとHTTPをサポートしています。
Stdio
{
"mcpServers": {
"pdf": {
"command": "npx",
"args": ["-y", "@mcp-z/mcp-pdf"]
}
}
}
HTTP
{
"mcpServers": {
"pdf": {
"type": "http",
"url": "http://localhost:9010/mcp",
"start": {
"command": "npx",
"args": ["-y", "@mcp-z/mcp-pdf", "--port=9010"]
}
}
}
}
start は npx @mcp-z/cli up がHTTPサーバーを起動するために使用する拡張機能です。
使い方
mcp-z inspect --servers pdf --tools
mcp-z call pdf pdf-document '{"content":["Hello from MCP"]}'
✨ 主な機能
利用可能なツール
pdf-resume
JSON Resume形式からプロフェッショナルな履歴書を生成します。
パラメーター
filename (文字列、オプション) - PDFのファイル名(デフォルトは "resume.pdf")
resume (オブジェクト、必須) - JSON Resumeスキーマ
sections (オブジェクト、オプション) - セクションの順序とフィールドテンプレート
layout (オブジェクト、オプション) - 空間配置(シングルカラムまたは2カラム)
styling (オブジェクト、オプション) - タイポグラフィとスペーシングオプション
font (文字列、オプション) - カスタムフォント
pageSize (文字列、オプション) - ページサイズ(デフォルト: "LETTER")
backgroundColor (文字列、オプション) - ページの背景色
履歴書スキーマのセクション
basics - 名前、連絡先、概要、所在地
work - ハイライト付きの職務経歴
education - 学位と所属機関
projects - 個人/職業上のプロジェクト
skills - カテゴリ別にグループ化されたスキル
awards, certificates, languages, volunteer, publications, interests, references
セクションの構成
sections.sections を使用して、表示するセクションとその順序を制御できます。
await client.callTool('pdf-resume', {
resume: { },
sections: {
sections: [
{ source: 'basics', render: 'header' },
{ source: 'basics.summary', title: 'Summary' },
{ source: 'work', title: 'Experience' },
{ source: 'skills', title: 'Skills' },
{ source: 'education', title: 'Education' }
]
}
});
セクション構成のプロパティ
source (文字列、必須) - 履歴書スキーマ内のデータへのパス(例: basics, work, meta.customField)
render (文字列、オプション) - 組み込みのレンダラー。明示的に header を使用するか、レンダラーを強制するために使用します。
title (文字列、オプション) - セクションの見出し(見出しを省略する場合は空)
template (文字列、オプション) - カスタムレンダリング用のLiquidJSテンプレート
利用可能なレンダラー
header - 基本情報からの名前 + 連絡先ライン(自動推測されることはありません)
entry-list - 職位/所属機関/組織を持つ配列
keyword-list - keywords を持つ配列
language-list - language を持つ配列
credential-list - 授与者/発行者/出版社を持つ配列
reference-list - reference を持つ配列
text - 文字列または文字列配列
例: カスタムセクション順序とメタフィールド
await client.callTool('pdf-resume', {
resume: {
basics: { name: 'Jane Doe', email: 'jane@example.com' },
work: [{ }],
meta: { valueProp: 'Full-stack engineer with 10+ years experience...' }
},
sections: {
sections: [
{ source: 'basics', render: 'header' },
{ source: 'meta.valueProp', title: 'Value Proposition' },
{ source: 'work', title: 'Experience' }
]
}
});
フィールドテンプレート
フィールドテンプレートは、LiquidJS構文を使用してフィールドのレンダリング方法をカスタマイズします。
利用可能なフィールドテンプレート
location - {{ city }}{% if region %}, {{ region }}{% endif %}
dateRange - {{ start | date: 'MMM YYYY' }} - {{ end | date: 'MMM YYYY' | default: 'Present' }}
degree - {{ studyType }}{% if area %}, {{ area }}{% endif %}
credential - {{ title | default: name }}{% if awarder %}, {{ awarder }}{% endif %}
language - {{ language }}{% if fluency %} ({{ fluency }}){% endif %}
skill - {{ name }}: {{ keywords | join: ', ' }}
contactLine - {{ items | join: ' | ' }}
日付形式のトークン
YYYY, YY, MMMM, MMM, MM, M, DD, D
利用可能なフィルター
date - 日付文字列をフォーマットします。
default - 空の値の場合のフォールバックです。
tenure - 期間を計算します。
join - 配列要素を結合します。
例: フランス語の履歴書
await client.callTool('pdf-resume', {
filename: 'cv-francais.pdf',
resume: { },
sections: {
fieldTemplates: {
dateRange: "{{ start | date: 'MM/YYYY' }} - {{ end | date: 'MM/YYYY' | default: 'Present' }}",
location: '{{ city }}'
}
}
});
例: 詳細な日付形式
await client.callTool('pdf-resume', {
filename: 'resume.pdf',
resume: { },
sections: {
fieldTemplates: {
dateRange: "{{ start | date: 'MMMM YYYY' }} to {{ end | date: 'MMMM YYYY' | default: 'Present' }}"
}
}
});
2カラムの履歴書レイアウト
await client.callTool('pdf-resume', {
filename: 'two-column-resume.pdf',
resume: {
basics: {
name: 'Jane Doe',
label: 'Product Designer',
email: 'jane@example.com'
},
work: [{
name: 'Design Studio',
position: 'Lead Designer',
startDate: '2019-03',
highlights: ['Redesigned product UI', 'Increased conversion by 25%']
}],
skills: [
{ name: 'Design', keywords: ['Figma', 'Sketch', 'Adobe XD'] },
{ name: 'Frontend', keywords: ['HTML', 'CSS', 'React'] }
],
languages: [
{ language: 'English', fluency: 'Native' },
{ language: 'Spanish', fluency: 'Intermediate' }
]
},
layout: {
style: 'two-column',
gap: 30,
columns: {
left: { width: '30%', sections: ['skills', 'languages'] },
right: { width: '70%', sections: ['work'] }
}
}
});
レイアウトオプション
style - "single-column"(デフォルト)または "two-column"
gap - カラム間のスペース(ポイント単位、デフォルト: 30)
columns.left.width - 左カラムの幅(パーセンテージまたはポイント)
columns.left.sections - 左カラムのセクションソースパス
columns.right.width - 右カラムの幅
columns.right.sections - 右カラムのセクションソースパス
pdf-layout
正確な位置決めとYogaフレックスボックスレイアウトでPDFを作成します。
パラメーター
filename (文字列、オプション) - PDFのファイル名(デフォルトは "document.pdf")
title (文字列、オプション) - ドキュメントのメタデータ
author (文字列、オプション) - ドキュメントのメタデータ
pageSetup (オブジェクト、オプション) - ページの設定
content (配列、必須) - コンテンツアイテム
layout (オブジェクト、オプション) - レイアウトオプション
ページ設定
pageSetup: {
size: [612, 792],
margins: { top: 72, bottom: 72, left: 72, right: 72 },
backgroundColor: '#FFFFFF'
}
コンテンツタイプ
テキストと見出し
{
type: 'text',
text: 'Content here',
fontSize: 12,
bold: true,
color: '#000000',
align: 'left',
x: 100,
y: 200,
oblique: 15,
characterSpacing: 1,
moveDown: 1,
underline: true,
strike: true
}
形状
{ type: 'rect', x: 50, y: 50, width: 200, height: 100, fillColor: '#FF0000', strokeColor: '#000000', lineWidth: 2 }
{ type: 'circle', x: 300, y: 400, radius: 50, fillColor: '#00FF00', strokeColor: '#000000', lineWidth: 1 }
{ type: 'line', x1: 100, y1: 100, x2: 500, y2: 100, strokeColor: '#0000FF', lineWidth: 2 }
画像とページ
{ type: 'image', imagePath: '/path/to/image.png', width: 200, height: 150, x: 100, y: 200 }
{ type: 'pageBreak' }
フレックスボックスレイアウトエンジン
type: 'group' を使用してフレックスボックスコンテナを作成します。
{
type: 'group',
direction: 'row',
gap: 20,
flex: 1,
justify: 'center',
alignItems: 'center',
align: 'center',
width: 300,
height: 200,
padding: 15,
background: '#f5f5f5',
border: { color: '#333', width: 1 },
children: [
{ type: 'text', text: 'Child 1' },
{ type: 'text', text: 'Child 2' }
]
}
一般的なレイアウトパターン
2等分のカラム
{
type: 'group',
direction: 'row',
gap: 20,
children: [
{ type: 'group', flex: 1, children: [{ type: 'text', text: 'Left' }] },
{ type: 'group', flex: 1, children: [{ type: 'text', text: 'Right' }] }
]
}
比率が1:2:1の3カラム
{
type: 'group',
direction: 'row',
gap: 15,
children: [
{ type: 'group', flex: 1, children: [] },
{ type: 'group', flex: 2, children: [] },
{ type: 'group', flex: 1, children: [] }
]
}
中央配置のカード
{
type: 'group',
width: 300,
align: 'center',
border: { color: '#333', width: 2 },
padding: 20,
children: [
{ type: 'heading', text: 'Card Title', align: 'center' },
{ type: 'text', text: 'Card content here' }
]
}
アイテム間のスペース
{
type: 'group',
direction: 'row',
justify: 'space-between',
children: [
{ type: 'text', text: 'Left' },
{ type: 'text', text: 'Right' }
]
}
混合配置
await client.callTool('pdf-layout', {
layout: { overflow: 'auto' },
content: [
{ type: 'heading', text: 'TITLE', x: 54, y: 50 },
{
type: 'group',
direction: 'row',
gap: 20,
x: 54,
y: 100,
children: [
{ type: 'group', flex: 1, children: [] },
{ type: 'group', flex: 1, children: [] }
]
},
{ type: 'text', text: 'Footer', x: 54, y: 700 }
]
});
完全なチラシの例
await client.callTool('pdf-layout', {
pageSetup: { backgroundColor: '#fffef5' },
content: [
{ type: 'heading', text: 'SUMMER FESTIVAL 2024', align: 'center', fontSize: 28, y: 50 },
{ type: 'text', text: 'July 15-17 | Central Park', align: 'center', y: 90 },
{
type: 'group',
direction: 'row',
gap: 20,
x: 54,
y: 130,
children: [
{
type: 'group',
flex: 1,
border: { color: '#2196f3', width: 2 },
padding: 15,
children: [
{ type: 'heading', text: 'MUSIC', align: 'center', fontSize: 18 },
{ type: 'text', text: 'Live bands all weekend' },
{ type: 'text', text: '- Main Stage' },
{ type: 'text', text: '- Acoustic Tent' }
]
},
{
type: 'group',
flex: 1,
border: { color: '#4caf50', width: 2 },
padding: 15,
children: [
{ type: 'heading', text: 'FOOD', align: 'center', fontSize: 18 },
{ type: 'text', text: '50+ local vendors' },
{ type: 'text', text: '- Food Court' },
{ type: 'text', text: '- Craft Beers' }
]
}
]
},
{
type: 'group',
width: 300,
align: 'center',
y: 400,
border: { color: '#ff9800', width: 2 },
padding: 15,
background: '#fff8e1',
children: [
{ type: 'heading', text: 'TICKETS', align: 'center', fontSize: 16 },
{ type: 'text', text: 'Early Bird: $25', align: 'center' },
{ type: 'text', text: 'At Door: $35', align: 'center' }
]
}
]
});
絵文字とUnicodeのサポート
カラー絵文字はインライン画像としてレンダリングされます。Unicodeテキストは主要なスクリプトでサポートされています。
{
"basics": {
"name": "John Doe",
"summary": "Developer passionate about clean code"
}
}
pdf-document
自動ページ分割機能を持つ流れるようなPDFドキュメントを作成します。
pdf-image
PDFページをPNG画像にレンダリングして、プレビューまたはエクスポートするために使用します。
text-measure
レイアウト前にテキストの幅と高さを測定します。
ツール一覧
- pdf-document
- pdf-image
- pdf-layout
- pdf-resume
- text-measure
外部リソース
外部リソースはありません。
プロンプト
- resource-fetching
リソース
- PDFKit Documentation
- JSON Resume Schema
- JSON Resume Editor