pdf_merge
Merge multiple files including PDFs, documents, spreadsheets, and images into a single PDF document using the PDF.co MCP Server tool.
Instructions
Merge PDF from two or more PDF, DOC, XLS, images, even ZIP with documents and images into a new PDF.
Ref: https://developer.pdf.co/api-reference/merge/various-files.md
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | URLs to the source files as a comma-separated list. Supports PDF, DOC, DOCX, RTF, TXT, XLS, XLSX, CSV, images, and more. Supports publicly accessible links including Google Drive, Dropbox, PDF.co Built-In Files Storage. Use 'upload_file' tool to upload local files. | |
| httpusername | No | HTTP auth user name if required to access source url. (Optional) | |
| httppassword | No | HTTP auth password if required to access source url. (Optional) | |
| name | No | File name for the generated output. (Optional) | |
| api_key | No | PDF.co API key. If not provided, will use X_API_KEY environment variable. (Optional) |
Implementation Reference
- The pdf_merge tool handler, registered with @mcp.tool(), defines the input schema using Pydantic Field descriptions, and implements the core logic by constructing ConversionParams and delegating to the merge_pdf helper.@mcp.tool() async def pdf_merge( url: str = Field( description="URLs to the source files as a comma-separated list. Supports PDF, DOC, DOCX, RTF, TXT, XLS, XLSX, CSV, images, and more. Supports publicly accessible links including Google Drive, Dropbox, PDF.co Built-In Files Storage. Use 'upload_file' tool to upload local files." ), httpusername: str = Field( description="HTTP auth user name if required to access source url. (Optional)", default="", ), httppassword: str = Field( description="HTTP auth password if required to access source url. (Optional)", default="", ), name: str = Field( description="File name for the generated output. (Optional)", default="" ), api_key: str = Field( description="PDF.co API key. If not provided, will use X_API_KEY environment variable. (Optional)", default="", ), ) -> BaseResponse: """ Merge PDF from two or more PDF, DOC, XLS, images, even ZIP with documents and images into a new PDF. Ref: https://developer.pdf.co/api-reference/merge/various-files.md """ return await merge_pdf( ConversionParams( url=url, httpusername=httpusername, httppassword=httppassword, name=name ), api_key=api_key, )
- pdfco/mcp/services/pdf.py:18-19 (helper)Supporting helper function that makes the API request to PDF.co's pdf/merge2 endpoint for merging PDFs.async def merge_pdf(params: ConversionParams, api_key: str | None = None) -> BaseResponse: return await request("pdf/merge2", params, api_key=api_key)
- pdfco/mcp/tools/apis/modification.py:8-8 (registration)The @mcp.tool() decorator registers the pdf_merge function as an MCP tool.@mcp.tool()
- Pydantic Field definitions providing the input schema, descriptions, and defaults for the pdf_merge tool.url: str = Field( description="URLs to the source files as a comma-separated list. Supports PDF, DOC, DOCX, RTF, TXT, XLS, XLSX, CSV, images, and more. Supports publicly accessible links including Google Drive, Dropbox, PDF.co Built-In Files Storage. Use 'upload_file' tool to upload local files." ), httpusername: str = Field( description="HTTP auth user name if required to access source url. (Optional)", default="", ), httppassword: str = Field( description="HTTP auth password if required to access source url. (Optional)", default="", ), name: str = Field( description="File name for the generated output. (Optional)", default="" ), api_key: str = Field( description="PDF.co API key. If not provided, will use X_API_KEY environment variable. (Optional)", default="", ), ) -> BaseResponse: