generate_professional_report
Create professional reports in PowerPoint, Word, HTML, or PDF formats using Microsoft 365 data for security analysis, compliance audits, user activity tracking, and device health monitoring.
Instructions
Generate comprehensive professional reports in multiple formats (PowerPoint, Word, HTML, PDF) from Microsoft 365 data.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| reportType | Yes | Type of professional report to generate | |
| title | Yes | Report title | |
| description | No | Report description | |
| dataQueries | No | Data queries to execute and include in report | |
| includeCharts | No | Include visual charts in the report | |
| includeTables | No | Include data tables in the report | |
| includeSummary | No | Include executive summary | |
| outputFormats | Yes | Output formats to generate (can select multiple) | |
| driveId | No | OneDrive/SharePoint drive ID for saving reports | |
| folderId | No | Folder ID within the drive | |
| fileNamePrefix | No | Prefix for generated file names | |
| template | No | Report branding and styling |
Implementation Reference
- Main handler function that orchestrates data collection from Microsoft Graph, generates structured report content based on type, and creates output files in multiple formats (PPTX, DOCX, HTML, PDF) by calling specialized document handlers.export async function handleProfessionalReports( args: ProfessionalReportArgs, graphClient: Client ): Promise<string> { try { // Step 1: Collect data from specified sources const collectedData = await collectReportData(args.dataQueries || [], graphClient); // Step 2: Generate report content based on report type const reportContent = generateReportContent(args, collectedData); // Step 3: Create documents in requested formats const createdFiles = []; for (const format of args.outputFormats) { let result; switch (format) { case 'pptx': result = await createPowerPointReport(args, reportContent, graphClient); createdFiles.push({ format: 'pptx', ...result }); break; case 'docx': result = await createWordReport(args, reportContent, graphClient); createdFiles.push({ format: 'docx', ...result }); break; case 'html': result = await createHTMLReport(args, reportContent, graphClient); createdFiles.push({ format: 'html', ...result }); break; case 'pdf': // PDF is generated by first creating Word and then converting result = await createPDFReport(args, reportContent, graphClient); createdFiles.push({ format: 'pdf', ...result }); break; } } return JSON.stringify({ success: true, reportType: args.reportType, title: args.title, filesCreated: createdFiles.length, files: createdFiles, dataSourcesQueried: args.dataQueries?.length || 0, message: `Professional report "${args.title}" generated successfully in ${createdFiles.length} format(s)` }, null, 2); } catch (error) { if (error instanceof McpError) throw error; throw new McpError( ErrorCode.InternalError, `Professional report generation failed: ${error instanceof Error ? error.message : 'Unknown error'}` ); } }
- src/server.ts:1334-1354 (registration)MCP server tool registration for 'generate_professional_report', linking the schema, metadata annotations, and execution handler.this.server.tool( "generate_professional_report", "Generate comprehensive professional reports in multiple formats (PowerPoint, Word, HTML, PDF) from Microsoft 365 data.", professionalReportArgsSchema.shape, {"readOnlyHint":false,"destructiveHint":false,"idempotentHint":false}, wrapToolHandler(async (args: ProfessionalReportArgs) => { this.validateCredentials(); try { const result = await handleProfessionalReports(args, this.getGraphClient()); return { content: [{ type: 'text', text: result }] }; } catch (error) { if (error instanceof McpError) { throw error; } throw new McpError( ErrorCode.InternalError, `Error generating professional report: ${error instanceof Error ? error.message : 'Unknown error'}` ); } }) );
- Zod input validation schema defining parameters for the professional report tool, including report type, data sources, output formats, and styling options.export const professionalReportArgsSchema = z.object({ reportType: z.enum(['security-analysis', 'compliance-audit', 'user-activity', 'device-health', 'custom']) .describe('Type of professional report to generate'), title: z.string().describe('Report title'), description: z.string().optional().describe('Report description'), dataQueries: z.array(dataQuerySchema).optional() .describe('Data queries to execute and include in report'), includeCharts: z.boolean().optional() .describe('Include visual charts in the report'), includeTables: z.boolean().optional() .describe('Include data tables in the report'), includeSummary: z.boolean().optional() .describe('Include executive summary'), outputFormats: z.array(z.enum(['pptx', 'docx', 'html', 'pdf'])) .describe('Output formats to generate (can select multiple)'), driveId: z.string().optional() .describe('OneDrive/SharePoint drive ID for saving reports'), folderId: z.string().optional() .describe('Folder ID within the drive'), fileNamePrefix: z.string().optional() .describe('Prefix for generated file names'), template: z.object({ theme: z.string().optional(), companyName: z.string().optional(), companyLogo: z.string().optional(), primaryColor: z.string().optional().describe('Primary brand color (hex)'), secondaryColor: z.string().optional().describe('Secondary brand color (hex)') }).optional().describe('Report branding and styling') });
- src/tool-metadata.ts:287-291 (registration)Tool metadata providing description, title, and annotations (readOnlyHint, destructiveHint, etc.) for the generate_professional_report tool.generate_professional_report: { description: "Generate comprehensive professional reports in multiple formats (PowerPoint, Word, HTML, PDF) from Microsoft 365 data.", title: "Professional Report Generator", annotations: { title: "Professional Report Generator", readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true } },
- TypeScript interface defining the structure of ProfessionalReportArgs used by the handler and schema.export interface ProfessionalReportArgs { reportType: 'security-analysis' | 'compliance-audit' | 'user-activity' | 'device-health' | 'custom'; title: string; description?: string; // Data sources dataQueries?: DataQuery[]; includeCharts?: boolean; includeTables?: boolean; includeSummary?: boolean; // Output formats outputFormats: ('pptx' | 'docx' | 'html' | 'pdf')[]; // Storage location driveId?: string; folderId?: string; fileNamePrefix?: string; // Styling template?: { theme?: string; companyName?: string; companyLogo?: string; primaryColor?: string; secondaryColor?: string; }; } export interface DataQuery { source: 'users' | 'devices' | 'groups' | 'audit-logs' | 'alerts' | 'policies' | 'compliance'; endpoint: string; filter?: string; select?: string[]; transform?: 'count' | 'group-by' | 'aggregate' | 'trend'; label: string; }