Skip to main content
Glama
pietermyb

mcp-pdf-reader

get-pdf-page-count

Count pages in a PDF document to determine its length or verify structure. Provide the PDF ID to retrieve the total number of pages.

Instructions

Get the page count of a PDF

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pdf_idYesID of the PDF to get page count for

Implementation Reference

  • Handler implementation for the 'get-pdf-page-count' tool. Retrieves the PdfReader instance for the given pdf_id from the global pdfs dictionary and returns the number of pages using len(reader.pages).
    elif name == "get-pdf-page-count":
        pdf_id = arguments.get("pdf_id")
        if not pdf_id or pdf_id not in pdfs:
            raise ValueError("Invalid PDF ID")
    
        reader = pdfs[pdf_id]
    
        return [
            types.TextContent(
                type="text",
                text=f"'{os.path.basename(pdf_paths[pdf_id])}' has {len(reader.pages)} pages",
            )
        ]
  • Registration of the 'get-pdf-page-count' tool in the @server.list_tools() function, including name, description, and JSON schema for input validation requiring 'pdf_id'.
    types.Tool(
        name="get-pdf-page-count",
        description="Get the page count of a PDF",
        inputSchema={
            "type": "object",
            "properties": {
                "pdf_id": {"type": "string", "description": "ID of the PDF to get page count for"},
            },
            "required": ["pdf_id"],
        },
    ),
    types.Tool(
  • Input schema definition for the 'get-pdf-page-count' tool, specifying a required 'pdf_id' string parameter.
    inputSchema={
        "type": "object",
        "properties": {
            "pdf_id": {"type": "string", "description": "ID of the PDF to get page count for"},
        },
        "required": ["pdf_id"],
    },
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 what the tool does but lacks details on error handling, performance (e.g., speed for large PDFs), or side effects (e.g., whether it opens/reads the PDF file). This is a significant gap for a tool with no structured safety hints.

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, direct sentence with zero wasted words. It's front-loaded with the core purpose, making it highly efficient and easy to parse for an AI agent.

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 lack of annotations and output schema, the description is incomplete. It doesn't explain what the tool returns (e.g., integer count, error formats) or behavioral traits like resource usage. For a tool with no structured context, more detail 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.

Parameters3/5

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

The input schema has 100% description coverage, with the 'pdf_id' parameter clearly documented. The description adds no additional parameter semantics beyond what the schema provides, such as format examples or constraints. Baseline 3 is appropriate since the schema does the heavy lifting.

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 tool's purpose with a specific verb ('Get') and resource ('page count of a PDF'), making it immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'get-pdf-page-text' or 'list-pdf-metadata', which also retrieve PDF information but serve different purposes.

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 scenarios where page count is needed over other PDF operations, nor does it reference sibling tools for comparison, leaving the agent to infer usage from tool names alone.

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/pietermyb/mcp-pdf-reader'

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