mcp-pandoc: A Document Conversion MCP Server

mcp-pandoc: A Document Conversion MCP Server

site icon
2024.12.30 160
Python文档转换内容生成内容生成
mcp-pandoc 是一个基于 Model Context Protocol 的文档格式转换服务器,使用 pandoc 工具实现不同文档格式之间的转换。该服务器支持多种文档格式的转换,包括 markdown、html、pdf、docx、rst、latex、epub 和 txt 等。核心功能包括内容转换、文件格式转换以及支持高级格式的转换(如 PDF、DOCX 等)。适用场景包括文档处理、内容生成、格式转换等。
View on GitHub

Overview

基本能力

产品定位

mcp-pandoc 是一个文档格式转换服务器,旨在提供高效的文档格式转换工具,支持多种输入和输出格式。

核心功能

  1. 内容转换:支持将内容从一种格式转换为另一种格式,如 markdown 转 HTML、PDF 等。
  2. 文件格式转换:支持直接转换文件格式,如 .md 转 .pdf。
  3. 高级格式支持:支持 PDF、DOCX、RST、LaTeX 和 EPUB 等高级格式的转换。

适用场景

  1. 文档处理:需要将文档从一种格式转换为另一种格式的场景。
  2. 内容生成:生成不同格式的内容,如将 markdown 转换为 PDF 或 DOCX。
  3. 格式转换:批量处理文档格式转换任务。

工具列表

  1. convert-contents
  2. 功能:将内容从一种格式转换为另一种格式。
  3. 输入参数:
    • contents:源内容(字符串)。
    • input_file:输入文件的完整路径。
    • input_format:源格式(默认为 markdown)。
    • output_format:目标格式(默认为 markdown)。
    • output_file:输出文件的完整路径(对于 PDF、DOCX、RST、LaTeX 和 EPUB 格式必需)。

常见问题解答

  1. PDF 转换失败
  2. 错误:"xelatex not found"
  3. 解决方案:安装 TeX Live(brew install texlive)。
  4. 文件转换失败
  5. 错误:"Invalid file path"
  6. 解决方案:提供完整的文件路径(包括文件名和扩展名)。
  7. 格式转换失败
  8. 错误:"Unsupported format"
  9. 解决方案:仅使用支持的格式(如 txt、html、markdown、pdf、docx、rst、latex、epub)。

使用教程

使用依赖

  1. PDF 转换依赖
  2. 安装 TeX Live: ```bash # Ubuntu/Debian sudo apt-get install texlive-xetex

    # macOS brew install texlive

    # Windows # 安装 MiKTeX 或 TeX Live ```

安装教程

  1. 手动安装
  2. 编辑 claude_desktop_config.json 文件: ```bash # MacOS open ~/Library/Application\ Support/Claude/claude_desktop_config.json

    # Windows %APPDATA%/Claude/claude_desktop_config.json - 添加以下配置:json "mcpServers": { "mcp-pandoc": { "command": "uvx", "args": ["mcp-pandoc"] } } 2. **自动安装**: - 使用 Smithery 安装:bash npx -y @smithery/cli install mcp-pandoc --client claude ```

调试方式

  1. 使用 MCP Inspector
  2. 安装并运行: bash npx @modelcontextprotocol/inspector uv --directory /path/to/mcp-pandoc run mcp-pandoc
  3. 访问生成的 URL 进行调试。

许可证

该项目遵循 MIT 开源许可条款,请参阅 MIT 了解完整条款。