npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

enhanced-markdown2pdf-mcp

v1.0.1

Published

Enhanced MCP server for converting markdown to PDF with performance optimizations

Readme

Enhanced Markdown2PDF MCP Server

TypeScript Node.js MCP

一个功能强大、性能优异的Markdown转PDF MCP服务器,基于Puppeteer和Chrome for Testing构建。

✨ 核心特性

🚀 性能优化

  • 浏览器连接池: 复用浏览器实例,减少启动开销
  • 智能缓存: HTML渲染结果缓存,避免重复处理
  • 并行处理: 支持批量转换,显著提升效率
  • 资源管理: 自动清理临时文件和内存

🎨 丰富功能

  • 多种模板: 内置defaultacademicmodern三种专业模板
  • 语法高亮: 支持100+编程语言的代码高亮
  • Mermaid图表: 完美渲染流程图、时序图等
  • 水印支持: 可配置透明度、大小、颜色、旋转角度
  • 任务列表: 支持GitHub风格的复选框列表
  • 警告框: 支持NOTE、TIP、WARNING等提示框

🔧 高级配置

  • 灵活的页面设置: 支持多种纸张尺寸和方向
  • 自定义边距: 精确控制页面边距
  • 批量处理: 一次转换多个文档
  • 进度监控: 实时转换进度反馈

📦 安装和使用

安装依赖

npm install

构建项目

npm run build

启动服务器

npm start

🛠️ MCP工具

1. convert_markdown_to_pdf

转换单个Markdown文档为PDF

参数:

  • markdown (必填): Markdown内容
  • outputFilename: 输出文件名,默认output.pdf
  • template: 模板名称 (default|academic|modern)
  • paperFormat: 页面格式 (a4|a3|a5|letter|legal|tabloid)
  • paperOrientation: 页面方向 (portrait|landscape)
  • margin*: 页面边距设置
  • watermark: 水印配置对象
  • enableSyntaxHighlight: 启用语法高亮
  • enableMermaid: 启用Mermaid图表
  • enableCache: 启用缓存

示例:

{
  "markdown": "# 标题\n\n这是内容",
  "outputFilename": "report.pdf",
  "template": "academic",
  "watermark": {
    "text": "DRAFT",
    "opacity": 0.2,
    "fontSize": 80,
    "color": "#ff0000",
    "rotation": -45
  }
}

2. batch_convert_markdown_to_pdf

批量转换多个Markdown文档

参数:

  • conversions: 转换任务数组
  • commonSettings: 公共设置

示例:

{
  "conversions": [
    {"markdown": "# Doc1", "outputFilename": "doc1.pdf", "template": "default"},
    {"markdown": "# Doc2", "outputFilename": "doc2.pdf", "template": "modern"}
  ],
  "commonSettings": {
    "paperFormat": "a4",
    "enableCache": true
  }
}

3. list_templates

获取可用模板列表

4. get_template_info

获取指定模板的详细信息

5. get_server_stats

获取服务器性能统计信息

🎨 内置模板

Default 模板

  • 经典GitHub风格
  • 适合技术文档和README

Academic 模板

  • 学术论文样式
  • 优雅的Crimson Text字体
  • 适合正式文档

Modern 模板

  • 现代简洁设计
  • Inter字体,优秀的可读性
  • 适合商业文档

⚙️ 环境变量

| 变量名 | 说明 | 默认值 | |--------|------|--------| | M2P_OUTPUT_DIR | 输出目录 | 用户主目录 | | M2P_MAX_CONCURRENT | 最大并发数 | 2 | | M2P_MAX_BROWSERS | 最大浏览器数 | 3 | | M2P_DISABLE_CACHE | 禁用缓存 | false |

📝 支持的Markdown功能

✅ 完全支持

  • 标题 (H1-H6)
  • 文本格式 (粗体、斜体、删除线)
  • 列表 (有序、无序、任务列表)
  • 代码块和行内代码
  • 表格
  • 引用块
  • 链接和图片
  • Mermaid图表
  • GitHub风格警告框

⚠️ 限制

  • 不支持LaTeX数学公式
  • 复杂的HTML嵌入可能有兼容性问题

🏗️ 架构设计

enhanced-markdown-pdf/
├── src/
│   ├── core/                # 核心模块
│   │   ├── BrowserPool.ts   # 浏览器连接池
│   │   ├── CacheManager.ts  # 缓存管理
│   │   ├── TemplateManager.ts # 模板管理
│   │   ├── MarkdownRenderer.ts # Markdown渲染
│   │   ├── PDFGenerator.ts  # PDF生成
│   │   └── EnhancedConverter.ts # 转换引擎
│   ├── types/
│   │   └── index.ts         # 类型定义
│   └── index.ts            # MCP服务器主入口
├── templates/              # 自定义模板
└── dist/                 # 编译输出

🚀 性能特点

  • 启动速度: 浏览器池预热,首次转换更快
  • 内存效率: 智能缓存和资源清理
  • 并发处理: 支持多文档同时转换
  • 错误恢复: 优雅的错误处理和自动重试

📄 License

MIT License - 详见 LICENSE 文件。

🤝 贡献

欢迎提交Issue和Pull Request!

📞 支持

如有问题或建议,请提交Issue或联系开发团队。