Skip to main content
Glama

merge-pdfs

Combine multiple PDF files into one document using the merge-pdfs tool from the mcp-pdf-tools server. Specify input files and output path to create a single PDF.

Instructions

Merge multiple PDF files into a single PDF

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
input_pathsYesList of input PDF file paths
output_pathYesOutput path for merged PDF

Implementation Reference

  • Executes the merge-pdfs tool by merging the provided PDF files using PyPDF2.PdfMerger and saving to the output path, with error handling.
    if name == "merge-pdfs":
        input_paths = arguments.get("input_paths", [])
        output_path = arguments.get("output_path")
        
        if not input_paths or not output_path:
            raise ValueError("Missing required arguments")
    
        merger = PyPDF2.PdfMerger()
        
        try:
            # Add each PDF to the merger
            for path in input_paths:
                with open(path, 'rb') as pdf_file:
                    merger.append(pdf_file)
            
            # Write the merged PDF
            with open(output_path, 'wb') as output_file:
                merger.write(output_file)
            
            return [types.TextContent(
                type="text",
                text=f"Successfully merged {len(input_paths)} PDFs into {output_path}"
            )]
            
        except Exception as e:
            return [types.TextContent(
                type="text",
                text=f"Error merging PDFs: {str(e)}"
            )]
        finally:
            merger.close()
  • Registers the merge-pdfs tool with the MCP server, providing name, description, and input schema validation.
    types.Tool(
        name="merge-pdfs",
        description="Merge multiple PDF files into a single PDF",
        inputSchema={
            "type": "object",
            "properties": {
                "input_paths": {
                    "type": "array",
                    "items": {"type": "string"},
                    "description": "List of input PDF file paths"
                },
                "output_path": {
                    "type": "string",
                    "description": "Output path for merged PDF"
                }
            },
            "required": ["input_paths", "output_path"]
        }
    ),
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 states the action ('merge') but doesn't cover critical traits like whether it modifies original files, handles errors, requires specific permissions, or has performance limits. This leaves significant gaps in understanding the tool's behavior.

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, clear sentence that directly states the tool's function without unnecessary words. It's front-loaded and efficiently communicates the core purpose, making it highly concise and well-structured.

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 complexity of merging files and the lack of annotations and output schema, the description is insufficient. It doesn't explain return values, error handling, or behavioral nuances, leaving the agent with incomplete information for reliable tool invocation in a real-world context.

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?

Schema description coverage is 100%, so the input schema fully documents the two parameters ('input_paths' and 'output_path'). The description adds no additional semantic context beyond what the schema provides, such as file format details or merging order, meeting the baseline for high schema coverage.

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 action ('merge') and resource ('multiple PDF files into a single PDF'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'merge-pdfs-ordered', which suggests a similar function with ordering, leaving room for improvement in sibling distinction.

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 like 'merge-pdfs-ordered' or other PDF-related siblings. It lacks context on prerequisites, such as file accessibility or format requirements, leaving usage unclear without external knowledge.

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/hanweg/mcp-pdf-tools'

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