pptx-to-markdown
Convert PowerPoint presentations to Markdown format for easier editing, sharing, and documentation purposes.
Instructions
Convert a PPTX file to markdown
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filepath | Yes | Absolute path of the PPTX file to convert |
Implementation Reference
- src/tools.ts:126-139 (schema)Tool schema definition including name, description, and input schema for 'pptx-to-markdown'.export const PptxToMarkdownTool = ToolSchema.parse({ name: "pptx-to-markdown", description: "Convert a PPTX file to markdown", inputSchema: { type: "object", properties: { filepath: { type: "string", description: "Absolute path of the PPTX file to convert", }, }, required: ["filepath"], }, });
- src/server.ts:33-37 (registration)Registers the pptx-to-markdown tool (among others exported from tools.ts) for listing via MCP protocol.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: Object.values(tools), }; });
- src/server.ts:72-86 (handler)Handler dispatch for pptx-to-markdown tool call: validates input filepath and invokes Markdownify.toMarkdown for conversion.case tools.PDFToMarkdownTool.name: case tools.ImageToMarkdownTool.name: case tools.AudioToMarkdownTool.name: case tools.DocxToMarkdownTool.name: case tools.XlsxToMarkdownTool.name: case tools.PptxToMarkdownTool.name: if (!validatedArgs.filepath) { throw new Error("File path is required for this tool"); } result = await Markdownify.toMarkdown({ filePath: validatedArgs.filepath, projectRoot: validatedArgs.projectRoot, uvPath: validatedArgs.uvPath || process.env.UV_PATH, }); break;
- src/Markdownify.ts:74-124 (helper)Core helper function that performs the file-to-markdown conversion using external 'markitdown' tool via uv, handles temp files and errors.static async toMarkdown({ filePath, url, projectRoot = path.resolve(__dirname, ".."), uvPath = "~/.local/bin/uv", }: { filePath?: string; url?: string; projectRoot?: string; uvPath?: string; }): Promise<MarkdownResult> { try { let inputPath: string; let isTemporary = false; if (url) { const response = await fetch(url); let extension = null; if (url.endsWith(".pdf")) { extension = "pdf"; } const arrayBuffer = await response.arrayBuffer(); const content = Buffer.from(arrayBuffer); inputPath = await this.saveToTempFile(content, extension); isTemporary = true; } else if (filePath) { inputPath = filePath; } else { throw new Error("Either filePath or url must be provided"); } const text = await this._markitdown(inputPath, projectRoot, uvPath); const outputPath = await this.saveToTempFile(text); if (isTemporary) { fs.unlinkSync(inputPath); } return { path: outputPath, text }; } catch (e: unknown) { if (e instanceof Error) { throw new Error(`Error processing to Markdown: ${e.message}`); } else { throw new Error("Error processing to Markdown: Unknown error occurred"); } } }