Skip to main content
Glama

merge-pdfs

Combine multiple PDF files into one document by specifying input paths and an output location using the MCP server’s PDF tools.

Instructions

Merge multiple PDF files into a single PDF

Input Schema

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

Input Schema (JSON Schema)

{ "properties": { "input_paths": { "description": "List of input PDF file paths", "items": { "type": "string" }, "type": "array" }, "output_path": { "description": "Output path for merged PDF", "type": "string" } }, "required": [ "input_paths", "output_path" ], "type": "object" }

Implementation Reference

  • Handler implementation for the 'merge-pdfs' tool. Merges the provided input PDF files into a single output PDF using PyPDF2.PdfMerger.
    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()
  • Registration of the 'merge-pdfs' tool in the MCP server's list_tools handler, including name, description, and input schema definition.
    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"] } ),

Other Tools

Related 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