Skip to main content
Glama
andr3medeiros

PDF Manipulation MCP Server

pdf_get_info

Extract metadata and information from PDF files to analyze document properties, page count, and structure details.

Instructions

Get metadata and information about a PDF.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pdf_pathYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function for the 'pdf_get_info' tool. It validates the PDF file, opens it with PyMuPDF (fitz), extracts page count, file size, first page dimensions, and all metadata fields, then formats and returns the information as a string. The @mcp.tool() decorator registers it with the FastMCP server.
    @mcp.tool()
    async def pdf_get_info(pdf_path: str) -> str:
        """Get metadata and information about 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)
            
            # Get basic information
            page_count = len(doc)
            file_size = os.path.getsize(pdf_path)
            
            # Get metadata
            metadata = doc.metadata
            
            # Get page dimensions (first page)
            first_page = doc[0]
            page_rect = first_page.rect
            page_width = page_rect.width
            page_height = page_rect.height
            
            # Close document
            doc.close()
            
            # Format information
            info_text = f"""PDF Information for: {pdf_path}
    
    Basic Information:
    - Page count: {page_count}
    - File size: {file_size:,} bytes
    - Page dimensions: {page_width:.1f} x {page_height:.1f} points
    
    Metadata:
    - Title: {metadata.get('title', 'N/A')}
    - Author: {metadata.get('author', 'N/A')}
    - Subject: {metadata.get('subject', 'N/A')}
    - Creator: {metadata.get('creator', 'N/A')}
    - Producer: {metadata.get('producer', 'N/A')}
    - Creation date: {metadata.get('creationDate', 'N/A')}
    - Modification date: {metadata.get('modDate', 'N/A')}
    - Keywords: {metadata.get('keywords', 'N/A')}
    - Format: {metadata.get('format', 'N/A')}
    - Encryption: {metadata.get('encryption', 'N/A')}"""
            
            return info_text
            
        except Exception as e:
            return f"Error getting PDF info: {str(e)}"
  • Helper utility function used by pdf_get_info (and other tools) to validate that the provided file path points to a valid PDF document.
    def validate_pdf_file(pdf_path: str) -> bool:
        """Validate that the file is a valid PDF."""
        try:
            doc = fitz.open(pdf_path)
            doc.close()
            return True
        except Exception:
            return False

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv1.0.0
    • addedInput schema / title
      Added value: +"pdf_get_infoArguments"
  2. First observed

TDQS

B3.2/5.0
Behavior3/5

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

No annotations are provided, so the description carries the full burden. The verb 'Get' implies a read-only operation with no side effects, but it does not explicitly state that the PDF is not modified, nor does it mention error behavior or prerequisites like file existence. The behavior is not contradicted, but it is under-specified for a tool with zero annotation coverage.

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, front-loaded sentence with no filler or repetition. It efficiently communicates the core function in just seven words, earning full marks for conciseness.

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?

The tool is simple with one parameter and an output schema, so the description does not need to explain return values. However, it lacks any usage guidance and explicit read-only confirmation, making it minimally viable but not fully complete for an agent deciding when and how to invoke it.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0% and the description adds no meaning to the single parameter 'pdf_path'. The parameter name is self-evident but the description does not explain its format, required location, or any constraints, so the description fails to compensate for the lack of schema documentation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses a specific verb ('Get') and resource ('PDF') and clearly states it retrieves metadata and information. It distinguishes itself from all sibling tools, which are mutating operations (add, replace, merge, split, etc.), so the purpose is unmistakable.

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 does not mention that it is intended for inspection before modification, nor does it name any exclusions or alternative tools, so an agent gets no usage context beyond the obvious difference from sibling names.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.