Skip to main content
Glama

discover_pdfs

Scan directories to find PDF files recursively, enabling systematic document organization and processing workflows.

Instructions

Recursively scan directory trees to locate all PDF files

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
directory_pathYesPath to directory to scan for PDF files
recursiveNoSearch subdirectories recursively

Implementation Reference

  • Handler for the discover_pdfs tool: parses arguments, calls findPdfFiles utility, formats and returns JSON response with discovered PDF files list and statistics.
    case "document_organizer__discover_pdfs": { const { directory_path, recursive } = DiscoverPdfsArgsSchema.parse(args); const pdfFiles = await findPdfFiles(directory_path, recursive); return { content: [ { type: "text", text: JSON.stringify({ found_pdfs: pdfFiles.length, pdf_files: pdfFiles, scanned_directory: directory_path, recursive_scan: recursive }, null, 2) } ] }; }
  • Zod schema defining input parameters for the discover_pdfs tool: directory_path (required string) and recursive (optional boolean, defaults to true).
    const DiscoverPdfsArgsSchema = z.object({ directory_path: z.string().describe("Path to directory to scan for PDF files"), recursive: z.boolean().optional().default(true).describe("Search subdirectories recursively") });
  • src/index.ts:1301-1305 (registration)
    Tool registration entry in the tools array, specifying name, description, and input schema reference.
    name: "document_organizer__discover_pdfs", description: "🔍 PDF FILE DISCOVERY - Recursively scan directory trees to locate all PDF files. Returns complete inventory with file paths, directory structure analysis, and scan statistics. Supports both recursive deep scanning and single-level directory inspection for comprehensive document discovery.", inputSchema: zodToJsonSchema(DiscoverPdfsArgsSchema) as ToolInput, }, {
  • Core utility function that recursively scans the specified directory for PDF files using fs.readdir, collects absolute paths, handles errors gracefully.
    async function findPdfFiles(dirPath: string, recursive: boolean = true): Promise<string[]> { const pdfFiles: string[] = []; async function scanDirectory(currentPath: string) { try { const items = await fs.readdir(currentPath, { withFileTypes: true }); for (const item of items) { const fullPath = path.join(currentPath, item.name); if (item.isFile() && path.extname(item.name).toLowerCase() === '.pdf') { pdfFiles.push(fullPath); } else if (item.isDirectory() && recursive) { await scanDirectory(fullPath); } } } catch (error) { console.error(`Error scanning directory ${currentPath}:`, error); } } await scanDirectory(dirPath); return pdfFiles; }

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/cordlesssteve/document-organizer-mcp'

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