已正式纳入模型上下文协议服务器开源项目 🎉
这是一个基于文档转换工具pandoc实现的模型上下文协议(MCP)服务器,用于文档格式转换。该服务器提供在不同文档格式间转换内容的工具,同时保持格式和结构的完整性。
请注意,mcp-pandoc目前处于早期开发阶段。PDF支持功能仍在开发中,其功能和可用工具可能会随着服务器的持续改进而发生变化和扩展。
致谢:本项目使用Pandoc Python包作为文档转换的基础。
更多内容即将推出...
convert-contents
contents
(字符串):要转换的源内容(如果未提供input_file则必须提供)input_file
(字符串):输入文件的完整路径(如果未提供contents则必须提供)input_format
(字符串):内容的源格式(默认为markdown)output_format
(字符串):目标格式(默认为markdown)output_file
(字符串):输出文件的完整路径(对于pdf、docx、rst、latex、epub格式必须提供)当前支持的格式:
基础格式(可直接转换):
高级格式(需要完整文件路径):
注意:对于高级格式:
brew install texlive
)注意:请确保完成下面"关键要求"部分提到的所需包的安装。
使用已发布的版本:
{
"mcpServers": {
"mcp-pandoc": {
"command": "uvx",
"args": ["mcp-pandoc"]
}
}
}

Pandoc安装
pandoc
- 核心文档转换引擎# macOS
brew install pandoc
# Ubuntu/Debian
sudo apt-get install pandoc
# Windows
# 从以下网址下载安装程序:https://pandoc.org/installing.html

pandoc --version
UV包安装
uv
包(包含uvx
命令)# macOS
brew install uv
# Windows/Linux
pip install uv

uvx --version
PDF转换前提条件:仅在进行PDF转换和保存时需要
# Ubuntu/Debian
sudo apt-get install texlive-xetex
# macOS
brew install texlive
# Windows
# 从以下网址安装MiKTeX或TeX Live:
# https://miktex.org/ 或 https://tug.org/texlive/

文件路径要求
✅ 正确用法:
# 将内容转换为PDF
"将此文本转换为PDF并保存为/path/to/document.pdf"
# 在文件格式之间转换
"将/path/to/input.md转换为PDF并保存为/path/to/output.pdf"

❌ 错误用法:
# 缺少文件名和扩展名
"将此保存为PDF到/documents/"
# 缺少完整路径
"将此转换为PDF"
# 缺少扩展名
"保存为/documents/story"

PDF转换失败
文件转换失败
/path/to/document.pdf
而不仅仅是 /path/to/
格式转换失败
open ~/Library/Application\ Support/Claude/claude_desktop_config.json
%APPDATA%/Claude/claude_desktop_config.json
a) 仅用于本地开发和对此仓库的贡献
ℹ️ 将
"mcpServers": {
"mcp-pandoc": {
"command": "uv",
"args": [
"--directory",
"<DIRECTORY>/mcp-pandoc",
"run",
"mcp-pandoc"
]
}
}

b) 已发布服务器配置 - 消费者应使用此配置
"mcpServers": {
"mcp-pandoc": {
"command": "uvx",
"args": [
"mcp-pandoc"
]
}
}

运行以下bash命令通过Smithery为Claude Desktop自动安装已发布的mcp-pandoc pypi:
npx -y @smithery/cli install mcp-pandoc --client claude
注意:要使用本地配置的mcp-pandoc,请按照上面的"开发/未发布服务器配置"步骤操作。
准备包以供分发:
uv sync

uv build
这将在dist/
目录中创建源代码和wheel分发。
uv publish
注意:你需要通过环境变量或命令行标志设置PyPI凭据:
--token
或 UV_PUBLISH_TOKEN
--username
/UV_PUBLISH_USERNAME
和 --password
/UV_PUBLISH_PASSWORD
由于MCP服务器通过stdio运行,调试可能具有挑战性。为了获得最佳调试体验,我们强烈建议使用MCP Inspector。
你可以通过npm
使用以下命令启动MCP Inspector:
npx @modelcontextprotocol/inspector uv --directory /Users/vivekvells/Desktop/code/ai/mcp-pandoc run mcp-pandoc
启动后,Inspector将显示一个URL,你可以在浏览器中访问该URL开始调试。
我们欢迎对mcp-pandoc的贡献!以下是你可以参与的方式: