generate_powerpoint_presentation
Create professional PowerPoint presentations with custom slides, charts, tables, and themes using Microsoft 365 data.
Instructions
Create professional PowerPoint presentations with custom slides, charts, tables, and themes from Microsoft 365 data.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| action | Yes | Action to perform: create new presentation, get existing, list all, or export to format | |
| fileName | No | Name for the new presentation file (for create action) | |
| driveId | No | OneDrive/SharePoint drive ID where file should be created (default: user's OneDrive) | |
| folderId | No | Folder ID within the drive (default: root) | |
| template | No | Template configuration for presentation styling | |
| slides | No | Array of slide definitions to create | |
| fileId | No | File ID for get/export actions | |
| format | No | Export format (for export action) | |
| filter | No | OData filter for list action | |
| top | No | Number of results to return (for list action) |
Implementation Reference
- src/server.ts:1266-1285 (registration)Registers the 'generate_powerpoint_presentation' tool with the MCP server, specifying description, input schema, annotations, and handler function."generate_powerpoint_presentation", "Create professional PowerPoint presentations with custom slides, charts, tables, and themes from Microsoft 365 data.", powerPointPresentationArgsSchema.shape, {"readOnlyHint":false,"destructiveHint":false,"idempotentHint":false}, wrapToolHandler(async (args: PowerPointPresentationArgs) => { this.validateCredentials(); try { const result = await handlePowerPointPresentations(args, this.getGraphClient()); return { content: [{ type: 'text', text: result }] }; } catch (error) { if (error instanceof McpError) { throw error; } throw new McpError( ErrorCode.InternalError, `Error generating PowerPoint presentation: ${error instanceof Error ? error.message : 'Unknown error'}` ); } }) );
- src/handlers/powerpoint-handler.ts:18-45 (handler)Primary handler function that dispatches to specific PowerPoint operations (create, get, list, export) based on input args.action.export async function handlePowerPointPresentations( args: PowerPointPresentationArgs, graphClient: Client ): Promise<string> { try { switch (args.action) { case 'create': return await createPresentation(args, graphClient); case 'get': return await getPresentation(args, graphClient); case 'list': return await listPresentations(args, graphClient); case 'export': return await exportPresentation(args, graphClient); default: throw new McpError( ErrorCode.InvalidRequest, `Unknown action: ${args.action}` ); } } catch (error) { if (error instanceof McpError) throw error; throw new McpError( ErrorCode.InternalError, `PowerPoint operation failed: ${error instanceof Error ? error.message : 'Unknown error'}` ); } }
- Core implementation for creating a new PowerPoint presentation: generates XML content, uploads to OneDrive/SharePoint via Graph API, returns file details.async function createPresentation( args: PowerPointPresentationArgs, graphClient: Client ): Promise<string> { if (!args.fileName) { throw new McpError(ErrorCode.InvalidRequest, 'fileName is required for create action'); } if (!args.slides || args.slides.length === 0) { throw new McpError(ErrorCode.InvalidRequest, 'At least one slide is required'); } // Determine drive location (default to user's OneDrive) const driveId = args.driveId || 'me'; const folderPath = args.folderId ? `/items/${args.folderId}` : '/root'; // Create empty PowerPoint file const fileName = args.fileName.endsWith('.pptx') ? args.fileName : `${args.fileName}.pptx`; // Create file with content const presentationContent = generatePresentationXML(args.slides, args.template); const uploadedFile = await graphClient .api(`/drives/${driveId}${folderPath}:/${fileName}:/content`) .header('Content-Type', 'application/vnd.openxmlformats-officedocument.presentationml.presentation') .put(presentationContent); return JSON.stringify({ success: true, fileId: uploadedFile.id, fileName: uploadedFile.name, webUrl: uploadedFile.webUrl, driveId: uploadedFile.parentReference?.driveId, message: `PowerPoint presentation "${fileName}" created successfully with ${args.slides.length} slides` }, null, 2); }
- Zod schema defining input parameters and validation for the generate_powerpoint_presentation tool, including action types, file locations, slide content, and export options.export const powerPointPresentationArgsSchema = z.object({ action: z.enum(['create', 'get', 'list', 'export']) .describe('Action to perform: create new presentation, get existing, list all, or export to format'), fileName: z.string().optional() .describe('Name for the new presentation file (for create action)'), driveId: z.string().optional() .describe('OneDrive/SharePoint drive ID where file should be created (default: user\'s OneDrive)'), folderId: z.string().optional() .describe('Folder ID within the drive (default: root)'), template: powerPointTemplateSchema.optional() .describe('Template configuration for presentation styling'), slides: z.array(powerPointSlideSchema).optional() .describe('Array of slide definitions to create'), fileId: z.string().optional() .describe('File ID for get/export actions'), format: z.enum(['pptx', 'pdf', 'odp']).optional() .describe('Export format (for export action)'), filter: z.string().optional() .describe('OData filter for list action'), top: z.number().optional() .describe('Number of results to return (for list action)') });
- src/tool-metadata.ts:272-276 (registration)Metadata definition for the generate_powerpoint_presentation tool, providing description, title, and operational annotations used in tool registration and discovery.generate_powerpoint_presentation: { description: "Create professional PowerPoint presentations with custom slides, charts, tables, and themes from Microsoft 365 data.", title: "PowerPoint Generator", annotations: { title: "PowerPoint Generator", readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true } },