Skip to main content
Glama
andr3medeiros

PDF Manipulation MCP Server

pdf_set_metadata

Set or modify metadata properties in PDF files, such as title, author, keywords, and custom fields, to organize and describe document content.

Instructions

Set metadata for a PDF.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pdf_pathYes
metadataYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function for the 'pdf_set_metadata' tool. It validates the PDF file, opens it using PyMuPDF (fitz), iteratively sets each metadata field provided in the input dictionary, generates a timestamped output filename to avoid overwriting the original, saves the modified PDF, and returns a success message with the updated fields and output path.
    @mcp.tool()
    async def pdf_set_metadata(
        pdf_path: str,
        metadata: Dict[str, str]
    ) -> str:
        """Set metadata for 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)
            
            # Set metadata fields
            updated_fields = []
            for field, value in metadata.items():
                if value:  # Only set non-empty values
                    doc.set_metadata({field: str(value)})
                    updated_fields.append(f"{field}: {value}")
            
            # Generate output filename
            output_path = generate_output_filename(pdf_path)
            
            # Save the modified PDF
            doc.save(output_path)
            doc.close()
            
            if updated_fields:
                return f"Successfully updated metadata. Output saved to: {output_path}\nUpdated fields:\n" + "\n".join(updated_fields)
            else:
                return "No metadata fields to update."
            
        except Exception as e:
            return f"Error setting PDF metadata: {str(e)}"
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool sets metadata but fails to describe critical traits such as whether it modifies the PDF in-place or creates a new file, what permissions are required, or potential side effects (e.g., overwriting existing metadata). This leaves significant gaps in understanding the tool's behavior.

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 is appropriately sized for a simple tool, though this brevity contributes to gaps in other dimensions like guidelines and transparency.

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

Completeness2/5

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

Given the complexity (2 parameters with nested objects, no annotations, and an output schema exists), the description is incomplete. It does not explain what metadata can be set, how the tool behaves, or reference the output schema for results. For a mutation tool with rich input structure, more context is needed to guide effective 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?

Schema description coverage is 0%, so the description must compensate but does not. It mentions 'metadata' generically without explaining what keys or values are supported (e.g., strings for title, author). The input schema shows 'pdf_path' and 'metadata' as required objects, but the description adds no meaning beyond the schema's structure, failing to clarify parameter usage.

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

Purpose3/5

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

The description 'Set metadata for a PDF' clearly states the action (set) and resource (PDF metadata), making the purpose understandable. However, it lacks specificity about what metadata can be set (e.g., title, author, keywords) and does not distinguish it from sibling tools like 'pdf_get_info' which might retrieve metadata, leaving room for ambiguity.

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?

No guidance is provided on when to use this tool versus alternatives. It does not mention prerequisites (e.g., needing an existing PDF file), exclusions, or how it differs from siblings like 'pdf_get_info' or other PDF manipulation tools, leaving the agent without context for tool selection.

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