Skip to main content
Glama

get_pdf_page_count

Get the total page count of a PDF file by specifying its absolute file path.

Instructions

Get the total number of pages in a PDF file

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filePathYesAbsolute path to the PDF file

Implementation Reference

  • src/index.ts:101-114 (registration)
    Tool registration in TOOLS array with name 'get_pdf_page_count' and input schema requiring filePath
    {
      name: 'get_pdf_page_count',
      description: 'Get the total number of pages in a PDF file',
      inputSchema: {
        type: 'object',
        properties: {
          filePath: {
            type: 'string',
            description: 'Absolute path to the PDF file',
          },
        },
        required: ['filePath'],
      },
    },
  • Input schema for get_pdf_page_count: requires filePath as a string
      inputSchema: {
        type: 'object',
        properties: {
          filePath: {
            type: 'string',
            description: 'Absolute path to the PDF file',
          },
        },
        required: ['filePath'],
      },
    },
  • Handler case in CallToolRequestSchema switch statement; calls getPageCount and returns 'Total pages: X'
    case 'get_pdf_page_count': {
      const { filePath } = args as { filePath: string };
      const pageCount = await getPageCount(filePath);
      
      return {
        content: [
          {
            type: 'text',
            text: `Total pages: ${pageCount}`,
          },
        ],
      };
    }
  • Core implementation: reads PDF file, uses PDFParse to get info, returns total page count
    export async function getPageCount(filePath: string): Promise<number> {
      try {
        const dataBuffer = await fs.readFile(filePath);
        const parser = new PDFParse({ data: dataBuffer });
        const result = await parser.getInfo();
        await parser.destroy();
        return result.total;
      } catch (error) {
        throw new Error(`Failed to get page count: ${error instanceof Error ? error.message : String(error)}`);
      }
    }
  • Import of getPageCount from pdf-tools.js helper module
    import {
      extractTextFromPDF,
      extractMetadata,
      extractTextFromPages,
      searchInPDF,
      getPageCount,
Behavior2/5

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

No annotations exist, so the description must cover behavior. It only states the purpose without disclosing error handling, return format, performance characteristics, or file access assumptions.

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?

Single sentence, no filler, front-loaded with key action. Every word earns its place.

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 no output schema and no annotations, the description is too sparse. It lacks return type, error cases, and usage examples, leaving the agent with minimal actionable detail.

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?

Schema coverage is 100% with a single parameter well-described in the schema. The description does not add new semantics beyond repeating 'PDF file', so baseline score fits.

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 resource 'total number of pages in a PDF file', distinguishing it from siblings like get_pdf_metadata or read_pdf.

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 on when to use this tool versus alternatives such as read_pdf_pages or search_pdf. No context about prerequisites or typical use cases.

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

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