Skip to main content
Glama
andr3medeiros

PDF Manipulation MCP Server

pdf_delete_page

Remove specific pages from PDF files to eliminate unwanted content or streamline documents for sharing and archiving.

Instructions

Delete a page from a PDF.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pdf_pathYes
page_numberYes

Implementation Reference

  • The primary handler function for the 'pdf_delete_page' tool, including its @mcp.tool() decorator which handles registration in the FastMCP framework. It validates the PDF file and page number, deletes the specified page using PyMuPDF (fitz.Document.delete_page()), generates a timestamped output filename, saves the modified PDF, and returns the success message with the output path.
    @mcp.tool() async def pdf_delete_page( pdf_path: str, page_number: int ) -> str: """Delete a page from a PDF.""" 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) # Validate page number if not validate_page_number(doc, page_number): doc.close() return f"Error: Invalid page number {page_number}. Document has {len(doc)} pages." # Delete the page doc.delete_page(page_number) # Generate output filename output_path = generate_output_filename(pdf_path) # Save the modified PDF doc.save(output_path) doc.close() return f"Successfully deleted page {page_number + 1}. Output saved to: {output_path}" except Exception as e: return f"Error deleting page: {str(e)}"

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