Skip to main content
Glama

check_conversions

Analyze PDF files in a directory to identify which documents have been converted to Markdown format and detect any pending conversions.

Instructions

Analyze PDF collection to determine conversion status

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
directory_pathYesPath to directory containing PDF files

Implementation Reference

  • Main handler logic for 'document_organizer__check_conversions' tool. Parses input, discovers PDFs if needed, checks for existing Markdown companions, computes statistics, and returns detailed JSON status report.
    case "document_organizer__check_conversions": { const { directory_path, pdf_files } = CheckConversionsArgsSchema.parse(args); const pdfsToCheck = pdf_files || await findPdfFiles(directory_path); const conversionStatus = []; for (const pdfPath of pdfsToCheck) { const hasMarkdown = await checkMdExists(pdfPath); conversionStatus.push({ pdf_path: pdfPath, has_markdown: hasMarkdown, needs_conversion: !hasMarkdown }); } return { content: [ { type: "text", text: JSON.stringify({ total_pdfs: conversionStatus.length, already_converted: conversionStatus.filter(s => s.has_markdown).length, needs_conversion: conversionStatus.filter(s => s.needs_conversion).length, conversion_status: conversionStatus }, null, 2) } ] }; }
  • Zod schema defining input parameters for the check_conversions tool: directory_path (required) and optional pdf_files array.
    const CheckConversionsArgsSchema = z.object({ directory_path: z.string().describe("Path to directory containing PDF files"), pdf_files: z.array(z.string()).optional().describe("Specific PDF files to check (if not provided, discovers all)") });
  • src/index.ts:1306-1309 (registration)
    Tool registration in the tools array, including name, description, and inputSchema reference.
    name: "document_organizer__check_conversions", description: "✅ CONVERSION STATUS AUDIT - Analyze PDF collection to determine which files already have companion Markdown files. Returns detailed conversion status matrix showing converted vs. unconverted documents, enabling targeted conversion workflows and avoiding duplicate processing.", inputSchema: zodToJsonSchema(CheckConversionsArgsSchema) as ToolInput, },
  • Helper function that checks if a Markdown file companion exists for a given PDF, trying multiple naming conventions.
    async function checkMdExists(pdfPath: string): Promise<boolean> { const dir = path.dirname(pdfPath); const basename = path.basename(pdfPath, '.pdf'); // Check various possible MD naming patterns const possibleMdPaths = [ path.join(dir, `${basename}.md`), path.join(dir, `${basename.replace(/\s+/g, '_')}.md`), path.join(dir, `${basename.replace(/[^a-zA-Z0-9]/g, '_')}.md`) ]; for (const mdPath of possibleMdPaths) { try { await fs.access(mdPath); return true; } catch { // File doesn't exist, continue checking } } return false; }
  • Helper function to recursively find all PDF files in a directory, used when pdf_files not provided.
    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