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
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"file_path": "<file_path>"
},
"name": "validate_pdf"
}
}Input 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), }, ], };