Skip to main content
Glama

plan_conversion

Generate optimal conversion plans for document format changes, ensuring proper workflow and handling complex multi-step transformations between PDF, DOCX, HTML, and Markdown formats.

Instructions

๐ŸŽฏ MANDATORY FIRST STEP - Smart Document Conversion Planner - โš ๏ธ CRITICAL: This tool MUST be executed BEFORE any document conversion operation! When users request any format conversion (e.g., 'convert MD to PDF', 'DOCX to HTML'), you MUST call this tool first to get the optimal conversion plan, then follow the plan's steps exactly. This ensures proper conversion workflow and handles complex multi-step conversions. For PDF conversions, note that playwright-mcp integration is required for final PDF generation, followed by process_pdf_post_conversion for watermarks/QR codes. Supports all format conversion path planning.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sourceFormatYesSource file format (e.g.: pdf, docx, html, markdown, md, txt)
targetFormatYesTarget file format (e.g.: pdf, docx, html, markdown, md, txt)
sourceFileNoSource file path (optional, used to generate specific conversion parameters)
preserveStylesNoWhether to preserve style formatting
includeImagesNoWhether to include images
themeNoConversion theme (applicable to HTML/DOCX output)github
qualityNoConversion quality requirementsbalanced

Implementation Reference

  • Input schema (ConversionRequest) and output schema (ConversionPlan) with supporting types for the plan_conversion tool.
    interface ConversionRequest { sourceFormat: string; targetFormat: string; sourceFile?: string; requirements?: { preserveStyles?: boolean; includeImages?: boolean; theme?: string; quality?: 'fast' | 'balanced' | 'high'; }; } interface ConversionStep { stepNumber: number; toolName: string; description: string; inputFormat: string; outputFormat: string; parameters: Record<string, any>; estimatedTime: string; notes?: string; } interface ConversionPlan { success: boolean; sourceFormat: string; targetFormat: string; conversionPath: string[]; steps: ConversionStep[]; totalSteps: number; estimatedTotalTime: string; recommendations: string[]; warnings?: string[]; error?: string; }
  • The handler function that executes the plan_conversion tool logic, planning document format conversion paths using heuristics and predefined mappings.
    async planConversion(request: ConversionRequest): Promise<ConversionPlan> { try { const sourceFormat = this.normalizeFormat(request.sourceFormat); const targetFormat = this.normalizeFormat(request.targetFormat); // ้ชŒ่ฏๆ ผๅผๆ”ฏๆŒ if (!this.isFormatSupported(sourceFormat)) { return { success: false, sourceFormat, targetFormat, conversionPath: [], steps: [], totalSteps: 0, estimatedTotalTime: '0ๅˆ†้’Ÿ', recommendations: [], error: `ไธๆ”ฏๆŒ็š„ๆบๆ ผๅผ: ${sourceFormat}`, }; } if (!this.isFormatSupported(targetFormat)) { return { success: false, sourceFormat, targetFormat, conversionPath: [], steps: [], totalSteps: 0, estimatedTotalTime: '0ๅˆ†้’Ÿ', recommendations: [], error: `ไธๆ”ฏๆŒ็š„็›ฎๆ ‡ๆ ผๅผ: ${targetFormat}`, }; } // ็›ธๅŒๆ ผๅผ if (sourceFormat === targetFormat) { return { success: true, sourceFormat, targetFormat, conversionPath: [sourceFormat], steps: [ { stepNumber: 1, toolName: 'read_document', description: 'ๆ–‡ไปถๅทฒ็ปๆ˜ฏ็›ฎๆ ‡ๆ ผๅผ๏ผŒๆ— ้œ€่ฝฌๆข', inputFormat: sourceFormat, outputFormat: targetFormat, parameters: {}, estimatedTime: 'ๅณๆ—ถ', }, ], totalSteps: 1, estimatedTotalTime: 'ๅณๆ—ถ', recommendations: ['ๆ–‡ไปถๆ ผๅผๅทฒๅŒน้…๏ผŒๆ— ้œ€่ฝฌๆข'], }; } // ๆŸฅๆ‰พ่ฝฌๆข่ทฏๅพ„ const conversionPath = this.findConversionPath(sourceFormat, targetFormat); if (!conversionPath || conversionPath.length === 0) { return { success: false, sourceFormat, targetFormat, conversionPath: [], steps: [], totalSteps: 0, estimatedTotalTime: '0ๅˆ†้’Ÿ', recommendations: [], error: `ๆ— ๆณ•ๆ‰พๅˆฐไปŽ ${sourceFormat} ๅˆฐ ${targetFormat} ็š„่ฝฌๆข่ทฏๅพ„`, }; } // ็”Ÿๆˆ่ฝฌๆขๆญฅ้ชค const steps = this.generateConversionSteps(conversionPath, request); const totalTime = this.calculateTotalTime(steps); const recommendations = this.generateRecommendations(sourceFormat, targetFormat, request); const warnings = this.generateWarnings(sourceFormat, targetFormat, conversionPath); return { success: true, sourceFormat, targetFormat, conversionPath, steps, totalSteps: steps.length, estimatedTotalTime: totalTime, recommendations, warnings, }; } catch (error: any) { return { success: false, sourceFormat: request.sourceFormat, targetFormat: request.targetFormat, conversionPath: [], steps: [], totalSteps: 0, estimatedTotalTime: '0ๅˆ†้’Ÿ', recommendations: [], error: `่ง„ๅˆ’่ฝฌๆข่ทฏๅพ„ๆ—ถๅ‡บ้”™: ${error.message}`, }; } }

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/Tele-AI/doc-ops-mcp'

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