md-to-word MCP Server
Markdown 转 Word 文档 MCP 服务器
功能特性
- ✅ 将 Markdown 文件转换为 Word 文档
- ✅ 支持自定义 Word 模板
- ✅ 模板管理功能
- ✅ Markdown 文件验证
- ✅ 示例文件创建
- ✅ 文件信息查看
安装和使用
1. 安装依赖
# 使用 uv
uv add pypandoc-binary mcp
# 或使用 pip
pip install pypandoc-binary mcp
2. 启动服务器
# 直接运行
python -m md_to_word_mcp
# 或使用模块方式
python src/md_to_word_mcp/server.py
3. 配置 Claude Desktop
在 Claude Desktop 的配置文件中添加:
{
"mcpServers": {
"md-to-word": {
"command": "python",
"args": ["-m", "md_to_word_mcp"],
"cwd": "/path/to/your/project"
}
}
}
可用工具
1. convert_md_to_word
将 Markdown 文件转换为 Word 文档。
参数:
input_file: 输入的 Markdown 文件路径output_file: 输出的 Word 文件路径(可选)template: Word 模板文件路径(可选)title: 文档标题(可选)author: 文档作者(可选)
2. create_markdown_sample
创建示例 Markdown 文件。
参数:
filename: 输出文件名(默认:sample.md)content_type: 内容类型(product_manual/technical_doc/user_guide/custom)custom_content: 自定义内容(当 content_type 为 custom 时)
3. list_templates
列出可用的 Word 模板。
4. validate_markdown
验证 Markdown 文件格式和内容。
参数:
file_path: Markdown 文件路径
使用示例
在 Claude 中使用:
请帮我将 README.md 转换为 Word 文档
创建一个产品手册的示例文件
列出所有可用的模板
文件结构
md转word/
├── src/
│ └── md_to_word_mcp/
│ ├── __init__.py
│ ├── __main__.py
│ ├── server.py # MCP 服务器
│ ├── converter.py # 转换器
│ ├── template_manager.py # 模板管理器
│ └── utils.py # 工具函数
├── pyproject.toml
├── batch_demo.py # 原始示例脚本
├── product_manual_black.docx # 默认模板
└── README.md
配置选项
可以通过修改 server.py 中的 config 对象来调整设置:
config = {
"default_template": "product_manual_black.docx", # 默认模板
"output_dir": "./output", # 输出目录
"max_file_size": 50 * 1024 * 1024, # 最大文件大小 (50MB)
"supported_formats": [".md", ".markdown", ".txt"] # 支持的格式
}
注意事项
- 确保
product_manual_black.docx模板文件存在于项目根目录 - 支持的输入格式:.md、.markdown、.txt
- 输出格式:.docx
- 模板格式:.docx、.dotx
- 最大文件大小限制:50MB
问题排查
如果遇到问题,请检查:
- 是否正确安装了
pypandoc-binary - 输入文件是否存在且可读
- 模板文件是否存在且是有效的 Word 文档
- 输出目录是否有写入权限
Metadata
Release files for md-to-word-mcp 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| md_to_word_mcp-0.1.1.tar.gz | 13.2 kB | Without provenance | Details for md_to_word_mcp-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| md_to_word_mcp-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for md_to_word_mcp-0.1.1-py3-none-any.whl |
Total release size: 27.6 kB
Release files / md_to_word_mcp-0.1.1.tar.gz
| Download URL | md_to_word_mcp-0.1.1.tar.gz |
|---|---|
| Size | 13.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d02795ee7ce264ca8e6a89fcafc45212a38bb9eb6e8b3d098f3c9a3f79a67a47
|
|
BLAKE2b-256 checksum How to use checksums |
97b22595e94e35bd073eb15e5041774ae61d188672e1f9278a689ae525a7dee6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.16
|
Release files / md_to_word_mcp-0.1.1-py3-none-any.whl
| Download URL | md_to_word_mcp-0.1.1-py3-none-any.whl |
|---|---|
| Size | 14.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1d0e1a0b114161c93ac43e019939b7a3c5e94eff1dc38580a032750389d87f47
|
|
BLAKE2b-256 checksum How to use checksums |
6d2fbd619625705c54e5b5a63ada2c52810f20d18d9061f11dbc1f8c79f90c68
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.16
|
Security for md-to-word-mcp 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.