mdmagic-mcp-server
This server lets you convert Markdown into professionally formatted DOCX, PDF, and HTML documents using custom or built-in Word templates, directly from your AI assistant.
Convert documents — Transform Markdown (or a file path/base64 content) into DOCX, PDF, HTML, or all three as a ZIP, using a chosen template, page size, and orientation. Returns a secure download URL.
Validate Markdown — Pre-flight check for malformed tables, unclosed code fences, broken task lists, and unsupported syntax before spending credits. Returns a green/amber/red status.
Estimate conversion cost — Get a credit cost breakdown based on word count, page count, format, and template type before committing.
Check credit balance — View total available credits (subscription + purchased), plan name, and status.
List & browse templates — Browse all 15 built-in templates plus any custom uploads, filtered by category (Business, Creative, Professional, Technical), or list built-in and custom templates separately.
Get template details — See which page sizes (A3, A4, US Letter, US Legal, Executive) and orientations (Portrait/Landscape) a specific template supports.
Recommend templates — Describe your document's purpose in plain English and receive ranked template suggestions.
Show default settings — Retrieve your account's default page size and orientation preferences.
MDMagic MCP Server
Convert Markdown to DOCX, PDF, and HTML using your own Word templates — your letterhead, your branding, your fonts. Plus 15 designer-built templates for when you don't have your own.
MDMagic plugs straight into Claude, Cursor, VS Code, and any MCP-compatible AI assistant — giving them direct access to a professional document conversion pipeline (Pandoc + Microsoft Graph + Mammoth.js) and, more importantly, your templates. Upload your existing letterhead, stationery, brand guidelines, contract shells, or proposal templates — anything you already use in Microsoft Word — and your AI assistant can convert any Markdown directly into a polished document carrying your logo, fonts, colours, footers, page numbers, watermarks, and signature blocks. The output looks like it came from your design team, not from a generic AI export.
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.Install
You need an MDMagic account (free tier available) and your API key from your account page.
Claude Desktop
Add this to your claude_desktop_config.json:
{
"mcpServers": {
"mdmagic": {
"command": "npx",
"args": ["-y", "@mdmagic/mcp-server@latest"],
"env": {
"MDMAGIC_API_KEY": "mdmagic-xxxxxxxxxxxxxxxx"
}
}
}
}Config file location:
macOS —
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows —
%APPDATA%\Claude\claude_desktop_config.jsonLinux —
~/.config/Claude/claude_desktop_config.json
Restart Claude Desktop. The MDMagic tools will appear in the tool list.
Cursor
Add to ~/.cursor/mcp.json (or via Settings → MCP):
{
"mcpServers": {
"mdmagic": {
"command": "npx",
"args": ["-y", "@mdmagic/mcp-server@latest"],
"env": {
"MDMAGIC_API_KEY": "mdmagic-xxxxxxxxxxxxxxxx"
}
}
}
}VS Code (with an MCP extension)
{
"mcp.servers": {
"mdmagic": {
"command": "npx",
"args": ["-y", "@mdmagic/mcp-server@latest"],
"env": {
"MDMAGIC_API_KEY": "mdmagic-xxxxxxxxxxxxxxxx"
}
}
}
}Hosted (no install)
Don't want Node on the user's machine? Use the hosted endpoint:
{
"mcpServers": {
"mdmagic": {
"url": "https://api.mdmagic.ai/mcp",
"headers": {
"x-api-key": "mdmagic-xxxxxxxxxxxxxxxx"
}
}
}
}Same tools, same templates, served over Streamable HTTP. Useful for clients that don't run local processes.
Related MCP server: AI Group Markdown to Word MCP Server
What you can do
Once connected, ask your AI assistant things like:
"Convert this markdown to a PDF using the Executive_Platinum template."
"What templates do I have available?"
"How many credits will it cost to render this 800-word report as DOCX + PDF?"
"Render this in landscape, US Letter, with the Legal_Burgundy template."
"Check my credit balance."
The AI picks the right tool and returns a secure, time-limited download link.
Tools
Tool | What it does |
| Convert Markdown → DOCX / PDF / HTML / all three. Returns a secure expiring URL. |
| Pre-flight check before conversion. Catches malformed tables, unclosed code fences, and other syntax issues that would produce broken output. |
| Pre-flight cost estimate based on word count, page count, format, and template type. |
| Current credit balance (subscription + purchased pools), plan status. |
| Full template catalog: 15 built-in templates (grouped by category) + your custom uploads. |
| Only the built-in templates: Business (5), Creative (6), Professional (2), Technical (2). |
| Only your custom uploaded templates. |
| Show available variants (page sizes × orientations) for a specific template. |
| Suggest the best built-in template for a described purpose ("Q4 board pack" → Executive_Platinum). |
| Your default page size, orientation, and template preferences. |
convert_document — input options
Three ways to provide the source:
content— raw markdown string (most common)filePath— absolute path to a.mdfile (great for IDE workflows)fileContent— base64-encoded markdown (for binary-safe transports)
Plus:
templateName— e.g.Executive_Platinum,Legal_Burgundy, or a custom template UUIDoutputFormat—docx,pdf,html,all, orall-formatspageSize—A4,A3,US_Letter,US_Legal,Executiveorientation—PortraitorLandscape
Config
Variable | Default | Notes |
| (required) | Your personal API key from mdmagic.ai/account |
|
| Override only for local dev or staging |
|
| Request timeout in ms |
|
|
|
|
| Port for HTTP transport mode |
|
| Bind address for HTTP transport mode |
Most users will only ever set MDMAGIC_API_KEY.
Pricing
Conversions cost credits, calculated from page count and output format:
DOCX: 1 credit per page (base)
PDF: +1 credit per page
HTML: +1 credit per page
Custom templates: +1 credit per page
A 5-page report converted to DOCX + PDF + HTML using a custom template = 5 × (1 + 1 + 1 + 1) = 20 credits.
The estimate_conversion_cost tool returns exact numbers before you spend anything. The MCP also refuses to run if your balance is too low — no surprise bills.
Free-tier credits renew monthly. Paid plans and credit top-ups available at mdmagic.ai.
Privacy
No permanent storage. Documents pass through Microsoft Graph API for PDF rendering and are deleted within 5–10 seconds. Output files are deleted from MDMagic servers after download or after 60 minutes, whichever comes first.
Random filenames. Source files use UUIDs, never user-identifiable names.
Secure download URLs. Each conversion returns a one-time URL with session ID and download token. No public file directories.
API key isolation. Each user authenticates with their own key. No shared credentials.
Troubleshooting
MDMAGIC_API_KEY environment variable is required
Set the env var in your client config (the env block in the JSON). Don't put it in a shell — npx won't see it.
Invalid API key format
Keys must match mdmagic- followed by exactly 16 digits. Copy it cleanly from your account page.
Failed to connect to MDMagic API
Check https://api.mdmagic.ai/health in a browser. If it's up, the issue is local network or firewall. Confirm MDMAGIC_BASE_URL (default https://api.mdmagic.ai) is reachable from the machine running the MCP.
Tools don't appear in Claude Desktop
Fully quit and relaunch Claude Desktop after editing claude_desktop_config.json — a window close isn't enough.
Insufficient credits
Use check_credit_balance to confirm balance, estimate_conversion_cost to preview costs, or top up at mdmagic.ai/account.
Local development
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 inspectorThe MCP Inspector (npm run inspector) launches a web UI for poking the server tool-by-tool — useful when adding new tools or debugging argument validation.
Run tests with npm test.
Links
MDMagic — mdmagic.ai
Get an API key — mdmagic.ai/account
MCP spec — modelcontextprotocol.io
License
MIT — see 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.
Hosted MarkItDown: convert Word, PowerPoint, Excel, HTML and the text of PDFs to Markdown.
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.486 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.394 PyPI1MIT