validate_pdf
Check PDF file integrity and readability to ensure documents are not corrupted and can be properly processed.
Instructions
Validate PDF file integrity and readability
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file_path | Yes | Path to the PDF file to validate |
Implementation Reference
- src/tools/validate-pdf.ts:22-32 (handler)The primary handler function that implements the core logic of the 'validate_pdf' tool. It parses input arguments using Zod schema and calls PDFProcessor to perform the PDF validation.export async function handleValidatePDF(args: unknown): Promise<ValidationResult> { try { const params = ValidatePDFParamsSchema.parse(args); const processor = new PDFProcessor(); return await processor.validatePDF(params.file_path); } 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)); } }
- src/tools/validate-pdf.ts:7-20 (registration)The Tool object definition registering the 'validate_pdf' tool with MCP, including name, description, and inline input schema.export const validatePDFTool: Tool = { name: 'validate_pdf', description: 'Validate PDF file integrity and readability', inputSchema: { type: 'object', properties: { file_path: { type: 'string', description: 'Path to the PDF file to validate' } }, required: ['file_path'] } };
- src/types/mcp-types.ts:24-26 (schema)Zod schema for validating the input parameters of the 'validate_pdf' tool, used in the handler for runtime parsing.export const ValidatePDFParamsSchema = z.object({ file_path: filePathValidation });
- src/index.ts:39-46 (registration)Registration of the 'validate_pdf' tool (via validatePDFTool) in the MCP server's listTools handler, making it discoverable.this.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [ extractTextTool, extractMetadataTool, extractPagesTool, validatePDFTool, ], }));
- src/index.ts:83-91 (registration)Wiring of the 'validate_pdf' tool handler (handleValidatePDF) in the MCP server's callTool request handler for execution.case 'validate_pdf': return { content: [ { type: 'text', text: JSON.stringify(await handleValidatePDF(args), null, 2), }, ], };