Markdown转PDF MCP服务器
MCP(模型上下文协议)服务器,用于将Markdown文档转换为具有可定制样式的格式精美的PDF文件。
特性
- 🎨 多个内置主题(GitHub、GitHub Dark、Minimal、Academic)
- 📝 自动生成目录
- 🌈 代码块的语法高亮显示
- 📄 自定义页面布局和边距
- 🔖 带变量的页眉和页脚
- 🖼️ 图像和SVG支持
- 📊 未来:美人鱼图和数学公式
安装
快速安装(推荐)
使用克劳德代码CLI:
claude mcp add markdown-pdf npx mcp-markdown-pdf或者手动添加到您的Claude配置中(~/.claude.json):
{
"mcpServers": {
"markdown-pdf": {
"command": "npx",
"args": ["mcp-markdown-pdf"]
}
}
}Playwright Chromium浏览器将在首次使用时自动安装。
手动安装(用于开发)
使用pnpm(推荐)
# Install dependencies
pnpm install
# Build the project
pnpm build
# Install Playwright browsers
pnpm exec playwright install chromium使用npm
# Install dependencies
npm install
# Build the project
npm run build
# Install Playwright browsers
npx playwright install chromium本地开发配置
添加到您的Claude配置中:
{
"mcpServers": {
"markdown-pdf": {
"command": "node",
"args": ["/absolute/path/to/markdown-pdf-mcp/dist/index.js"]
}
}
}项目结构
markdown-pdf-mcp/
├── src/
│ ├── index.ts # MCP server entry point
│ ├── tools/
│ │ ├── convert.ts # markdown_to_pdf tool
│ │ ├── batch.ts # Batch conversion
│ │ ├── themes.ts # Theme management
│ │ └── validate.ts # Markdown validation
│ ├── renderer/
│ │ ├── markdown-parser.ts # Markdown → HTML
│ │ ├── pdf-generator.ts # HTML → PDF (Playwright)
│ │ └── html-template.ts # HTML template generation
│ ├── themes/ # CSS theme utilities
│ ├── utils/ # Shared utilities
│ └── types/ # TypeScript types and Zod schemas
├── themes/ # CSS theme files
│ ├── github.css
│ ├── github-dark.css
│ ├── minimal.css
│ └── academic.css
└── dist/ # Build output用法
在Claude中配置后,您可以这样使用它:
User: Convert my README.md to PDF with GitHub theme
Claude: [Uses markdown_to_pdf tool to convert the file]发展
使用pnpm(推荐)
# Watch mode for development
pnpm dev
# Build for production
pnpm build使用npm
# Watch mode for development
npm run dev
# Build for production
npm run build许可证
麻省理工学院
