Skip to main content
Glama
truaxki

PDF to PNG MCP Server

by truaxki

pdf2png

Convert PDF documents to PNG image files using this MCP server tool. Specify input PDF path and output folder to generate images from PDF pages.

Instructions

Converts PDFs to images in PNG format.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
read_file_pathYes
write_folder_pathYes

Implementation Reference

  • The handle_call_tool function executes the pdf2png tool: validates arguments, converts PDF pages to PNG images using pdf2image.convert_from_path, saves them sequentially as page_N.png in the write_folder_path, and returns a success text message.
    @server.call_tool()
    async def handle_call_tool(
        name: str, arguments: dict | None
    ) -> list[types.TextContent | types.ImageContent | types.EmbeddedResource]:
        """Handle tool execution requests."""
        if name != "pdf2png":
            raise ValueError(f"Unknown tool: {name}")
    
        if not arguments:
            raise ValueError("Missing arguments")
    
        read_file_path = arguments.get("read_file_path")
        write_folder_path = arguments.get("write_folder_path")
    
        if not read_file_path or not write_folder_path:
            raise ValueError("Missing read_file_path or write_folder_path")
    
        # Convert PDF to PNG
        images = convert_from_path(read_file_path)
        
        # Create output directory if it doesn't exist
        os.makedirs(write_folder_path, exist_ok=True)
        
        # Save each page as PNG
        output_files = []
        for i, image in enumerate(images):
            output_path = os.path.join(write_folder_path, f'page_{i+1}.png')
            image.save(output_path, 'PNG')
            output_files.append(output_path)
    
        return [
            types.TextContent(
                type="text",
                text=f"Successfully converted PDF to {len(output_files)} PNG files in {write_folder_path}"
            )
        ]
  • The handle_list_tools function defines and returns the schema for the pdf2png tool, including name, description, and input schema requiring read_file_path and write_folder_path as strings.
    @server.list_tools()
    async def handle_list_tools() -> list[types.Tool]:
        """List available tools."""
        return [
            types.Tool(
                name="pdf2png",
                description="Converts PDFs to images in PNG format.",
                inputSchema={
                    "type": "object",
                    "properties": {
                        "read_file_path": {"type": "string"},
                        "write_folder_path": {"type": "string"},
                    },
                    "required": ["read_file_path", "write_folder_path"],
                },
            )
        ]
  • Creates the MCP Server instance named 'pdf2png', onto which tool handlers are registered via decorators.
    server = Server("pdf2png")
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions conversion but lacks details on permissions, rate limits, error handling, or output behavior (e.g., whether it overwrites files). This leaves significant gaps for a tool that performs file operations.

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

Conciseness5/5

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

The description is a single, efficient sentence with zero waste, front-loading the core functionality. It's appropriately sized for a straightforward tool, earning a high score for conciseness.

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

Completeness2/5

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

Given the tool's complexity (file conversion with 2 parameters), lack of annotations, and no output schema, the description is incomplete. It doesn't address key aspects like what the tool returns, error conditions, or file handling specifics, leaving the agent with insufficient context.

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

Parameters2/5

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

Schema description coverage is 0%, so the description must compensate by explaining parameters. It adds no meaning beyond the schema, failing to clarify what 'read_file_path' and 'write_folder_path' represent (e.g., input PDF file path and output directory for PNGs).

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?

The description clearly states the tool's purpose with a specific verb ('converts') and resource ('PDFs to images in PNG format'), making it immediately understandable. It doesn't need to distinguish from siblings since none exist, so a 4 is appropriate rather than a 5.

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?

The description provides no guidance on when to use this tool versus alternatives, prerequisites, or contextual constraints. It merely states what the tool does without indicating appropriate scenarios or limitations.

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/truaxki/mcp-Pdf2png'

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