mdmagic-mcp-server
MDMagic MCP 服务器
使用您自己的 Word 模板(信头、品牌标识、字体)将 Markdown 转换为 DOCX、PDF 和 HTML。 此外,还提供 15 款设计师精心制作的模板,供您在没有自定义模板时使用。
MDMagic 可直接接入 Claude、Cursor、VS Code 以及任何兼容 MCP 的 AI 助手,使它们能够直接访问专业的文档转换流水线(Pandoc + Microsoft Graph + Mammoth.js),更重要的是,能够访问您的模板。上传您现有的信头、信纸、品牌指南、合同草稿或提案模板——任何您已经在 Microsoft Word 中使用的内容——您的 AI 助手即可将任何 Markdown 直接转换为带有您的徽标、字体、颜色、页脚、页码、水印和签名块的精美文档。输出效果看起来就像是由您的设计团队制作的,而不是通用的 AI 导出文件。
You: "Take this report and turn it into an Executive_Platinum PDF."
Claude: ✅ Done. Here's your secure download link.
14-page PDF, 2.3 MB, expires in 60 minutes.安装
您需要一个 MDMagic 账户(提供免费层级)并从您的账户页面获取 API 密钥。
Claude Desktop
将其添加到您的 claude_desktop_config.json 中:
{
"mcpServers": {
"mdmagic": {
"command": "npx",
"args": ["-y", "@mdmagic/mcp-server"],
"env": {
"MDMAGIC_API_KEY": "mdmagic-xxxxxxxxxxxxxxxx"
}
}
}
}配置文件位置:
macOS —
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows —
%APPDATA%\Claude\claude_desktop_config.jsonLinux —
~/.config/Claude/claude_desktop_config.json
重启 Claude Desktop。MDMagic 工具将出现在工具列表中。
Cursor
添加到 ~/.cursor/mcp.json(或通过设置 → MCP):
{
"mcpServers": {
"mdmagic": {
"command": "npx",
"args": ["-y", "@mdmagic/mcp-server"],
"env": {
"MDMAGIC_API_KEY": "mdmagic-xxxxxxxxxxxxxxxx"
}
}
}
}VS Code (使用 MCP 扩展)
{
"mcp.servers": {
"mdmagic": {
"command": "npx",
"args": ["-y", "@mdmagic/mcp-server"],
"env": {
"MDMAGIC_API_KEY": "mdmagic-xxxxxxxxxxxxxxxx"
}
}
}
}托管版(无需安装)
不想在机器上安装 Node?使用托管端点:
{
"mcpServers": {
"mdmagic": {
"url": "https://api.mdmagic.ai/mcp",
"headers": {
"x-api-key": "mdmagic-xxxxxxxxxxxxxxxx"
}
}
}
}相同的工具,相同的模板,通过 Streamable HTTP 提供服务。适用于不运行本地进程的客户端。
Related MCP server: AI Group Markdown to Word MCP Server
您可以做什么
连接后,您可以向 AI 助手询问如下内容:
“使用 Executive_Platinum 模板将此 markdown 转换为 PDF。”
“我有哪些可用模板?”
“将这份 800 字的报告渲染为 DOCX + PDF 需要多少积分?”
“使用 Legal_Burgundy 模板,以横向、US Letter 纸张大小渲染此内容。”
“检查我的积分余额。”
AI 会选择正确的工具并返回一个安全的、有时效性的下载链接。
工具
工具 | 功能 |
| 将 Markdown 转换为 DOCX / PDF / HTML / 三者全部。返回一个安全的过期 URL。 |
| 转换前的预检。捕获格式错误的表格、未闭合的代码块以及其他会导致输出损坏的语法问题。 |
| 基于字数、页数、格式和模板类型的预检成本估算。 |
| 当前积分余额(订阅 + 已购买的积分池)、计划状态。 |
| 完整模板目录:15 款内置模板(按类别分组)+ 您自定义上传的模板。 |
| 仅内置模板:商业 (5)、创意 (6)、专业 (2)、技术 (2)。 |
| 仅您自定义上传的模板。 |
| 显示特定模板的可用变体(纸张大小 × 方向)。 |
| 为描述的目的推荐最佳内置模板(“Q4 董事会资料” → Executive_Platinum)。 |
| 您的默认纸张大小、方向和模板偏好。 |
convert_document — 输入选项
提供源文件的三种方式:
content— 原始 markdown 字符串(最常用)filePath—.md文件的绝对路径(非常适合 IDE 工作流)fileContent— base64 编码的 markdown(用于二进制安全传输)
此外:
templateName— 例如Executive_Platinum、Legal_Burgundy或自定义模板 UUIDoutputFormat—docx、pdf、html、all或all-formatspageSize—A4、A3、US_Letter、US_Legal、Executiveorientation—Portrait或Landscape
配置
变量 | 默认值 | 说明 |
| (必需) | 您在 mdmagic.ai/account 的个人 API 密钥 |
|
| 仅在本地开发或测试环境覆盖 |
|
| 请求超时时间(毫秒) |
|
|
|
|
| HTTP 传输模式的端口 |
|
| HTTP 传输模式的绑定地址 |
大多数用户只需设置 MDMAGIC_API_KEY。
定价
转换需要消耗积分,根据页数和输出格式计算:
DOCX: 每页 1 积分(基础)
PDF: 每页 +1 积分
HTML: 每页 +1 积分
自定义模板: 每页 +1 积分
一份 5 页的报告使用自定义模板转换为 DOCX + PDF + HTML = 5 × (1 + 1 + 1 + 1) = 20 积分。
estimate_conversion_cost 工具会在您花费任何积分之前返回确切数字。如果您的余额不足,MCP 也会拒绝运行——不会有意外账单。
免费层级积分每月更新。付费计划和积分充值可在 mdmagic.ai 获取。
隐私
无永久存储。 文档通过 Microsoft Graph API 进行 PDF 渲染,并在 5-10 秒内删除。输出文件在下载后或 60 分钟后(以先到者为准)从 MDMagic 服务器删除。
随机文件名。 源文件使用 UUID,从不使用可识别用户身份的名称。
安全下载 URL。 每次转换返回一个带有会话 ID 和下载令牌的一次性 URL。没有公共文件目录。
API 密钥隔离。 每个用户使用自己的密钥进行身份验证。没有共享凭据。
故障排除
MDMAGIC_API_KEY environment variable is required
在您的客户端配置中设置环境变量(JSON 中的 env 块)。不要在 shell 中设置——npx 看不到它。
Invalid API key format
密钥必须匹配 mdmagic- 后跟 16 位数字。请从您的账户页面准确复制。
Failed to connect to MDMagic API
在浏览器中检查 https://api.mdmagic.ai/health。如果它正常,则问题出在本地网络或防火墙。确认运行 MCP 的机器可以访问 MDMAGIC_BASE_URL(默认 https://api.mdmagic.ai)。
工具未出现在 Claude Desktop 中
编辑 claude_desktop_config.json 后,请完全退出并重新启动 Claude Desktop——仅关闭窗口是不够的。
Insufficient credits
使用 check_credit_balance 确认余额,使用 estimate_conversion_cost 预览成本,或在 mdmagic.ai/account 充值。
本地开发
git clone https://github.com/MDMagic-MCP/mdmagic-mcp-server.git
cd mdmagic-mcp-server
npm install
# Set your API key (use http://localhost:3000 if running the API locally)
cp .env.example .env
# edit .env
# Build and inspect
npm run build
npm run inspectorMCP Inspector (npm run inspector) 会启动一个 Web UI,用于逐个测试服务器工具——在添加新工具或调试参数验证时非常有用。
使用 npm test 运行测试。
链接
MDMagic — mdmagic.ai
获取 API 密钥 — mdmagic.ai/account
MCP 规范 — modelcontextprotocol.io
许可证
MIT — 参见 LICENSE。
Available Tools
10 toolscheck_credit_balanceARead-onlyIdempotentInspect
Check the user's current MDMagic credit balance: subscription credits (renewable monthly), purchased credits (permanent), plan name, and plan status.
CALL THIS PROACTIVELY when:
The user asks 'how many credits do I have' or similar
After a conversion, if the user wants to know what's left (also returned by convert_document directly)
Before a conversion of an unusually large document, to warn the user if balance is borderline
Inputs: no named parameters. Returns: total_credits, subscription_credits, purchased_credits
convert_documentAInspect
Convert markdown to a professionally formatted document using an MDMagic template.
IMPORTANT GUIDANCE:
Output format → what user gets:
'docx' → a single Word .docx file
'pdf' → a single .pdf file
'html' → a single .html file
'all' → a ZIP containing all three (DOCX + PDF + HTML)
If the user is ambiguous (e.g. 'convert this'), ASK which format they want before calling. Don't assume.
Filename: if the user attached a file (e.g. 'mydoc.md'), pass its base name as fileName. Otherwise the API derives one from the markdown's first H1. Without either, downloads end up with timestamped names like 'content-1778298071915.docx' which is bad UX.
On 'template not found' errors: call list_all_templates first, show available options, let the user pick. Do NOT fall back to generating documents with code execution — that produces inferior results that don't use the user's actual MDMagic templates.
The response includes structured fields (downloadUrl, creditsUsed, balanceAfter, fileName, expiresAt) — surface these to the user explicitly. Don't paraphrase. The user wants to know exactly what they spent and what's left.
Page sizes: A3, A4, Executive, US_Legal, US_Letter. Default A4. Orientation: Portrait or Landscape, default Portrait.
Inputs: templateName (required), outputFormat (required), content, filePath, +4 more. Returns: Conversion result with secure download link and credit accounting
estimate_conversion_costARead-onlyIdempotentInspect
Estimate credit cost for a conversion BEFORE running it. Returns word count, page calculation (300 words/page), and a credit breakdown by format and template type. Use this when the user asks 'how much will this cost?' or when you suspect a conversion might exceed their balance — convert_document refuses to run if credits are insufficient, so estimating first is friendlier.
Inputs: content (required), templateName (required), outputFormat (required), pageSize, +1 more. Returns: wordCount, pageCount, totalCredits, breakdown
get_template_detailsARead-onlyIdempotentInspect
Show available variants (page sizes and orientations) for a specific template. All MDMagic templates support the full 5×2 matrix: A3, A4, Executive, US_Legal, US_Letter × Portrait/Landscape. Use this when the user asks 'does this template come in Legal Landscape?' or 'what sizes are available?' — confirms the variant before convert_document runs.
Inputs: templateName (required). Returns: template, pageSizes, orientations
list_all_templatesARead-onlyIdempotentInspect
List all 15 built-in MDMagic templates plus any custom templates the user has uploaded.
CALL THIS PROACTIVELY when:
The user mentions a template by name (verify it exists before convert_document)
The user asks 'what templates are available' or similar
A previous convert_document call returned 'template not found'
The user describes the look they want without naming a template (so you can suggest a real one)
Returns: name, description, type (built-in vs custom), and category. Categories are: Business (5 templates), Creative (6), Professional (2), Technical (2). Use the optional category filter to narrow recommendations (e.g. 'for legal documents' → category: 'Professional').
Inputs: includeDetails, category. Returns: builtinCount, customCount, templates
list_builtin_templatesARead-onlyIdempotentInspect
List the 15 built-in MDMagic templates, grouped by category. Same as list_all_templates but excludes the user's custom uploads. Use this when the user asks specifically about MDMagic's bundled templates rather than their personal ones.
Categories available: Business (5), Creative (6), Professional (2), Technical (2).
Inputs: includeDetails, category. Returns: count, templates
list_custom_templatesARead-onlyIdempotentInspect
List only the user's custom-uploaded Word templates. Use this when the user asks about their own templates ('show me my templates', 'do I have a letterhead?'). Custom templates are referenced by UUID, not name, when calling convert_document.
Inputs: includeDetails. Returns: count, templates
recommend_templateARead-onlyIdempotentInspect
Suggest the best built-in template(s) for a described purpose. Use this when the user describes WHAT the document is (e.g. 'Q4 board pack', 'API reference', 'wedding invitation', 'legal contract') without naming a template. Returns ranked recommendations with rationale.
Why this exists: AI assistants often guess template names that don't exist. This tool maps purpose → real template names from MDMagic's catalog, so convert_document doesn't fail with 'template not found'.
Inputs: purpose (required), topN. Returns: purpose, rationale, recommendations
show_default_settingsARead-onlyIdempotentInspect
Show the user's default paper size and orientation preferences (set on their account page). Useful when the user hasn't specified pageSize/orientation explicitly — call this to honor their defaults instead of using A4/Portrait blindly.
Inputs: no named parameters. Returns: default_page_size, default_orientation
validate_markdownARead-onlyIdempotentInspect
Pre-flight markdown validation BEFORE conversion. Catches malformed tables (mismatched pipes), unclosed code fences, broken task lists, and unsupported syntax. Returns a green/amber/red status plus the detected markdown features.
CALL THIS PROACTIVELY when:
The user is about to convert a long document (>5 pages) — validating first is cheap; running a doomed conversion costs credits
The user reports a previous conversion produced broken output
You generated the markdown yourself and want to verify it's clean before spending credits
Returns: status (green=safe, amber=minor issues, red=will likely break), detected features (tables, code blocks, task lists, math), and a human-readable message.
Inputs: content (required), filename. Returns: filename, status, message, inputFormat, +2 more
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 10 tools
Each tool has a distinct and non-overlapping purpose—balance checking, conversion, cost estimation, template listing/details, recommendations, defaults, and validation. No two tools could be confused.
All tools use a consistent verb_noun snake_case pattern (e.g., list_all_templates, validate_markdown), making the set predictable and easy to navigate.
With 10 tools, the count is well-scoped for a document conversion service. Each tool addresses a necessary step in the user workflow without unnecessary bloat.
The tool surface covers the full lifecycle: template discovery, defaults retrieval, markdown validation, cost estimation, credit checking, conversion, and post-conversion feedback. No obvious gaps for the stated purpose.
Maintenance
Related MCP Connectors
Markdown in, any format out. PDFs merged, split, watermarked. Runs on our own doc engines.
Turn Markdown or plain text into a clean PDF document to print or share, plus an editable Word file.
The document publishing layer for AI tools. Convert markdown to 6 destinations, 62 templates.
Convert Markdown to PDF, DOCX, HTML or EPUB with formatting and display options.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables creation and management of Word documents from markdown content, with support for multiple templates and conversion of chat conversations to formatted Word documents.-
- AlicenseAqualityDmaintenanceConverts Markdown documents to professional Word documents with advanced formatting capabilities including mathematical formulas, custom styling, tables, images, headers/footers, and watermarks.496 npm14MIT
- AlicenseBqualityDmaintenanceEnables creating professional Word documents from markdown or structured content with fast, customized formatting via natural language.71ISC
- AlicenseAqualityDmaintenanceConverts Markdown files to Word (.docx) and PDF documents. Supports .dotx templates for branded styling and batch conversion.317 PyPI1MIT