Skip to main content
Glama
andr3medeiros

PDF Manipulation MCP Server

pdf_split

Split PDF files into individual pages or specific page ranges to extract, organize, or manage document sections.

Instructions

Split a PDF into individual pages or page ranges.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pdf_pathYes
output_dirNo
page_rangesNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The primary handler implementation for the 'pdf_split' MCP tool. This async function handles splitting a PDF file into individual pages or custom page ranges using PyMuPDF (fitz). The @mcp.tool() decorator registers it automatically in the FastMCP server. Input parameters define the schema via type hints.
    @mcp.tool()
    async def pdf_split(
        pdf_path: str,
        output_dir: Optional[str] = None,
        page_ranges: Optional[List[Dict[str, int]]] = None
    ) -> str:
        """Split a PDF into individual pages or page ranges."""
        if not os.path.exists(pdf_path):
            return f"Error: PDF file not found: {pdf_path}"
        
        if not validate_pdf_file(pdf_path):
            return f"Error: Invalid PDF file: {pdf_path}"
        
        try:
            # Open PDF document
            doc = fitz.open(pdf_path)
            
            # Determine output directory
            if not output_dir:
                pdf_file = Path(pdf_path)
                output_dir = str(pdf_file.parent / f"{pdf_file.stem}_split")
            
            # Create output directory
            os.makedirs(output_dir, exist_ok=True)
            
            split_files = []
            
            if page_ranges:
                # Split by page ranges
                for i, page_range in enumerate(page_ranges):
                    start_page = page_range["start"]
                    end_page = page_range["end"]
                    
                    # Validate page range
                    if start_page < 0 or end_page >= len(doc) or start_page > end_page:
                        doc.close()
                        return f"Error: Invalid page range {start_page}-{end_page}"
                    
                    # Create new document for this range
                    new_doc = fitz.open()
                    new_doc.insert_pdf(doc, from_page=start_page, to_page=end_page)
                    
                    # Save split PDF
                    output_file = os.path.join(output_dir, f"pages_{start_page + 1}_to_{end_page + 1}.pdf")
                    new_doc.save(output_file)
                    new_doc.close()
                    split_files.append(output_file)
            else:
                # Split into individual pages
                for page_num in range(len(doc)):
                    new_doc = fitz.open()
                    new_doc.insert_pdf(doc, from_page=page_num, to_page=page_num)
                    
                    output_file = os.path.join(output_dir, f"page_{page_num + 1}.pdf")
                    new_doc.save(output_file)
                    new_doc.close()
                    split_files.append(output_file)
            
            doc.close()
            
            return f"Successfully split PDF into {len(split_files)} files. Output directory: {output_dir}"
            
        except Exception as e:
            return f"Error splitting PDF: {str(e)}"
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It states the action ('split') but doesn't disclose behavioral traits like whether it modifies the original file, creates new files, requires specific permissions, handles errors, or has performance considerations. For a tool that presumably creates output files, this lack of transparency about file handling and side effects is inadequate.

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, efficient sentence that front-loads the core purpose. Every word earns its place with no redundancy or fluff. It's appropriately sized for a straightforward tool.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (splitting PDFs with 3 parameters) and the presence of an output schema (which likely describes the return values), the description is minimally adequate. However, with no annotations and 0% schema description coverage, it should provide more context about file operations, error handling, or usage scenarios to be truly complete.

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 0%, so the description must compensate. It mentions 'individual pages or page ranges', which relates to the 'page_ranges' parameter, but doesn't explain 'pdf_path' or 'output_dir'. The description adds minimal meaning beyond the schema's parameter names, failing to fully compensate for the coverage gap. With 3 parameters and no schema descriptions, baseline expectations are higher.

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 verb ('split') and resource ('a PDF'), specifying it can be done 'into individual pages or page ranges'. It distinguishes from siblings like pdf_merge_files or pdf_delete_page by focusing on splitting rather than merging, deleting, or other operations. However, it doesn't explicitly differentiate from all siblings (e.g., pdf_combine_pages_to_single might be related but opposite).

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. It doesn't mention prerequisites, when splitting is appropriate versus other PDF operations, or any context for choosing between individual pages or page ranges. With many sibling tools available, this lack of differentiation is a significant gap.

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/andr3medeiros/pdf-manipulation-mcp-server'

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