Skip to main content
Glama

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

TableJSON Schema
NameRequiredDescriptionDefault
htmlYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • 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()
  • Registration of the tool using @mcp.tool() decorator on the FastMCP instance, which registers 'generate_pdf_from_html' as an MCP tool.
    @mcp.tool()
  • 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.
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations present. The description only states the return format (Base64-encoded PDF bytes). Lacks disclosure on idempotency, safety (read/write), authentication needs, size limits, or any side effects.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Concise two-line description with structured Args/Returns. No wasted words, though it could be more informative about constraints.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Tool is simple with one param and an output schema. Description covers input and output format. However, context signals indicate no nested objects or enums, so basic completeness is adequate, but missing details like supported HTML features or file size limits.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

One parameter 'html' described as 'HTML content to convert to PDF'. This adds context beyond the schema's type string. Schema description coverage is 0%, so description partially compensates.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

Clearly states verb 'Generate' and resource 'PDF from HTML content'. Distinguishes from siblings implicitly by specifying HTML input, but lacks explicit differentiation from similar tools like 'generate_pdf_from_markdown'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives like 'generate_pdf_from_markdown' or 'fill_pdf_form'. No exclusions or prerequisites mentioned.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/dokmatiq/docgen-sdks'

If you have feedback or need assistance with the MCP directory API, please join our Discord server