
mcp-pandoc: A Document Conversion MCP Server

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 是一个文档格式转换服务器,旨在提供高效的文档格式转换工具,支持多种输入和输出格式。
核心功能
- 内容转换:支持将内容从一种格式转换为另一种格式,如 markdown 转 HTML、PDF 等。
- 文件格式转换:支持直接转换文件格式,如 .md 转 .pdf。
- 高级格式支持:支持 PDF、DOCX、RST、LaTeX 和 EPUB 等高级格式的转换。
适用场景
- 文档处理:需要将文档从一种格式转换为另一种格式的场景。
- 内容生成:生成不同格式的内容,如将 markdown 转换为 PDF 或 DOCX。
- 格式转换:批量处理文档格式转换任务。
工具列表
convert-contents
:- 功能:将内容从一种格式转换为另一种格式。
- 输入参数:
contents
:源内容(字符串)。input_file
:输入文件的完整路径。input_format
:源格式(默认为 markdown)。output_format
:目标格式(默认为 markdown)。output_file
:输出文件的完整路径(对于 PDF、DOCX、RST、LaTeX 和 EPUB 格式必需)。
常见问题解答
- PDF 转换失败:
- 错误:"xelatex not found"
- 解决方案:安装 TeX Live(
brew install texlive
)。 - 文件转换失败:
- 错误:"Invalid file path"
- 解决方案:提供完整的文件路径(包括文件名和扩展名)。
- 格式转换失败:
- 错误:"Unsupported format"
- 解决方案:仅使用支持的格式(如 txt、html、markdown、pdf、docx、rst、latex、epub)。
使用教程
使用依赖
- PDF 转换依赖:
-
安装 TeX Live: ```bash # Ubuntu/Debian sudo apt-get install texlive-xetex
# macOS brew install texlive
# Windows # 安装 MiKTeX 或 TeX Live ```
安装教程
- 手动安装:
-
编辑
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 ```
调试方式
- 使用 MCP Inspector:
- 安装并运行:
bash npx @modelcontextprotocol/inspector uv --directory /path/to/mcp-pandoc run mcp-pandoc
- 访问生成的 URL 进行调试。