analyze_deployments
Analyze deployment patterns and generate insights from historical deployment data to identify trends, compare SSG performance, and assess deployment health.
Instructions
Analyze deployment patterns and generate insights from historical deployment data
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| analysisType | No | Type of analysis: full_report (comprehensive), ssg_stats (per-SSG), compare (compare SSGs), health (deployment health score), trends (temporal analysis) | full_report |
| ssg | No | SSG name for ssg_stats analysis | |
| ssgs | No | Array of SSG names for comparison | |
| periodDays | No | Period in days for trend analysis |
Implementation Reference
- src/tools/analyze-deployments.ts:29-139 (handler)Main execution logic for the analyze_deployments tool. Parses input schema, calls DeploymentAnalytics methods based on analysisType (full_report, ssg_stats, compare, health, trends), handles errors, and returns formatted MCP response with metadata and recommendations.export async function analyzeDeployments( args: unknown, ): Promise<{ content: any[] }> { const startTime = Date.now(); try { const { analysisType, ssg, ssgs, periodDays } = inputSchema.parse(args); const analytics = getDeploymentAnalytics(); let result: any; let actionDescription: string; switch (analysisType) { case "full_report": result = await analytics.generateReport(); actionDescription = "Generated comprehensive deployment analytics report"; break; case "ssg_stats": if (!ssg) { throw new Error("SSG name required for ssg_stats analysis"); } result = await analytics.getSSGStatistics(ssg); if (!result) { throw new Error(`No deployment data found for SSG: ${ssg}`); } actionDescription = `Retrieved statistics for ${ssg}`; break; case "compare": if (!ssgs || ssgs.length < 2) { throw new Error( "At least 2 SSG names required for comparison analysis", ); } result = await analytics.compareSSGs(ssgs); actionDescription = `Compared ${ssgs.length} SSGs`; break; case "health": result = await analytics.getHealthScore(); actionDescription = "Calculated deployment health score"; break; case "trends": result = await analytics.identifyTrends(periodDays); actionDescription = `Identified deployment trends over ${periodDays} days`; break; default: throw new Error(`Unknown analysis type: ${analysisType}`); } const response: MCPToolResponse<any> = { success: true, data: result, metadata: { toolVersion: "1.0.0", executionTime: Date.now() - startTime, timestamp: new Date().toISOString(), }, recommendations: [ { type: "info", title: actionDescription, description: `Analysis completed successfully`, }, ], }; // Add context-specific recommendations if (analysisType === "full_report" && result.recommendations) { response.recommendations?.push( ...result.recommendations.slice(0, 3).map((rec: string) => ({ type: "info" as const, title: "Recommendation", description: rec, })), ); } if (analysisType === "health") { const healthStatus = result.score > 70 ? "good" : result.score > 40 ? "warning" : "critical"; response.recommendations?.push({ type: healthStatus === "good" ? "info" : "warning", title: `Health Score: ${result.score}/100`, description: `Deployment health is ${healthStatus}`, }); } return formatMCPResponse(response); } catch (error) { const errorResponse: MCPToolResponse = { success: false, error: { code: "ANALYTICS_FAILED", message: `Failed to analyze deployments: ${error}`, resolution: "Ensure deployment data exists in the knowledge graph and parameters are valid", }, metadata: { toolVersion: "1.0.0", executionTime: Date.now() - startTime, timestamp: new Date().toISOString(), }, }; return formatMCPResponse(errorResponse); } }
- Zod schema for input validation defining analysisType (default full_report), optional ssg, ssgs array, and periodDays (default 30).const inputSchema = z.object({ analysisType: z .enum(["full_report", "ssg_stats", "compare", "health", "trends"]) .optional() .default("full_report"), ssg: z.string().optional().describe("SSG name for ssg_stats analysis"), ssgs: z .array(z.string()) .optional() .describe("Array of SSG names for comparison"), periodDays: z .number() .optional() .default(30) .describe("Period in days for trend analysis"), });
- Core helper module providing DeploymentAnalytics singleton with methods for generating reports, SSG statistics, comparisons, health scores, and trends from knowledge graph deployment data. Used by the handler for all analysis types.export function getDeploymentAnalytics(): DeploymentAnalytics { if (!analyticsInstance) { analyticsInstance = new DeploymentAnalytics(); } return analyticsInstance; }