An AI agent can split a PDF and rebuild a document from only the pages you need by chaining two tools: split extracts the pages, and merge puts them back together. The GroupDocs.Merger.Mcp server runs both locally on your machine, so a single prompt does the job in Claude Desktop, Claude Code or Cursor:

Extract pages 3, 6 and 8, then merge the three results into one file in that order.

The step-by-step version with config and troubleshooting is in the documentation: How to split a document and reassemble the pages you want.

Why does the split tool need a second step?

An LLM asked to cut pages out of a document has only one option without a tool: rewrite the text it can see. That loses layout and may change content. With a page-aware engine the agent works on real pages instead.

The detail that shapes every workflow here is how split behaves. It extracts the pages you name and saves each one as its own document. Three page numbers produce three files, not one file with three pages. It is page extraction, not “cut here”. The three ways below differ in what the agent does with those single-page files.

Way 1: How do you extract pages as separate files?

Pull out pages 3, 6, and 8 of report.pdf.

The agent calls split with pages: "3,6,8". The tool returns a message of the form Split "report.pdf" into 3 file(s): followed by the saved path of each extracted document. Use this when each page is the deliverable: a signature page, a certificate, one form from a bundle.

Page numbers are a comma-separated, 1-based list. Name every page you want. A range is not a documented input, so for pages 5 to 9 the prompt should list 5,6,7,8,9.

Way 2: How do you extract pages and reassemble them into one document?

Extract pages 5 to 9 of report.pdf, then merge the results into one file in page order.

Here the agent lists the pages itself (5,6,7,8,9), calls split once, and then calls merge. Because merge takes two to four documents per call, five single-page files need two rounds: four pages first, then that result plus the fifth page. Ask for the chaining explicitly. Order is slot order, so the agent must place page 5 in file1 and page 9 last. Under evaluation, the rebuilt file is trimmed to its first 3 pages.

This is the pattern behind “extract pages and reassemble”: two tool families, one prompt.

Way 3: How do you remove a page from a document?

This document has 10 pages. Extract all of them except page 4, then merge the rest back together in order.

The same trick, inverted. Nine single-page files need three merge calls: the first four files, then that result with the next three, then that result with the last two. Before it starts, have the agent check the page count with get_document_info, which returns pageCount and a pages array, so it lists the right page numbers instead of guessing the length.

What should the agent check before it splits?

Requesting page 12 of a ten-page document fails rather than returning less, and the failure costs a round trip. Make inspection the first step:

How many pages does this have? Then extract the last three.

The agent calls get_document_info, reads the page count, computes the last three page numbers, and then calls split. Spreadsheets behave differently: in spreadsheet formats the page numbers address worksheets, not printed pages. “Split out sheet 2” is pages: "2", and the result is a workbook containing that sheet.

Example session (abridged)

An illustration based on the documented tool behavior, not a captured screenshot.

You:   Pull pages 3, 6 and 8 out of report.pdf and give me one file
       with just those pages, in that order.

Agent: [calls get_document_info on report.pdf: 12 pages]
       [calls split with pages = "3,6,8": 3 files]
       [calls merge with the three single-page files in order]
       Done. The rebuilt document is in your output folder. The
       original report.pdf was not changed.

Honest limits

  • The 3-page trim hits rebuilt documents. In evaluation mode the result is trimmed to the first 3 pages, with a trial badge on each page. A rebuilt eight-page range comes back as three pages. Check get_license_status before looking for a bug.
  • Extraction alone is unaffected. The documentation states that extracting single pages is not trimmed; the cap applies the moment you merge the results.
  • No range input. split takes a list of page numbers and returns one file per number.
  • Four documents per merge. Long ranges need rounds.
  • Not an editor. The server extracts and combines whole pages. It does not edit content inside a page, and the documentation notes that in-file reordering belongs to the library API rather than these four tools.

FAQ

Can an AI agent extract pages 5 to 9 from a PDF and merge them? Yes. It lists the pages, calls split for them, and merges the single-page results in rounds of up to four. Order is preserved if you ask for it.

Can AI reorder PDF pages? Within these four tools, only by extracting pages and merging them in the order you want. The server does not move pages inside a file.

How do I split a document by sections with AI? Ask the agent to read the page count first, then name the first page of each section yourself. split extracts the pages you list; it does not detect sections.

Go deeper