这是一个模型上下文协议(MCP)服务器,它使用外部转换服务将 Markdown 文本转换为 DOCX 格式。
<img src="https://raw.githubusercontent.com/Yorick-Ryu/md2doc-mcp/master/images/md2doc.png" alt="md2doc 示例" width="600" style="max-width: 100%; height: auto;">{
"mcpServers": {
"md2doc": {
"command": "uvx",
"args": ["md2doc"],
"env": {
"DEEP_SHARE_API_KEY": "your-api-key-here"
}
}
}
}
打开你的 Claude Desktop 配置文件:
~/Library/Application Support/Claude/claude_desktop_config.json%APPDATA%\Claude\claude_desktop_config.json添加 md2doc 服务器:
{
"mcpServers": {
"md2doc": {
"command": "uvx",
"args": ["md2doc"],
"env": {
"DEEP_SHARE_API_KEY": "your-api-key-here"
}
}
}
}
重启 Claude Desktop
无需客户端设置即可立即使用:
# 安装并运行服务器
uvx md2doc
# 或者使用环境变量
DEEP_SHARE_API_KEY="your-api-key-here" uvx md2doc
你也可以在 Python 项目中直接使用 md2doc:
import asyncio
from md2doc.api_client import ConversionAPIClient
from md2doc.models import ConvertTextRequest
async def convert_markdown():
client = ConversionAPIClient()
request = ConvertTextRequest(
content="# Hello World\n\nThis is **markdown** content.",
filename="example",
language="en",
template_name="thesis"
)
response = await client.convert_text(request)
if response.success:
print(f"文件保存至: {response.file_path}")
# 运行转换
asyncio.run(convert_markdown())
该服务器与任何兼容 MCP 的客户端一起工作。配置以运行:
uvx md2doc
使用环境变量:
DEEP_SHARE_API_KEY="your-api-key-here" uvx md2doc
使用此密钥进行测试:
f4e8fe6f-e39e-486f-b7e7-e037d2ec216f
convert_markdown_to_docx: 将 Markdown 文本转换为 DOCXlist_templates: 获取按语言可用的模板MIT