Skip to main content
Glama
crazyrabbitLTC

Vibe-Coder MCP Server

get_next_phase_action

Determines the next development phase action for a specified feature in structured LLM-based coding workflows, guiding implementation steps.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
featureIdYes

Implementation Reference

  • The primary handler function for the 'get_next_phase_action' tool. It validates the feature ID, identifies the current active phase, assesses task completion, and returns guidance on the next development action.
    const getNextPhaseActionHandler: ToolHandler<z.infer<typeof GetNextPhaseActionSchema>> = async (params) => {
      try {
        const { featureId } = GetNextPhaseActionSchema.parse(params);
        
        // Validate feature ID
        const featureResult = validateFeatureId(featureId);
        if (!featureResult.valid) {
          return createToolErrorResponse(featureResult.message);
        }
        
        const feature = featureResult.data;
        
        // Find the current active phase (first non-completed/reviewed phase)
        const currentPhase = feature.phases.find((p: Phase) => p.status === 'pending' || p.status === 'in_progress');
        
        if (!currentPhase) {
          // All phases are completed or reviewed
          return {
            content: [{
              type: "text",
              text: 'All phases are completed or reviewed. The feature implementation is done!'
            }]
          };
        }
        
        // Check task completion status
        const completedTasks = currentPhase.tasks.filter((t: Task) => t.completed);
        const pendingTasks = currentPhase.tasks.filter((t: Task) => !t.completed);
        
        // Determine next action based on phase and task status
        let message = '';
        
        if (currentPhase.status === 'pending') {
          message = `Phase "${currentPhase.name}" is pending. Start working on this phase by setting its status to "in_progress".`;
        } else if (currentPhase.status === 'in_progress') {
          if (pendingTasks.length > 0) {
            message = `${completedTasks.length}/${currentPhase.tasks.length} tasks are completed in phase "${currentPhase.name}". Continue working on pending tasks.`;
          } else if (currentPhase.tasks.length === 0) {
            message = `Phase "${currentPhase.name}" has no tasks defined. Add tasks or mark the phase as completed if appropriate.`;
          } else {
            // All tasks are completed
            message = `All tasks in phase "${currentPhase.name}" are completed. Consider marking this phase as completed.`;
          }
        }
        
        return {
          content: [{
            type: "text",
            text: message
          }]
        };
      } catch (error) {
        if (error instanceof z.ZodError) {
          const errorMessage = error.errors.map(e => `${e.path.join('.')}: ${e.message}`).join(', ');
          return createToolErrorResponse(`Validation error: ${errorMessage}`);
        }
        return createToolErrorResponse(error instanceof Error ? error.message : "Unknown error");
      }
    };
  • Zod schema defining the input parameters for the tool: requires a featureId string.
    // Schema for get_next_phase_action
    const GetNextPhaseActionSchema = z.object({
      featureId: z.string().min(1)
    });
  • Registers the 'get_next_phase_action' tool with the toolRegistry, including the handler, description, input schema, and example.
    toolRegistry.register(
      'get_next_phase_action', 
      getNextPhaseActionHandler,
      'Get guidance on what to do next in the current phase or whether to move to the next phase',
      {
        type: 'object',
        properties: {
          featureId: {
            type: 'string',
            description: 'ID of the feature'
          }
        },
        required: ['featureId']
      },
      [
        { featureId: "feature-123" }
      ]
    );
  • Alternative inline handler for 'get_next_phase_action' tool directly registered with the MCP server, with slightly different logic including checks for implementation plan.
    server.tool(
      "get_next_phase_action",
      {
        featureId: z.string().min(1)
      },
      async ({ featureId }) => {
        const feature = getFeature(featureId);
        if (!feature) {
          throw new Error(`Feature ${featureId} not found`);
        }
        
        // Check if we need implementation plan first
        if (!feature.implementationPlan) {
          return {
            content: [{
              type: "text",
              text: "You should generate an implementation plan before creating phases."
            }]
          };
        }
        
        // If no phases, suggest creating first phase
        if (feature.phases.length === 0) {
          return {
            content: [{
              type: "text",
              text: "You should create the first development phase based on the implementation plan."
            }]
          };
        }
        
        // Find the current active phase (the first non-completed phase)
        const currentPhase = feature.phases.find(p => p.status !== 'completed' && p.status !== 'reviewed');
        
        if (!currentPhase) {
          return {
            content: [{
              type: "text",
              text: "All phases are complete. You should mark the final phase as reviewed."
            }]
          };
        }
        
        // Check if all tasks in the phase are completed
        const allTasksCompleted = currentPhase.tasks.every(t => t.completed);
        
        if (currentPhase.tasks.length === 0) {
          return {
            content: [{
              type: "text",
              text: `Current phase "${currentPhase.name}" has no tasks. You should add tasks based on the implementation plan.`
            }]
          };
        } else if (!allTasksCompleted) {
          const pendingTasks = currentPhase.tasks.filter(t => !t.completed);
          
          return {
            content: [{
              type: "text",
              text: `Current phase "${currentPhase.name}" has ${pendingTasks.length} incomplete tasks. Complete these tasks before moving to the next phase.`
            }]
          };
        } else {
          return {
            content: [{
              type: "text",
              text: `All tasks in the current phase "${currentPhase.name}" are complete. You can now mark this phase as completed and proceed to the next phase.`
            }]
          };
        }
      }
    );
  • Calls the registerToolHandlers function which registers all tools including get_next_phase_action in the registry-based server implementation.
    registerToolHandlers();

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/crazyrabbitLTC/mcp-vibecoder'

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