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"], },

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