Markdownify MCP服务器-UTF-8增强
这是增强版的 原始Markdownify MCP项目,改进了UTF-8编码支持,优化了对多语言内容的处理。
增强
- 添加了全面的UTF-8编码支持
- 优化多语言内容的处理
- 修复了Windows系统上的编码问题
- 改进的错误处理机制
与原始项目的主要区别
- 增强的编码支持:
- 在所有操作中完全支持UTF-8 - 正确处理中文、日文、韩文和其他非ASCII字符 - 修复了Windows特定的编码问题(cmd.exe和PowerShell兼容性)
- 改进的错误处理:
- 中英文详细错误信息 - 更好地处理网络问题的异常 - 转换失败的优雅回退机制
- 扩展功能:
- 添加了对批处理多个文件的支持 - 增强的YouTube视频转录处理 - 改进了从各种文件格式中提取元数据的过程 - 更好地保存文档格式
- 性能优化:
- 优化了大文件转换的内存使用 - 更快地处理多语言内容 - 减少依赖冲突
- 更好的开发体验:
- 全面的调试选项 - 详细的测井系统 - 特定于环境的配置支持 - 清晰的中英文文档
特性
支持将各种文件类型转换为Markdown:
- PDF文件
- 图像(带元数据)
- 音频(带转录)
- Word文档(DOCX)
- Excel电子表格(XLSX)
- PowerPoint演示文稿(PPTX)
- Web内容:
- YouTube视频转录 - 搜索结果 - 一般网页
- 现有Markdown文件
快速开始
- 克隆此存储库:
git clone https://github.com/JDJR2024/markdownify-mcp-utf8.git
cd markdownify-mcp-utf8- 安装依赖项:
pnpm install注意:这也将安装 uv 以及相关的Python依赖关系。
- 构建项目:
pnpm run build- 启动服务器:
pnpm start需求
- Node.js 16.0或更高版本
- Python 3.8或更高版本
- pnpm包管理器
- Git
详细安装指南
1.环境设置
- 安装Node.js:
- 下载自 - 验证安装: node --version
- 安装pnpm:
npm install -g pnpm
pnpm --version- 安装Python:
- 下载自 Python官方网站 - 确保在安装过程中将Python添加到PATH中 - 验证安装: python --version
- (仅限Windows)配置UTF-8支持:
# Set system-wide UTF-8
setx PYTHONIOENCODING UTF-8
# Set current session UTF-8
set PYTHONIOENCODING=UTF-8
# Enable UTF-8 in command prompt
chcp 650012.项目设置
- 克隆存储库:
git clone https://github.com/JDJR2024/markdownify-mcp-utf8.git
cd markdownify-mcp-utf8- 创建并激活Python虚拟环境:
# Windows
python -m venv .venv
.venv\Scripts\activate
# Linux/macOS
python3 -m venv .venv
source .venv/bin/activate- 安装项目依赖关系:
# Install Node.js dependencies
pnpm install
# Install Python dependencies (will be handled by setup.sh)
./setup.sh- 构建项目:
pnpm run build3.验证
- 启动服务器:
pnpm start- 测试安装:
# Convert a web page
python convert_utf8.py "https://example.com"
# Convert a local file
python convert_utf8.py "path/to/your/file.docx"使用指南
基本用法
- 转换网页:
python convert_utf8.py "https://example.com"转换后的降价将另存为 converted_result.md
- 转换本地文件:
# Convert DOCX
python convert_utf8.py "document.docx"
# Convert PDF
python convert_utf8.py "document.pdf"
# Convert PowerPoint
python convert_utf8.py "presentation.pptx"
# Convert Excel
python convert_utf8.py "spreadsheet.xlsx"- 转换YouTube视频:
python convert_utf8.py "https://www.youtube.com/watch?v=VIDEO_ID"高级用法
- 环境变量:
# Set custom UV path
export UV_PATH="/custom/path/to/uv"
# Set custom output directory
export MARKDOWN_OUTPUT_DIR="/custom/output/path"- 批量处理:
创建批处理文件(例如。, convert_batch.txt)使用URL或文件路径:
https://example1.com
https://example2.com
file1.docx
file2.pdf然后运行:
while read -r line; do python convert_utf8.py "$line"; done < convert_batch.txt故障排除
- 常见问题:
- 如果您看到编码错误,请确保正确设置了UTF-8 - 对于Windows上的权限问题,请以管理员身份运行 - 对于Python路径问题,确保虚拟环境已激活
- 调试:
# Enable debug output
export DEBUG=true
python convert_utf8.py "your_file.docx"用法
命令行
将网页转换为Markdown:
python convert_utf8.py "https://example.com"转换本地文件:
python convert_utf8.py "path/to/your/file.docx"桌面应用程序集成
要将此服务器与桌面应用程序集成,请将以下内容添加到应用程序的服务器配置中:
{
"mcpServers": {
"markdownify": {
"command": "node",
"args": [
"{ABSOLUTE_PATH}/dist/index.js"
],
"env": {
"UV_PATH": "/path/to/uv"
}
}
}
}故障排除
- 编码问题
- 如果遇到字符编码问题,请确保 PYTHONIOENCODING 环境变量设置为 utf-8 - Windows用户可能需要运行 chcp 65001 启用UTF-8支持
- 权限问题
- 确保您有足够的文件读/写权限 - 在Windows上,您可能需要以管理员身份运行
致谢
该项目基于Zach Caceres的原创作品。感谢原作者的杰出贡献。
许可证
该项目继续根据麻省理工学院许可证获得许可。请参阅 许可证 文件以获取详细信息。
贡献
欢迎投稿!在提交Pull Request之前,请:
- 确保你的代码遵循项目的编码标准
- 添加必要的测试和文件
- 更新README中的相关部分
联系
关于问题或建议:
- 提交问题:https://github.com/JDJR2024/markdownify-mcp-utf8/issues
- 创建拉取请求:https://github.com/JDJR2024/markdownify-mcp-utf8/pulls
- 电子邮件:jdidndosmmxmx@gmail.com
