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
Behavior2/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 of behavioral disclosure. It states 'Get metadata and information' but doesn't specify what information is included (e.g., page count, author, creation date), whether it's read-only (implied but not explicit), or any error handling. This leaves significant gaps for a tool with potential complexity.

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 with no wasted words, making it easy to parse. It's appropriately sized for a simple-sounding tool and front-loads the key action and resource.

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 apparent simplicity (1 parameter, no annotations, but has an output schema), the description is minimally adequate. The output schema likely covers return values, reducing the need for description detail, but the lack of parameter semantics and behavioral context leaves it incomplete for reliable use.

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

Parameters2/5

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

The input schema has 1 parameter (pdf_path) with 0% description coverage, and the tool description adds no semantic details about it. It doesn't explain what pdf_path represents (e.g., file path, URL, identifier) or its format, failing to compensate for the schema's lack of documentation.

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 'Get' and the resource 'metadata and information about a PDF', making the purpose understandable. However, it doesn't distinguish this read operation from its many siblings (e.g., pdf_set_metadata for writing metadata or pdf_extract_images for extracting content), which prevents a perfect score.

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. With siblings like pdf_set_metadata (for writing metadata) and pdf_extract_images (for extracting content), it's unclear if this tool is for basic metadata retrieval, comprehensive info, or something else, leaving the agent without usage context.

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