/** * ┌─────────────────────────────────────────────────────────────────────────┐ * │ ANALYZE PDF PAGE TOOL - MCP Tool Implementation │ * ├─────────────────────────────────────────────────────────────────────────┤ * │ Filename: analyze-pdf-page.tool.ts │ * │ Language: TypeScript │ * │ MCP Server: PDF Operations Server │ * │ │ * │ Purpose: │ * │ Implements an MCP tool that analyzes PDF page dimensions, margins, │ * │ and layout properties. Provides comprehensive page information for │ * │ accurate element positioning and layout calculations. │ * │ │ * │ Why this tool exists: │ * │ - Enables AI to understand PDF page layout and structure │ * │ - Provides foundation for intelligent watermark placement │ * │ - Supports accurate coordinate calculations for PDF operations │ * │ - Essential for proper element positioning in PDFs │ * │ │ * │ MCP Tool Information: │ * │ Tool Name: analyze-pdf-page │ * │ Category: pdf-operations │ * │ Input: { filePath, pageNumber } │ * │ Output: { dimensions, margins, mediaBox, cropBox, etc. } │ * │ │ * │ Key Features: │ * │ - Extracts page dimensions (width, height, rotation) │ * │ - Provides dimensions in multiple units (points, inches, mm) │ * │ - Estimates or detects page margins │ * │ - Returns MediaBox and CropBox information │ * │ - Supports all standard and custom page sizes │ * │ │ * │ Dependencies: │ * │ - @modelcontextprotocol/sdk: MCP server SDK │ * │ - zod: Input validation and schema definition │ * │ - pdf-lib: PDF document manipulation │ * │ - ../utils/page-analysis-utils: Page analysis functions │ * │ - ../utils/path-resolver: File path resolution │ * │ │ * │ Related Tools: │ * │ - detect-text-position: Finds exact text positions in PDFs │ * │ - add-pdf-watermark: Uses page info for watermark placement │ * │ │ * │ Security Considerations: │ * │ - Validates file paths to prevent traversal attacks │ * │ - Validates page numbers within document bounds │ * │ - Handles corrupted PDFs gracefully │ * │ - Limits analysis to prevent resource exhaustion │ * │ │ * │ Author: PDF MCP Team │ * │ Created: 2025-10-30 │ * │ Version: 1.0.0 │ * └─────────────────────────────────────────────────────────────────────────┘ */ import { z } from 'zod'; import type { PageAnalysisResult } from '../types.js'; /** * Zod schema for analyze-pdf-page tool input validation */ export declare const AnalyzePdfPageInputSchema: { filePath: z.ZodString; pageNumber: z.ZodOptional; }; /** * Zod schema for analyze-pdf-page tool output */ export declare const AnalyzePdfPageOutputSchema: { filePath: z.ZodString; pageNumber: z.ZodNumber; dimensions: z.ZodObject<{ width: z.ZodNumber; height: z.ZodNumber; rotation: z.ZodNumber; inchDimensions: z.ZodObject<{ width: z.ZodNumber; height: z.ZodNumber; }, "strip", z.ZodTypeAny, { width: number; height: number; }, { width: number; height: number; }>; mmDimensions: z.ZodObject<{ width: z.ZodNumber; height: z.ZodNumber; }, "strip", z.ZodTypeAny, { width: number; height: number; }, { width: number; height: number; }>; }, "strip", z.ZodTypeAny, { rotation: number; width: number; height: number; inchDimensions: { width: number; height: number; }; mmDimensions: { width: number; height: number; }; }, { rotation: number; width: number; height: number; inchDimensions: { width: number; height: number; }; mmDimensions: { width: number; height: number; }; }>; margins: z.ZodObject<{ top: z.ZodNumber; bottom: z.ZodNumber; left: z.ZodNumber; right: z.ZodNumber; detected: z.ZodBoolean; }, "strip", z.ZodTypeAny, { left: number; right: number; top: number; bottom: number; detected: boolean; }, { left: number; right: number; top: number; bottom: number; detected: boolean; }>; mediaBox: z.ZodObject<{ x: z.ZodNumber; y: z.ZodNumber; width: z.ZodNumber; height: z.ZodNumber; }, "strip", z.ZodTypeAny, { x: number; y: number; width: number; height: number; }, { x: number; y: number; width: number; height: number; }>; cropBox: z.ZodOptional>; contentBox: z.ZodOptional>; }; /** * Analyzes a PDF page and returns comprehensive layout information * * @param params - Analysis parameters * @returns Complete page analysis result * @throws Error if file cannot be processed or page number is invalid */ export declare function analyzePdfPage(params: { filePath: string; pageNumber?: number | undefined; }): Promise; /** * Tool handler for analyze-pdf-page * Formats the result for MCP protocol */ export declare const analyzePdfPageToolHandler: (params: { filePath: string; pageNumber?: number | undefined; }) => Promise<{ content: { type: "text"; text: string; }[]; structuredContent: PageAnalysisResult; }>; //# sourceMappingURL=analyze-pdf-page.tool.d.ts.map