Skip to main content
Glama
cordlesssteve

Document Organizer MCP Server

full_workflow

Organize documents automatically by converting PDFs to Markdown, categorizing content, and managing workflows in a specified directory.

Instructions

Execute end-to-end document organization pipeline

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
directory_pathYesPath to directory to organize completely

Implementation Reference

  • Main execution handler for the 'document_organizer__full_workflow' tool. Orchestrates the complete document processing pipeline: PDF discovery, conversion status check, selective PDF-to-Markdown conversion of missing files, optional content analysis for categorization, and comprehensive workflow reporting.
    case "document_organizer__full_workflow": {
      const { directory_path, analyze_content } = FullWorkflowArgsSchema.parse(args);
      
      const workflow = [];
      
      // Step 1: Discover PDFs
      const pdfFiles = await findPdfFiles(directory_path);
      workflow.push({ step: "discover", found_pdfs: pdfFiles.length });
      
      // Step 2: Check conversions
      const conversionStatus = [];
      for (const pdfPath of pdfFiles) {
        const hasMarkdown = await checkMdExists(pdfPath);
        conversionStatus.push({
          pdf_path: pdfPath,
          has_markdown: hasMarkdown,
          needs_conversion: !hasMarkdown
        });
      }
      workflow.push({ 
        step: "check_conversions", 
        needs_conversion: conversionStatus.filter(s => s.needs_conversion).length 
      });
      
      // Step 3: Convert missing
      const conversions = [];
      for (const status of conversionStatus) {
        if (status.needs_conversion) {
          const result = await convertPdfToMd(status.pdf_path);
          conversions.push({ pdf_path: status.pdf_path, ...result });
        }
      }
      workflow.push({ 
        step: "convert_missing", 
        conversions_attempted: conversions.length,
        successful: conversions.filter(c => c.success).length
      });
      
      // Step 4: Analyze content (if requested)
      let categorization = {};
      if (analyze_content) {
        // Find all markdown files after conversion
        const allMdFiles: string[] = [];
        async function findMdFiles(dir: string) {
          const items = await fs.readdir(dir, { withFileTypes: true });
          for (const item of items) {
            const fullPath = path.join(dir, item.name);
            if (item.isFile() && path.extname(item.name).toLowerCase() === '.md') {
              allMdFiles.push(fullPath);
            } else if (item.isDirectory()) {
              await findMdFiles(fullPath);
            }
          }
        }
        await findMdFiles(directory_path);
        
        const analyses = [];
        for (const mdPath of allMdFiles) {
          const analysis = await analyzeMarkdownContent(mdPath);
          analyses.push({ file_path: mdPath, ...analysis });
        }
        
        categorization = analyses.reduce((acc, analysis) => {
          if (!acc[analysis.category]) {
            acc[analysis.category] = [];
          }
          acc[analysis.category].push(analysis.file_path);
          return acc;
        }, {} as Record<string, string[]>);
        
        workflow.push({ 
          step: "analyze_content", 
          files_analyzed: analyses.length,
          categories_identified: Object.keys(categorization).length
        });
      }
      
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify({
              workflow_completed: true,
              steps: workflow,
              final_categorization: categorization,
              summary: {
                pdfs_found: pdfFiles.length,
                conversions_needed: conversions.length,
                successful_conversions: conversions.filter(c => c.success).length,
                categories_suggested: Object.keys(categorization).length
              }
            }, null, 2)
          }
        ]
      };
    }
  • Zod schema defining input parameters for the full_workflow tool: directory_path (required string) and analyze_content (optional boolean, default true).
    const FullWorkflowArgsSchema = z.object({
      directory_path: z.string().describe("Path to directory to organize completely"),
      analyze_content: z.boolean().optional().default(true).describe("Analyze content for categorization")
    });
  • src/index.ts:1326-1330 (registration)
    Tool registration entry in the tools array, including name, description, and inputSchema reference to FullWorkflowArgsSchema. Registered with the MCP server via setRequestHandler for ListToolsRequestSchema.
      name: "document_organizer__full_workflow",
      description: "🔄 COMPLETE DOCUMENT AUTOMATION - Execute end-to-end document organization pipeline: (1) Discover all PDFs recursively, (2) Check conversion status, (3) Convert missing PDFs to Markdown, (4) Analyze content for categorization, (5) Create organized folder structure. Returns detailed workflow progress with success/failure counts, processing statistics, and final organization summary. One-command solution for complete document management.",
      inputSchema: zodToJsonSchema(FullWorkflowArgsSchema) as ToolInput,
    },
    {

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