Skip to main content
Glama
kingdomseed

Structured Workflow MCP

by kingdomseed

validate_phase_completion

Check if a workflow phase meets all completion requirements before allowing progression to the next stage.

Instructions

Validate that current phase meets all completion requirements before allowing progression

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
phaseYesThe phase to validate
completedWorkYesDescription of work completed in this phase
createdFilesNoList of files created during this phase

Implementation Reference

  • The core handler function that implements the validate_phase_completion tool. It validates phase completion by checking criteria, updating session validation state, handling escalations, and returning detailed results including whether the phase can proceed.
    export async function handleValidatePhaseCompletion(
      params: {
        phase: Phase;
        completedWork: any;
        createdFiles?: string[];
      },
      sessionManager: SessionManager
    ) {
      const session = sessionManager.getSession();
      
      if (!session) {
        return {
          isValid: false,
          error: 'No active session. Use build_custom_workflow first.',
          blockers: ['No active workflow session']
        };
      }
    
      // Get current validation state for this phase
      let validationState = sessionManager.getValidationState(params.phase);
      if (!validationState) {
        validationState = {
          isComplete: false,
          completedRequirements: [],
          failedRequirements: [],
          lastValidatedAt: Date.now(),
          attempts: 0
        };
      }
    
      // Increment validation attempts
      validationState.attempts++;
      validationState.lastValidatedAt = Date.now();
    
      // Get phase-specific validation criteria
      const criteria = getValidationCriteriaForPhase(params.phase, session.workflowConfig?.outputPreferences.outputDirectory || 'workflow-output');
      
      // Perform validation checks
      const validationResults = performPhaseValidation(params.phase, params.completedWork, params.createdFiles || [], criteria);
    
      // Update validation state
      validationState.completedRequirements = validationResults.passed;
      validationState.failedRequirements = validationResults.failed;
      validationState.isComplete = validationResults.isComplete;
    
      // Store updated validation state
      sessionManager.setValidationState(params.phase, validationState);
    
      // Check for escalation conditions
      const escalationContext = sessionManager.shouldEscalateToUserInput(params.phase);
      
      if (escalationContext) {
        return {
          isValid: false,
          escalationRequired: true,
          escalationContext,
          message: '⚠️ ESCALATION REQUIRED: Validation issues require user input',
          validationAttempts: validationState.attempts,
          failedRequirements: validationResults.failed,
          recommendation: 'Use user_input_required_guidance to escalate to user'
        };
      }
    
      if (!validationResults.isComplete) {
        return {
          isValid: false,
          message: '⛔ VALIDATION FAILED: Phase completion requirements not met',
          validationAttempts: validationState.attempts,
          passedRequirements: validationResults.passed,
          failedRequirements: validationResults.failed,
          blockingMessages: validationResults.blockingMessages,
          nextSteps: validationResults.nextSteps,
          selfCheckQuestions: criteria.selfCheckQuestions
        };
      }
    
      return {
        isValid: true,
        message: '✅ VALIDATION PASSED: Phase completion requirements met',
        validationAttempts: validationState.attempts,
        completedRequirements: validationResults.passed,
        nextPhase: getNextPhaseRecommendation(params.phase, session),
        canProceed: true
      };
    }
  • The input schema definition for the validate_phase_completion tool, specifying parameters like phase, completedWork, and optional createdFiles.
    {
      name: 'validate_phase_completion',
      description: 'Validate that current phase meets all completion requirements before allowing progression',
      inputSchema: {
        type: 'object',
        properties: {
          phase: {
            type: 'string',
            enum: ['SETUP', 'AUDIT_INVENTORY', 'COMPARE_ANALYZE', 'QUESTION_DETERMINE', 'WRITE_OR_REFACTOR', 'TEST', 'LINT', 'ITERATE', 'PRESENT'],
            description: 'The phase to validate'
          },
          completedWork: {
            type: 'object',
            description: 'Description of work completed in this phase',
            additionalProperties: true
          },
          createdFiles: {
            type: 'array',
            items: { type: 'string' },
            description: 'List of files created during this phase'
          }
        },
        required: ['phase', 'completedWork']
      }
    }
  • src/index.ts:137-157 (registration)
    Registration of the tool in the MCP server by including the result of createValidationTools() (which provides the validate_phase_completion schema) in the tools array used for list_tools requests.
    const tools = [
      // Workflow entry points
      createRefactorWorkflowTool(),                 // Refactoring workflow
      createFeatureWorkflowTool(),                  // Feature creation workflow
      createTestWorkflowTool(),                     // Test writing workflow
      createTddWorkflowTool(),                      // TDD workflow
      createBuildCustomWorkflowTool(),              // Custom workflow builder
      
      // Phase guidance tools
      ...createPhaseGuidanceTools(),                // Handles both suggestive and directive modes
      createTestGuidanceTool(),                     // TEST phase guidance
      
      // Validation tools
      ...createValidationTools(),                   // Both validate_action and validate_phase_completion
      
      // Workflow management
      createUserInputRequiredTool(),                // Escalation handling
      createWorkflowStatusTool(),                   // Workflow status
      createPhaseOutputTool(),                      // Phase output recording
      createDiscoverWorkflowToolsTool()             // Tool discovery
    ];
  • src/index.ts:201-207 (registration)
    Dispatch handler in the MCP call_tool request that routes validate_phase_completion calls to the handleValidatePhaseCompletion function.
    case 'validate_phase_completion':
      return {
        content: [{
          type: 'text',
          text: JSON.stringify(await handleValidatePhaseCompletion(args as any, sessionManager), null, 2)
        }]
      };
  • Key helper function that performs the actual validation logic by checking minimum requirements and expected files against the provided completedWork and createdFiles.
    function performPhaseValidation(
      _phase: Phase, 
      completedWork: any, 
      createdFiles: string[], 
      criteria: ValidationCriteria
    ): {
      isComplete: boolean;
      passed: string[];
      failed: string[];
      blockingMessages: string[];
      nextSteps: string[];
    } {
      const passed: string[] = [];
      const failed: string[] = [];
      const blockingMessages: string[] = [];
      const nextSteps: string[] = [];
    
      // Check minimum requirements
      Object.entries(criteria.minimumRequirements).forEach(([requirement, expectedValue]) => {
        const actualValue = completedWork[requirement];
        
        if (typeof expectedValue === 'number') {
          if (actualValue >= expectedValue) {
            passed.push(`${requirement}: ${actualValue} (meets minimum ${expectedValue})`);
          } else {
            failed.push(`${requirement}: ${actualValue || 0} (need minimum ${expectedValue})`);
            blockingMessages.push(`⛔ ${requirement} insufficient: need ${expectedValue}, have ${actualValue || 0}`);
          }
        } else if (typeof expectedValue === 'boolean') {
          if (!!actualValue === expectedValue) {
            passed.push(`${requirement}: completed`);
          } else {
            failed.push(`${requirement}: not completed`);
            blockingMessages.push(`⛔ ${requirement} not completed`);
          }
        }
      });
    
      // Check expected files
      criteria.expectedFiles.forEach(expectedFile => {
        if (createdFiles.includes(expectedFile)) {
          passed.push(`File created: ${expectedFile}`);
        } else {
          failed.push(`Missing file: ${expectedFile}`);
          blockingMessages.push(`⛔ Required file not created: ${expectedFile}`);
          nextSteps.push(`Create file: ${expectedFile}`);
        }
      });
    
      // Add criteria-specific blocking messages if validation failed
      if (failed.length > 0) {
        blockingMessages.push(...criteria.blockingMessages);
        nextSteps.push('Review self-check questions');
        nextSteps.push('Complete failed requirements');
        nextSteps.push('Re-run validation');
      }
    
      return {
        isComplete: failed.length === 0,
        passed,
        failed,
        blockingMessages: [...new Set(blockingMessages)], // Remove duplicates
        nextSteps: [...new Set(nextSteps)] // Remove duplicates
      };
    }
