pdf_split
Split a PDF into separate files by specifying page indices or ranges. Supports single pages, sequences, or splitting every page individually.
Instructions
Split a PDF into multiple PDF files using page indexes or page ranges.
Ref: https://developer.pdf.co/api-reference/pdf-split/by-pages.md
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | URL to the source PDF file. Supports publicly accessible links including Google Drive, Dropbox, PDF.co Built-In Files Storage. Use 'upload_file' tool to upload local files. | |
| pages | Yes | Comma-separated indices of pages (or page ranges) that you want to use. The first-page index is 1. For example: '1,3,5-7' or '1-2,4-'. Use '*' to split every page into separate 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) | |
| password | No | Password of the PDF file. (Optional) | |
| name | No | Base file name for the generated output files. (Optional) | |
| api_key | No | PDF.co API key. If not provided, will use X_API_KEY environment variable. (Optional) |
Implementation Reference
- pdfco/mcp/services/pdf.py:22-23 (helper)The split_pdf service function that calls the PDF.co API endpoint 'pdf/split' via the request helper. This is the actual API call made by the pdf_split tool.
async def split_pdf(params: ConversionParams, api_key: str | None = None) -> BaseResponse: return await request("pdf/split", params, api_key=api_key) - pdfco/mcp/services/pdf.py:125-153 (helper)The request helper function that sends HTTP POST requests to the PDF.co API. Used by split_pdf to make the actual API call.
async def request( endpoint: str, params: ConversionParams, custom_payload: dict | None = None, api_key: str | None = None, ) -> BaseResponse: payload = params.parse_payload(async_mode=True) if custom_payload: payload.update(custom_payload) try: async with PDFCoClient(api_key=api_key) as client: url = f"/v1/{endpoint}" print(f"Requesting {url} with payload {payload}", file=sys.stderr) response = await client.post(url, json=payload) print(f"response: {response}", file=sys.stderr) json_data = response.json() return BaseResponse( status="working", content=json_data, credits_used=json_data.get("credits"), credits_remaining=json_data.get("remainingCredits"), tips=f"You **should** use the 'wait_job_completion' tool to wait for the job [{json_data.get('jobId')}] to complete if a jobId is present.", ) except Exception as e: return BaseResponse( status="error", content=f"{type(e)}: {[arg for arg in e.args if arg]}", )