Skip to main content
Glama

organize_structure

Create hierarchical directory structures and move files to appropriate locations based on user-defined categories and file patterns for systematic document organization.

Instructions

Create hierarchical directory structure and move files to appropriate locations

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
categoriesYesCategories with their associated file patterns/names
directory_pathYesPath to directory to organize

Implementation Reference

  • The main handler function for the 'document_organizer__organize_structure' tool. It parses input arguments, iterates over provided categories, creates category directories (with optional PDFs/MDs subfolders), and returns a JSON summary of the created structure. Note: It prepares the folder structure but does not actually move files based on patterns.
    case "document_organizer__organize_structure": { const { directory_path, categories, create_pdf_md_subfolders } = OrganizeStructureArgsSchema.parse(args); const results = []; for (const [categoryName, filePatterns] of Object.entries(categories)) { const categoryPath = path.join(directory_path, categoryName); // Create category directory await fs.mkdir(categoryPath, { recursive: true }); if (create_pdf_md_subfolders) { const pdfDir = path.join(categoryPath, 'PDFs'); const mdDir = path.join(categoryPath, 'MDs'); await fs.mkdir(pdfDir, { recursive: true }); await fs.mkdir(mdDir, { recursive: true }); } results.push({ category: categoryName, path: categoryPath, files_to_organize: filePatterns.length, subfolders_created: create_pdf_md_subfolders }); } return { content: [ { type: "text", text: JSON.stringify({ categories_created: results.length, organization_results: results }, null, 2) } ] }; }
  • Zod schema defining the input parameters for the organize_structure tool: directory_path (string), categories (record of string arrays for file patterns), create_pdf_md_subfolders (boolean, default true).
    const OrganizeStructureArgsSchema = z.object({ directory_path: z.string().describe("Path to directory to organize"), categories: z.record(z.array(z.string())).describe("Categories with their associated file patterns/names"), create_pdf_md_subfolders: z.boolean().optional().default(true).describe("Create PDFs and MDs subfolders in each category") });
  • src/index.ts:1321-1324 (registration)
    Tool registration object in the tools array, defining the name 'document_organizer__organize_structure', its description, and linking to the OrganizeStructureArgsSchema.
    name: "document_organizer__organize_structure", description: "🏗️ AUTOMATED FOLDER ORGANIZATION - Create hierarchical directory structure based on document categories and automatically move files to appropriate locations. Creates category-specific folders with optional PDF/MD subfolders, then relocates documents based on provided category mappings. Supports both flat and nested organization patterns for efficient document management.", inputSchema: zodToJsonSchema(OrganizeStructureArgsSchema) 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