generate_pdf_from_html
Generate a PDF from HTML content. Accepts HTML input and returns base64-encoded PDF bytes, enabling automated document creation from HTML templates.
Instructions
Generate a PDF from HTML content.
Args: html: HTML content to convert to PDF.
Returns: Base64-encoded PDF bytes.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| html | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- mcp/src/docgen_mcp/server.py:53-65 (handler)The actual handler/implementation of the 'generate_pdf_from_html' MCP tool. It is registered via the @mcp.tool() decorator, accepts an HTML string as input, calls the DocGen client's html_to_pdf method, and returns base64-encoded PDF bytes.
@mcp.tool() def generate_pdf_from_html(html: str) -> str: """Generate a PDF from HTML content. Args: html: HTML content to convert to PDF. Returns: Base64-encoded PDF bytes. """ dg = _get_client() pdf = dg.html_to_pdf(html) return base64.b64encode(pdf).decode() - mcp/src/docgen_mcp/server.py:53-53 (registration)Registration of the tool using @mcp.tool() decorator on the FastMCP instance, which registers 'generate_pdf_from_html' as an MCP tool.
@mcp.tool() - mcp/src/docgen_mcp/server.py:54-56 (schema)Input schema: the function takes a single 'html' parameter of type str (HTML content to convert to PDF). The return type is str (base64-encoded PDF bytes).
def generate_pdf_from_html(html: str) -> str: """Generate a PDF from HTML content.