Skip to main content
Glama
pietermyb

mcp-pdf-reader

get-pdf-page-text

Extract text from a specific page in a PDF document using its ID and page number for targeted content retrieval.

Instructions

Get the text content of a specific page in a PDF

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pdf_idYesID of the PDF to get page text from
page_numberYesPage number (0-based index)

Implementation Reference

  • Implements the core logic for the 'get-pdf-page-text' tool: validates inputs, retrieves the PDF reader, extracts text from the specified page using PyPDF2, and returns the text content.
    elif name == "get-pdf-page-text":
        pdf_id = arguments.get("pdf_id")
        if not pdf_id or pdf_id not in pdfs:
            raise ValueError("Invalid PDF ID")
    
        page_number = arguments.get("page_number")
        if page_number is None:
            raise ValueError("Missing page number")
    
        reader = pdfs[pdf_id]
    
        # Check if page number is valid
        if page_number < 0 or page_number >= len(reader.pages):
            raise ValueError(f"Invalid page number. PDF has {len(reader.pages)} pages (0-{len(reader.pages)-1})")
    
        # Extract text from the specified page
        page = reader.pages[page_number]
        page_text = page.extract_text()
    
        if not page_text:
            page_text = f"No extractable text found on page {page_number}"
    
        return [
            types.TextContent(
                type="text",
                text=f"Text from page {page_number} of '{os.path.basename(pdf_paths[pdf_id])}':\n\n{page_text}",
            )
        ]
  • Registers the 'get-pdf-page-text' tool with MCP server, providing name, description, and JSON schema for input validation (pdf_id and page_number required).
    types.Tool(
        name="get-pdf-page-text",
        description="Get the text content of a specific page in a PDF",
        inputSchema={
            "type": "object",
            "properties": {
                "pdf_id": {"type": "string", "description": "ID of the PDF to get page text from"},
                "page_number": {"type": "integer", "description": "Page number (0-based index)"},
            },
            "required": ["pdf_id", "page_number"],
        },
    ),
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. While it states what the tool does, it doesn't mention important behavioral aspects like whether this is a read-only operation, what format the text is returned in, potential errors (e.g., invalid page numbers), or performance characteristics. For a tool with zero annotation coverage, this leaves significant gaps.

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 extremely concise and front-loaded with exactly one sentence that directly states the tool's purpose. There's no wasted language or unnecessary elaboration, making it easy to parse while conveying the essential information.

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 that there are no annotations and no output schema, the description is insufficiently complete. It doesn't explain what the return value looks like (e.g., plain text, structured data), potential limitations, or how it interacts with sibling tools. For a tool with 2 parameters and no structured behavioral hints, more context is needed to help an agent use it effectively.

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 description doesn't add any parameter-specific information beyond what's already in the schema, which has 100% coverage with clear descriptions for both parameters. The baseline score of 3 is appropriate since the schema adequately documents the parameters, though the description could have added context like how to obtain the pdf_id or page numbering conventions.

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 ('text content of a specific page in a PDF'), making it easy to understand what the tool does. However, it doesn't explicitly distinguish itself from sibling tools like 'pdf-to-text' or 'get-pdf-page-count', which could cause confusion about when to use each one.

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. With siblings like 'pdf-to-text' (which might extract all pages) and 'get-pdf-page-count' (which returns metadata), there's no indication of when this single-page extraction tool is preferred or what prerequisites might be needed (e.g., whether the PDF must be opened first).

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