Skip to main content
Glama

Risk Assessment

Assess project risks using pattern detection and predictive analytics to identify potential issues and enable proactive mitigation strategies.

Instructions

Comprehensive project risk assessment with pattern detection and predictive analytics

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectIdYesProject ID to assess (e.g., "project-1", "alpha")

Implementation Reference

  • Registration of the 'Risk Assessment' tool in the mcpTools array, imported from './risk_assessment' and exported for use by the MCP server.
    import { riskAssessmentTool } from './risk_assessment';
    
    // EXPANSION: Consolidated tool registry for MCP server
    export const mcpTools = [naturalLanguageQueryTool, workloadAnalysisTool, riskAssessmentTool];
  • Zod input schema defining the required 'projectId' parameter for the tool.
    parameters: z.object({
      projectId: z
        .string()
        .min(1, 'Project ID is required')
        .max(50, 'Project ID too long')
        .describe('Project ID to assess (e.g., "project-1", "alpha-initiative")'),
  • The MCP tool handler function that instantiates RiskAssessmentProcessor, calls assessProjectRisk, formats the response as MCP content, and handles errors.
    handler: async ({ projectId }: { projectId: string }) => {
      try {
        const processor = new RiskAssessmentProcessor(process.env.MCP_DEBUG_MODE === 'true');
        const assessment = await processor.assessProjectRisk(projectId);
    
        // SAFETY: Ensure assessment is valid
        if (!assessment) {
          throw new Error('Risk assessment returned null or undefined');
        }
    
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(
                {
                  project_id: assessment.projectId || projectId,
                  project_name: assessment.projectName || projectId,
                  summary: `${assessment.projectName || projectId}: ${assessment.riskLevel || 'UNKNOWN'} risk (${assessment.riskScore || 0}/100)`,
                  risk_level: assessment.riskLevel || 'MEDIUM',
                  risk_score: assessment.riskScore || 0,
                  progress: assessment.progress || 0,
                  overdue_tasks: assessment.overdueTasks || 0,
                  blocked_tasks: assessment.blockedTasks || 0,
                  risk_breakdown: assessment.riskBreakdown || {
                    schedule: 0,
                    resource: 0,
                    scope: 0,
                    quality: 0,
                    dependencies: 0,
                  },
                  patterns_detected: (assessment.patterns || []).length,
                  trend: assessment.trend || {
                    direction: 'STABLE',
                    velocity: 0,
                    forecastedRisk: 0,
                    trendFactors: [],
                  },
                  early_warnings: assessment.earlyWarnings || [],
                  insights: assessment.insights || [],
                  recommendations: assessment.recommendations || [],
                  mitigation_strategies: assessment.mitigationStrategies || [],
                  monitoring_recommendations: assessment.monitoringRecommendations || [],
                  requires_attention:
                    (assessment.riskScore || 0) > 70 || (assessment.earlyWarnings || []).length > 0,
                },
                null,
                2,
              ),
            },
          ],
        };
      } catch (error) {
        console.error(`[RiskAssessment] Handler failed:`, error);
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(
                {
                  project_id: projectId,
                  project_name: projectId,
                  success: false,
                  error: (error as Error).message,
                  summary: `Failed to assess risk for ${projectId}`,
                  insights: ['Risk assessment unavailable'],
                  recommendations: ['Check system connectivity and project ID validity'],
                },
                null,
                2,
              ),
            },
          ],
        };
      }
  • Core helper method in RiskAssessmentProcessor class that performs the comprehensive risk assessment logic including caching, API calls, pattern detection, trend analysis, and enhancement.
    async assessProjectRisk(projectId: string): Promise<EnhancedRiskAssessment> {
      const startTime = Date.now();
    
      try {
        this.debug(`Assessing risk for project: ${projectId}`);
    
        // CACHE: Check for recent assessment
        const cacheKey = `risk:assessment:${projectId}`;
        let cachedAssessment = await CacheService.get<EnhancedRiskAssessment>(cacheKey);
    
        if (cachedAssessment) {
          this.debug(`Retrieved cached risk assessment for ${projectId}`);
          return cachedAssessment;
        }
    
        // Stage 1: Get base risk assessment
        const baseAssessment = await this.apiClient.getRiskAssessment(projectId);
    
        // Stage 2: Enhance with pattern detection
        const enhancedAssessment = await this.enhanceRiskAssessment(baseAssessment);
    
        // Stage 3: Add trend analysis
        enhancedAssessment.trend = await this.analyzeTrend(enhancedAssessment);
    
        // Stage 4: Detect risk patterns
        enhancedAssessment.patterns = await this.detectRiskPatterns(enhancedAssessment);
    
        // Stage 5: Generate early warnings
        enhancedAssessment.earlyWarnings = this.generateEarlyWarnings(enhancedAssessment);
    
        // Stage 6: Add comparative analysis
        enhancedAssessment.comparison = await this.generateProjectComparison(enhancedAssessment);
    
        // CACHE: Store enhanced assessment
        await CacheService.set(cacheKey, enhancedAssessment, this.RISK_CACHE_TTL);
    
        const processingTime = Date.now() - startTime;
        this.debug(`Risk assessment completed for ${projectId} in ${processingTime}ms`);
    
        return enhancedAssessment;
      } catch (error) {
        this.debug(`Risk assessment failed for ${projectId}: ${error}`);
        throw error;
      }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions 'comprehensive' assessment with 'pattern detection and predictive analytics', which hints at analysis capabilities, but doesn't disclose critical behavioral traits like whether this is a read-only operation, if it requires specific permissions, what the output format might be, or any rate limits. The description is too vague about actual behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that gets straight to the point without unnecessary words. It's appropriately sized for a tool with one parameter, though it could be slightly more structured by separating core function from additional features.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity implied by 'comprehensive risk assessment' with analytics, no annotations, and no output schema, the description is incomplete. It doesn't explain what 'comprehensive' entails, what kind of risks are assessed, how results are returned, or any dependencies. For a tool that likely produces detailed analysis, this leaves significant gaps for an AI agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, with the single parameter 'projectId' well-documented in the schema. The description doesn't add any meaningful parameter semantics beyond what the schema already provides (e.g., it doesn't explain how the projectId influences the risk assessment or what formats are expected). Baseline 3 is appropriate when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool performs 'comprehensive project risk assessment' with 'pattern detection and predictive analytics', specifying both the verb (assessment) and resource (project risk). However, it doesn't explicitly distinguish this from sibling tools like 'Natural Language Query' or 'Workload Analysis', which might also involve analysis functions.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus the sibling tools. It doesn't mention any prerequisites, alternatives, or specific contexts where this tool is preferred over others like 'Workload Analysis' for risk-related tasks.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/jatinderbhola/mcp-taskflow-tracker-api'

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