Behavior2/5

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

With no annotations provided, the description carries full burden but offers limited behavioral insight. It mentions validation and progression blocking, but doesn't disclose critical details like what validation criteria are used, whether it's read-only or has side effects, what happens on failure (e.g., error messages), or if it requires specific permissions. For a validation tool with zero annotation coverage, this is inadequate.

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

Conciseness5/5

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

The description is a single, efficient sentence that front-loads the core purpose without unnecessary elaboration. Every word earns its place, making it easy to parse quickly.

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 tool's complexity (validation logic with 3 parameters including nested objects), lack of annotations, and no output schema, the description is insufficient. It doesn't explain what validation entails, what the output might be (e.g., pass/fail, error details), or how it integrates with the broader workflow system, leaving 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?

Schema description coverage is 100%, so parameters are well-documented in the schema itself. The description adds no additional parameter semantics beyond implying that 'phase' and 'completedWork' are used for validation checks. It doesn't explain how these inputs relate to completion requirements or what 'completedWork' should contain.

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's purpose: 'Validate that current phase meets all completion requirements before allowing progression.' It specifies the action (validate) and the resource (current phase completion requirements), but doesn't explicitly distinguish it from sibling tools like 'validate_action' or 'workflow_status' which might have overlapping functionality.

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 minimal guidance: it implies usage when checking if a phase can progress, but offers no explicit when/when-not instructions or alternatives. It doesn't mention prerequisites, how it differs from sibling validation tools, or what happens if validation fails.

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/kingdomseed/structured-workflow-mcp'

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