Skip to main content
Glama
kingdomseed

Structured Workflow MCP

by kingdomseed

user_input_required_guidance

Requests user input when automated workflows encounter limits, checkpoints, or validation issues to continue structured development processes.

Instructions

Handle escalation to user input when iteration limits reached or checkpoints triggered

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
triggerYesWhat triggered the escalation
contextNoAdditional context about the escalation

Implementation Reference

  • Main handler function for 'user_input_required_guidance' tool. Processes escalation triggers, updates session phase, generates user input report file, provides detailed guidance and blocking messages based on trigger type, and returns PhaseGuidance object.
    export async function handleUserInputRequired(
      params: {
        trigger: 'iteration_limit' | 'user_checkpoint' | 'validation_failure' | 'time_limit';
        context?: any;
      },
      sessionManager: SessionManager
    ): Promise<PhaseGuidance> {
      const session = sessionManager.getSession();
      
      if (!session) {
        throw new Error('No active session. Use build_custom_workflow first.');
      }
    
      // Update to USER_INPUT_REQUIRED phase
      sessionManager.updatePhase('USER_INPUT_REQUIRED');
      
      const config = session.workflowConfig;
      const outputDir = config?.outputPreferences.outputDirectory || 'workflow-output';
      const escalationContext = params.context || {};
    
      // Generate escalation report file
      const userInputFile: OutputFileInstruction = {
        path: `${outputDir}/user-input-needed.md`,
        description: 'User input escalation report with options and context',
        required: true,
        format: 'markdown',
        template: generateUserInputTemplate(params.trigger, escalationContext, session),
        validationRules: [
          'Must explain escalation trigger clearly',
          'Must provide specific user options',
          'Must include current workflow context'
        ]
      };
    
      // Define escalation-specific guidance based on trigger
      let escalationGuidance: PhaseGuidance;
    
      switch (params.trigger) {
        case 'iteration_limit':
          escalationGuidance = {
            phase: 'USER_INPUT_REQUIRED',
            objective: 'โš ๏ธ ITERATION LIMIT REACHED - User guidance needed to proceed',
            
            directiveInstructions: [
              '๐Ÿ›‘ STOP ALL WORKFLOW ACTIVITY: You have reached the configured iteration limit',
              '๐Ÿ“‹ MANDATORY: You MUST create user input escalation report',
              'โณ WAIT: You MUST pause workflow until user provides direction',
              '๐Ÿ“ž ESCALATE: Present clear options for user to choose from'
            ],
    
            instructions: [
              'Document exactly why the iteration limit was reached',
              'Summarize the current state and what has been attempted',
              'Present clear, actionable options for the user',
              'Create comprehensive escalation report',
              'Pause all further workflow activity'
            ],
    
            expectedOutput: {
              escalationReason: `Iteration limit reached for ${escalationContext.failedPhase || 'unknown'} phase`,
              attemptsSummary: `${escalationContext.attemptCount || 'Unknown'} attempts made`,
              currentStatus: 'Summary of what has been accomplished and what failed',
              userOptions: 'Clear options for how to proceed',
              escalationReport: 'User input escalation document created'
            },
    
            requiredOutputFiles: [userInputFile],
    
            blockingMessages: [
              'โ›” WORKFLOW PAUSED: Iteration limit exceeded',
              'โ›” USER INPUT REQUIRED: Cannot proceed without user guidance',
              'โ›” NO FURTHER ACTIONS: All workflow activity must stop until user responds'
            ],
    
            nextPhase: 'Workflow paused - awaiting user input and direction'
          };
          break;
    
        case 'validation_failure':
          escalationGuidance = {
            phase: 'USER_INPUT_REQUIRED',
            objective: 'โš ๏ธ VALIDATION FAILURES - User review needed for quality issues',
            
            directiveInstructions: [
              '๐Ÿ›‘ VALIDATION BLOCKED: Multiple validation attempts have failed',
              '๐Ÿ“‹ MANDATORY: You MUST document specific validation failures',
              '๐Ÿ” REQUIRED: You MUST provide detailed failure analysis',
              '๐Ÿ“ž ESCALATE: Request user review of validation criteria'
            ],
    
            instructions: [
              'Document all validation failures encountered',
              'Analyze patterns in validation issues',
              'Suggest potential solutions or criteria adjustments',
              'Request user review of validation requirements'
            ],
    
            expectedOutput: {
              validationFailures: 'Specific validation issues encountered',
              failurePatterns: 'Common themes in validation problems',
              suggestedSolutions: 'Potential ways to resolve issues',
              criteriaReview: 'Validation criteria that may need adjustment'
            },
    
            requiredOutputFiles: [userInputFile]
          };
          break;
    
        case 'user_checkpoint':
          escalationGuidance = {
            phase: 'USER_INPUT_REQUIRED',
            objective: '๐Ÿ“‹ USER CHECKPOINT - Scheduled user review point',
            
            directiveInstructions: [
              'โธ๏ธ CHECKPOINT REACHED: User review configured for this point',
              '๐Ÿ“Š MANDATORY: You MUST provide comprehensive progress summary',
              '๐ŸŽฏ REQUIRED: You MUST highlight key decisions and changes',
              '๐Ÿ“ž PRESENT: Show user current state and next planned actions'
            ],
    
            instructions: [
              'Summarize progress made since last checkpoint',
              'Highlight significant decisions and changes',
              'Present current state and upcoming plans',
              'Request user confirmation to proceed'
            ],
    
            expectedOutput: {
              progressSummary: 'What has been accomplished since last checkpoint',
              keyDecisions: 'Important decisions made during workflow',
              currentState: 'Current status of refactoring',
              upcomingActions: 'Next planned phases and activities'
            },
    
            requiredOutputFiles: [userInputFile]
          };
          break;
    
        default:
          escalationGuidance = {
            phase: 'USER_INPUT_REQUIRED',
            objective: 'โš ๏ธ ESCALATION TRIGGERED - User input needed',
            
            instructions: [
              'Document the escalation trigger',
              'Provide current workflow context',
              'Request user guidance on how to proceed'
            ],
    
            expectedOutput: {
              escalationContext: 'Why escalation was triggered',
              workflowState: 'Current status of refactoring workflow'
            },
    
            requiredOutputFiles: [userInputFile]
          };
      }
    
      return escalationGuidance;
    }
  • Defines the Tool object for 'user_input_required_guidance' including name, description, and detailed inputSchema for trigger and context parameters.
    export function createUserInputRequiredTool(): Tool {
      return {
        name: 'user_input_required_guidance',
        description: 'Handle escalation to user input when iteration limits reached or checkpoints triggered',
        inputSchema: {
          type: 'object',
          properties: {
            trigger: {
              type: 'string',
              enum: ['iteration_limit', 'user_checkpoint', 'validation_failure', 'time_limit'],
              description: 'What triggered the escalation'
            },
            context: {
              type: 'object',
              description: 'Additional context about the escalation',
              properties: {
                failedPhase: { type: 'string' },
                attemptCount: { type: 'number' },
                lastError: { type: 'string' },
                specificIssues: { type: 'array', items: { type: 'string' } }
              }
            }
          },
          required: ['trigger']
        }
      };
  • src/index.ts:137-157 (registration)
    Registers the tool by calling createUserInputRequiredTool() and including it in the tools array provided to the MCP Server's listTools handler.
    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:193-199 (registration)
    Registers the tool handler dispatch in the main CallToolRequestSchema switch statement, calling handleUserInputRequired with sessionManager.
    case 'user_input_required_guidance':
      return {
        content: [{
          type: 'text',
          text: JSON.stringify(await handleUserInputRequired(args as any, sessionManager), null, 2)
        }]
      };
  • Helper function that generates the Markdown template content for the user-input-needed.md escalation report file.
    function generateUserInputTemplate(
      trigger: string,
      context: any,
      session: any
    ): string {
      const timestamp = new Date().toISOString();
      const failedPhase = context.failedPhase || 'Unknown';
      const attemptCount = context.attemptCount || 0;
      const lastError = context.lastError || 'Not specified';
    
      return `# User Input Required - Workflow Escalation
    
    ## Escalation Details
    - **Timestamp**: ${timestamp}
    - **Trigger**: ${trigger.toUpperCase().replace('_', ' ')}
    - **Session ID**: ${session.id}
    - **Failed Phase**: ${failedPhase}
    - **Attempt Count**: ${attemptCount}
    
    ## Current Situation
    ${generateSituationDescription(trigger, context)}
    
    ## Last Error/Issue
    \`\`\`
    ${lastError}
    \`\`\`
    
    ## User Options
    
    ${generateUserOptions(trigger, context)}
    
    ## Current Workflow Status
    - **Total Phases Completed**: ${session.completedPhases.length}
    - **Current Phase**: ${session.currentPhase}
    - **Time Elapsed**: ${Math.round((Date.now() - session.startedAt) / 1000 / 60)} minutes
    - **Files Modified**: ${session.metrics.filesModified}
    
    ## Workflow Configuration
    - **Selected Phases**: ${session.workflowConfig?.selectedPhases.join(', ') || 'Default'}
    - **Iteration Limits**: TEST=${session.workflowConfig?.iterationLimits.TEST}, LINT=${session.workflowConfig?.iterationLimits.LINT}, ITERATE=${session.workflowConfig?.iterationLimits.ITERATE}
    
    ## Recommendations
    
    ${generateRecommendations(trigger, context)}
    
    ## How to Proceed
    
    1. **Review the situation** described above
    2. **Choose one of the user options** listed
    3. **Modify workflow configuration** if needed
    4. **Resume workflow** with updated guidance
    5. **Or request human intervention** if issues are complex
    
    ---
    
    **โš ๏ธ WORKFLOW PAUSED**: No further automatic actions will be taken until user input is provided.
    
    *Generated by USER_INPUT_REQUIRED phase at ${timestamp}*`;
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. While it mentions the tool handles escalation to user input, it doesn't describe what this escalation entailsโ€”whether it pauses execution, requests input via a UI, logs an error, or something else. It also lacks details on permissions, side effects, or response format, which are critical for a tool that interacts with user input in a workflow context.

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 words. Every part of the sentence earns its place by specifying the action and conditions, making it highly concise and well-structured for quick understanding.

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 of handling user input escalation in a workflow with no annotations and no output schema, the description is incomplete. It doesn't explain what the tool returns, how the user input is integrated back into the workflow, or any error handling. For a tool that likely involves interaction and state changes, this leaves significant gaps in understanding its full context and behavior.

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 the schema already documents both parameters thoroughly. The description doesn't add any meaning beyond what the schema providesโ€”it doesn't explain how 'trigger' or 'context' relate to the escalation process or provide examples. With high schema coverage, the baseline is 3, as the description doesn't compensate with extra insights.

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: 'Handle escalation to user input' when certain conditions occur. It specifies the verb ('handle escalation') and the resource ('user input'), and mentions specific triggers like iteration limits and checkpoints. However, it doesn't explicitly differentiate this tool from its many sibling guidance tools, which would require a 5.

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

Usage Guidelines3/5

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

The description implies when to use this tool ('when iteration limits reached or checkpoints triggered'), providing some context for usage. However, it doesn't offer explicit guidance on when NOT to use it or mention alternatives among the sibling tools, nor does it clarify prerequisites or dependencies. This leaves room for ambiguity in tool selection.

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