Skip to main content
Glama
pablontiv

PDF Reader MCP Server

by pablontiv

extract_pdf_pages

Extract content from specific pages or page ranges of PDF documents to retrieve text or structured data for focused analysis.

Instructions

Extract content from specific pages or page ranges of PDF documents

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYesPath to the PDF file to extract pages from
page_rangeYesPage range to extract (e.g., "1-3", "2,4,6", or "all")
output_formatNoOutput format: "text" for plain text, "structured" for formatted texttext

Implementation Reference

  • The core handler function for 'extract_pdf_pages' tool. It validates input using ExtractPagesParamsSchema, instantiates TextExtractor, calls extractFromPages, and handles errors.
    export async function handleExtractPages(args: unknown): Promise<ExtractPagesResult> {
      try {
        const params = ExtractPagesParamsSchema.parse(args);
        const extractor = new TextExtractor();
        
        return await extractor.extractFromPages(
          params.file_path,
          params.page_range,
          params.output_format
        );
      } catch (error) {
        const mcpError = handleError(error, typeof args === 'object' && args !== null && 'file_path' in args ? String(args.file_path) : undefined);
        throw new Error(JSON.stringify(mcpError));
      }
    }
  • Tool definition object for 'extract_pdf_pages' including the input schema for validation.
    export const extractPagesTool: Tool = {
      name: 'extract_pdf_pages',
      description: 'Extract content from specific pages or page ranges of PDF documents',
      inputSchema: {
        type: 'object',
        properties: {
          file_path: {
            type: 'string',
            description: 'Path to the PDF file to extract pages from'
          },
          page_range: {
            type: 'string',
            description: 'Page range to extract (e.g., "1-3", "2,4,6", or "all")'
          },
          output_format: {
            type: 'string',
            enum: ['text', 'structured'],
            description: 'Output format: "text" for plain text, "structured" for formatted text',
            default: 'text'
          }
        },
        required: ['file_path', 'page_range']
      }
    };
  • src/index.ts:73-81 (registration)
    Registration in the switch statement that dispatches tool calls to the handleExtractPages function.
    case 'extract_pdf_pages':
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(await handleExtractPages(args), null, 2),
          },
        ],
      };
  • src/index.ts:41-45 (registration)
    Registration of the extractPagesTool in the listTools response.
      extractTextTool,
      extractMetadataTool,
      extractPagesTool,
      validatePDFTool,
    ],
  • src/index.ts:15-15 (registration)
    Import of the tool definition and handler for 'extract_pdf_pages'.
    import { extractPagesTool, handleExtractPages } from './tools/extract-pages.js';
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 mentions extraction but doesn't cover critical aspects like whether this modifies the original file, requires specific permissions, handles errors, or has rate limits. For a tool with three parameters and no annotations, this is a significant gap in transparency.

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, efficient sentence that front-loads the core purpose without any wasted words. It's appropriately sized for the tool's complexity and gets straight to the point.

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 tool has no annotations, no output schema, and three parameters, the description is incomplete. It doesn't explain what 'extract content' means in practice (e.g., returns text, images, or something else), lacks error handling or behavioral context, and doesn't guide usage relative to siblings. For a tool with this complexity, more context is needed.

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 schema description coverage is 100%, so the schema already documents all parameters thoroughly. The description adds no additional meaning beyond what's in the schema (e.g., it doesn't explain 'structured' format details or provide examples beyond the schema's 'page_range' examples). Baseline 3 is appropriate when 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 ('extract content') and resource ('PDF documents'), and specifies the scope ('specific pages or page ranges'). However, it doesn't explicitly differentiate from sibling tools like 'extract_pdf_text' or 'extract_pdf_metadata', which prevents a perfect score.

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 like 'extract_pdf_text' (which might extract all pages) or 'validate_pdf'. It lacks context about use cases, prerequisites, or exclusions, leaving the agent to infer usage from the purpose 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/pablontiv/pdf-reader-mcp'

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