Skip to main content
Glama
pablontiv
by pablontiv

extract_pdf_metadata

Access and retrieve metadata and document details from PDF files using a robust server. Input the file path to extract essential information efficiently.

Instructions

Extract metadata and document information from PDF files

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYesPath to the PDF file to extract metadata from

Implementation Reference

  • Main handler function that validates input parameters and delegates metadata extraction to MetadataParser
    export async function handleExtractMetadata(args: unknown): Promise<PDFMetadata> { try { const params = ExtractMetadataParamsSchema.parse(args); const parser = new MetadataParser(); return await parser.parseMetadata(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)); } }
  • Core parsing logic using pdf-parse library to extract metadata from PDF buffer, including validation, file reading, and timeout handling
    async parseMetadata(filePath: string): Promise<PDFMetadata> { await validatePDFFile(filePath); const buffer = await fs.readFile(filePath); const stats = await fs.stat(filePath); const pdfData = await withTimeout( pdf(buffer), this.config.processingTimeout ); return this.formatMetadata(pdfData, stats.size); }
  • Zod schema for validating the tool input parameters (file_path)
    export const ExtractMetadataParamsSchema = z.object({ file_path: filePathValidation });
  • src/index.ts:63-71 (registration)
    Tool dispatch/registration in the main server request handler switch statement
    case 'extract_pdf_metadata': return { content: [ { type: 'text', text: JSON.stringify(await handleExtractMetadata(args), null, 2), }, ], };
  • Tool definition including name, description, and input schema for MCP registration
    name: 'extract_pdf_metadata', description: 'Extract metadata and document information from PDF files', inputSchema: { type: 'object', properties: { file_path: { type: 'string', description: 'Path to the PDF file to extract metadata from' } }, required: ['file_path'] } };

Other Tools

Related 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