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
| Name | Required | Description | Default |
|---|---|---|---|
| pdf_id | Yes | ID of the PDF to get page count for |
Implementation Reference
- src/pdf_reader_mcp/server.py:507-519 (handler)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", ) ]
- src/pdf_reader_mcp/server.py:384-395 (registration)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(
- src/pdf_reader_mcp/server.py:387-393 (schema)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"], },