Skip to main content
Glama

Convert-Markdown-PDF-MCP

An MCP server that turns Markdown into a styled PDF. The look follows VS Code's markdown preview, typeset with ReportLab and a bundled sans-serif family.

Status: built in February 2025 and retired once this kind of tooling became standard in model releases. Updated in November 2026 to run on the current MCP SDK, render general Markdown, and start from any directory. Kept working.

First page of the sample PDF

That page is tests/fixtures/sample.md rendered with the default theme. The full PDF is in docs/.

What It Renders

Headings one to six, paragraphs, bold, italic, inline code, links that stay clickable, ordered and bulleted lists, nested lists, blockquotes, tables, fenced code blocks, horizontal rules, and images (local paths or URLs, scaled to the page width). Nested list items need four spaces of indentation, which is Python-Markdown's rule.

Related MCP server: MCP MD2PDF Server

The Tool

convert_markdown takes:

  • markdown (required): the Markdown text.

  • output_path (required): where to write the PDF. .pdf is added if it's missing, and missing folders are created. Use an absolute path; a relative one resolves against the server's working directory.

  • theme: light (the default) or high-contrast. It changes the colors of code blocks, quotes, and tables.

It returns the path it saved to. Failures come back as MCP tool errors.

Install

Requires uv, which installs Python 3.12 if needed.

git clone https://github.com/seanivore/Convert-Markdown-PDF-MCP.git
cd Convert-Markdown-PDF-MCP
uv sync
uv run pytest

Connect It

Claude Code:

claude mcp add md-pdf -- uv --directory /absolute/path/to/Convert-Markdown-PDF-MCP run md-pdf-mcp

Claude Desktop, in claude_desktop_config.json:

{
  "mcpServers": {
    "md-pdf": {
      "command": "uv",
      "args": ["--directory", "/absolute/path/to/Convert-Markdown-PDF-MCP", "run", "md-pdf-mcp"]
    }
  }
}

Use It From Python

from md_pdf_mcp import convert_markdown_to_pdf

convert_markdown_to_pdf("# Hello\n\nSome **bold** text.", "/tmp/hello.pdf", theme="light")

How It Works

md_pdf_mcp/converter.py parses Markdown with Python-Markdown, walks the resulting HTML, and builds ReportLab flowables. md_pdf_mcp/vscode_styles.py holds the type scale and colors, modeled on VS Code's markdown preview stylesheet, which is kept in docs/markdown.css. ReportLab replaced an earlier WeasyPrint attempt. The fonts are IBM Plex Sans, under the SIL Open Font License (md_pdf_mcp/fonts/TTF/OFL.txt). They live inside the package, so the server starts from any working directory.

Development

  • uv run pytest runs the converter tests and an MCP test that starts the server from another directory.

  • npx @modelcontextprotocol/inspector uv --directory . run md-pdf-mcp opens the MCP Inspector.

Available Tools

1 tool
convert_markdownA

Convert a Markdown string to a styled PDF file.

Args:
    markdown: The Markdown content to convert.
    output_path: Where to write the PDF. ".pdf" is appended if missing. Relative paths
        resolve against the server's working directory, so pass an absolute path.
    theme: "light" (default) or "high-contrast". Changes code-block, quote, and table colors.

Inputs: markdown (required), output_path (required), theme. Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.6/5.0

    Scored across 1 tool

    Disambiguation5/5

    There is only one tool, so there is no possibility of confusing it with another operation. Its name and description make its single purpose clear.

    Naming Consistency5/5

    The single tool follows a clear verb_noun convention (convert_markdown), which would extend predictably if more conversion tools were added. There are no competing conventions to create inconsistency.

    Tool Count3/5

    The server's scope is narrow — Markdown to PDF conversion — so one tool is defensible, but the surface is thin and offers no alternatives such as batch conversion or theme discovery. A single tool leaves little room for the agent to recover when the one call path does not fit the task.

    Completeness3/5

    The core conversion (Markdown string in, PDF out, with theme selection and path handling) is covered, but there are noticeable gaps: no file-input variant, no batch conversion, no page or margin configuration, and no way to enumerate the valid themes. Agents can work around these gaps only by doing extra work, such as reading files themselves.

    Related MCP Connectors

    Related MCP Servers