Skip to main content
Glama

Planner

planner

Create multi-step plans with revisions and branches to solve complex tasks, adjusting scope and requirements as needed.

Instructions

Multi-step planning with revisions and branches

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
taskYesThe task or problem to plan. For the first step, describe the complete planning challenge in detail. For subsequent steps, provide the specific planning step content, revisions, or branch explorations.
stepNumberYesCurrent step number in the planning sequence (starts at 1)
totalStepsYesCurrent estimate of total steps needed (can be adjusted as planning progresses)
scopeNoPlanning scope and depthstandard
requirementsNoSpecific requirements, constraints, or success criteria
isRevisionNoTrue if this step revises a previous step
revisingStepNoIf isRevision is true, which step number is being revised
isBranchingNoTrue if exploring an alternative approach from a previous step
branchingFromNoIf isBranching is true, which step number to branch from
branchIdNoIdentifier for this planning branch (e.g., 'approach-A', 'microservices-path')
providerNoAI provider to use for planning assistancegemini

Implementation Reference

  • Core handler function that executes the planner tool logic. Uses AI providers to generate step-by-step planning responses with support for revisions, branching, and deep thinking phases.
      async handlePlanner(params: z.infer<typeof PlannerSchema>) {
        const providerName = params.provider || (await this.providerManager.getPreferredProvider(['openai', 'gemini', 'azure']));
        const provider = await this.providerManager.getProvider(providerName);
        
        // Track planning state for step-by-step guidance
        const isFirstStep = params.stepNumber === 1;
        const isComplexPlan = params.totalSteps >= 5;
        const needsDeepThinking = isComplexPlan && params.stepNumber <= 3;
        
        // Build planning-specific system prompt based on step and complexity
        let systemPrompt = `You are an expert planner and strategic thinker. Your role is to break down complex tasks into manageable, sequential steps while considering dependencies, risks, and alternatives.
    
    CURRENT PLANNING CONTEXT:
    - Step ${params.stepNumber} of ${params.totalSteps} (${params.scope} scope)
    - ${isFirstStep ? "INITIAL PLANNING" : isComplexPlan && params.stepNumber <= 3 ? "STRATEGIC PHASE" : "TACTICAL PHASE"}
    - ${params.isRevision ? `REVISING previous step ${params.revisingStep}` : ""}
    - ${params.isBranching ? `EXPLORING alternative from step ${params.branchingFrom} (${params.branchId})` : ""}
    
    PLANNING GUIDELINES:`;
    
        if (isFirstStep) {
          systemPrompt += `
    STEP 1 - FOUNDATION SETTING:
    - Thoroughly understand the complete scope and complexity
    - Consider multiple high-level approaches and their trade-offs
    - Identify key stakeholders, constraints, and success criteria
    - Think about resource requirements and potential challenges
    - Establish the overall strategy before diving into tactics`;
        } else if (needsDeepThinking) {
          systemPrompt += `
    STRATEGIC PLANNING PHASE (Complex Plan):
    - Build upon previous steps with deeper analysis
    - Consider interdependencies and critical decision points
    - Evaluate risks, assumptions, and validation needs
    - Think through resource allocation and timeline implications
    - Focus on strategic decisions before tactical implementation`;
        } else {
          systemPrompt += `
    TACTICAL PLANNING PHASE:
    - Develop specific, actionable steps
    - Consider implementation details and practical constraints
    - Sequence activities logically with clear dependencies
    - Think about coordination, communication, and progress tracking
    - Prepare for execution with concrete next steps`;
        }
    
        systemPrompt += `
    
    RESPONSE FORMAT:
    Provide a structured planning response that includes:
    1. **Current Step Analysis**: ${isFirstStep ? "Complete scope understanding" : "Step-specific planning focus"}
    2. **Key Considerations**: Important factors, constraints, or dependencies
    3. **Planning Decision**: Specific step content or strategic direction
    4. **Next Steps Guidance**: What should be planned in subsequent steps
    ${needsDeepThinking ? "5. **Deep Thinking Required**: Areas requiring further reflection" : ""}
    
    ${params.requirements ? `\nREQUIREMENTS TO CONSIDER:\n${params.requirements}` : ""}`;
    
        // Build the planning prompt
        let prompt = `Planning Task: ${params.task}`;
        
        if (!isFirstStep) {
          prompt += `\n\nThis is step ${params.stepNumber} in a ${params.totalSteps}-step planning process.`;
          if (params.isRevision) {
            prompt += ` I'm revising step ${params.revisingStep} based on new insights.`;
          }
          if (params.isBranching) {
            prompt += ` I'm exploring an alternative approach (${params.branchId}) branching from step ${params.branchingFrom}.`;
          }
        }
    
        prompt += `\n\nProvide the planning analysis for this step with specific, actionable guidance.`;
    
        try {
          const response = await provider.generateText({
            prompt,
            systemPrompt,
            temperature: 0.6, // Balanced temperature for creative yet structured planning
            reasoningEffort: (providerName === "openai" || providerName === "azure" || providerName === "grok") ? "high" : undefined,
            useSearchGrounding: providerName === "gemini" && params.scope === "comprehensive",
            toolName: 'planner',
          });
    
          // Build structured response
          const planningStep = {
            stepNumber: params.stepNumber,
            totalSteps: params.totalSteps,
            stepContent: response.text,
            scope: params.scope,
            isRevision: params.isRevision || false,
            revisingStep: params.revisingStep,
            isBranching: params.isBranching || false,
            branchingFrom: params.branchingFrom,
            branchId: params.branchId,
            requirements: params.requirements,
          };
    
          // Determine if more steps are needed and provide guidance
          const isLastStep = params.stepNumber >= params.totalSteps;
          const nextStepGuidance = isLastStep 
            ? "Planning complete. Present the final plan with clear implementation guidance."
            : needsDeepThinking 
            ? `MANDATORY PAUSE: This is a complex plan requiring deep thinking. Before step ${params.stepNumber + 1}, reflect on strategic decisions, alternatives, and critical dependencies.`
            : `Continue with step ${params.stepNumber + 1}. Focus on ${params.stepNumber >= params.totalSteps - 2 ? "implementation details and concrete actions" : "detailed planning and dependencies"}.`;
    
          const result = {
            currentStep: planningStep,
            planningComplete: isLastStep,
            nextStepRequired: !isLastStep,
            nextStepNumber: isLastStep ? null : params.stepNumber + 1,
            planningGuidance: nextStepGuidance,
            deepThinkingRequired: needsDeepThinking && !isLastStep,
            plannerStatus: {
              phase: isFirstStep ? "foundation" : needsDeepThinking ? "strategic" : "tactical",
              complexity: isComplexPlan ? "complex" : "standard",
              totalSteps: params.totalSteps,
              currentStep: params.stepNumber,
              remainingSteps: params.totalSteps - params.stepNumber,
            },
          };
    
          return {
            content: [
              {
                type: "text",
                text: JSON.stringify(result, null, 2),
              },
            ],
            metadata: {
              toolName: "planner",
              stepNumber: params.stepNumber,
              totalSteps: params.totalSteps,
              scope: params.scope,
              provider: providerName,
              model: response.model,
              planningPhase: result.plannerStatus.phase,
              usage: response.usage,
              ...response.metadata,
            },
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: JSON.stringify({
                  error: "Planning step failed",
                  message: error instanceof Error ? error.message : "Unknown error",
                  stepNumber: params.stepNumber,
                  totalSteps: params.totalSteps,
                }, null, 2),
              },
            ],
            isError: true,
          };
        }
      }
  • src/server.ts:354-362 (registration)
    Registers the 'planner' tool with the MCP server, specifying title, description, input schema, and handler invocation.
    // Register planner tool
    server.registerTool("planner", {
      title: "Planner",
      description: "Multi-step planning with revisions and branches",
      inputSchema: PlannerSchema.shape,
    }, async (args) => {
      const aiHandlers = await getHandlers();
      return await aiHandlers.handlePlanner(args);
    });
  • Zod schema defining the input parameters for the planner tool, including task, step numbers, scope, revision/branching flags, and provider selection.
    const PlannerSchema = z.object({
      task: z.string().describe("The task or problem to plan. For the first step, describe the complete planning challenge in detail. For subsequent steps, provide the specific planning step content, revisions, or branch explorations."),
      stepNumber: z.number().min(1).describe("Current step number in the planning sequence (starts at 1)"),
      totalSteps: z.number().min(1).describe("Current estimate of total steps needed (can be adjusted as planning progresses)"),
      scope: z.enum(["minimal", "standard", "comprehensive"]).default("standard").describe("Planning scope and depth"),
      requirements: z.string().optional().describe("Specific requirements, constraints, or success criteria"),
      isRevision: z.boolean().optional().default(false).describe("True if this step revises a previous step"),
      revisingStep: z.number().optional().describe("If isRevision is true, which step number is being revised"),
      isBranching: z.boolean().optional().default(false).describe("True if exploring an alternative approach from a previous step"),
      branchingFrom: z.number().optional().describe("If isBranching is true, which step number to branch from"),
      branchId: z.string().optional().describe("Identifier for this planning branch (e.g., 'approach-A', 'microservices-path')"),
      provider: z.enum(["openai", "gemini", "azure", "grok"]).optional().default("gemini").describe("AI provider to use for planning assistance"),
    });
  • Duplicate Zod schema for planner used internally in the handler function for type inference.
    const PlannerSchema = z.object({
      task: z.string().describe("The task or problem to plan. For the first step, describe the complete planning challenge in detail. For subsequent steps, provide the specific planning step content, revisions, or branch explorations."),
      stepNumber: z.number().min(1).describe("Current step number in the planning sequence (starts at 1)"),
      totalSteps: z.number().min(1).describe("Current estimate of total steps needed (can be adjusted as planning progresses)"),
      scope: z.enum(["minimal", "standard", "comprehensive"]).default("standard").describe("Planning scope and depth"),
      requirements: z.string().optional().describe("Specific requirements, constraints, or success criteria"),
      isRevision: z.boolean().optional().default(false).describe("True if this step revises a previous step"),
      revisingStep: z.number().optional().describe("If isRevision is true, which step number is being revised"),
      isBranching: z.boolean().optional().default(false).describe("True if exploring an alternative approach from a previous step"),
      branchingFrom: z.number().optional().describe("If isBranching is true, which step number to branch from"),
      branchId: z.string().optional().describe("Identifier for this planning branch (e.g., 'approach-A', 'microservices-path')"),
      provider: z.enum(["openai", "gemini", "azure", "grok"]).optional().default("gemini").describe("AI provider to use for planning assistance"),
    });
  • src/server.ts:721-746 (registration)
    Registers the prompt template for the planner tool, used for natural language invocation.
    server.registerPrompt("planner", {
      title: "Multi-Step Planning",
      description: "Create detailed multi-step plans with revisions and branching support",
      // String-only schema
      argsSchema: {
        task: z.string(),
        stepNumber: z.string(),
        totalSteps: z.string(),
        scope: z.string().optional(),
        requirements: z.string().optional(),
        isRevision: z.string().optional(),
        revisingStep: z.string().optional(),
        isBranching: z.string().optional(),
        branchingFrom: z.string().optional(),
        branchId: z.string().optional(),
        provider: z.string().optional(),
      },
    }, (args) => ({
      messages: [{
        role: "user",
        content: {
          type: "text",
          text: `Create a detailed plan for: ${args.task} (Step ${args.stepNumber} of ${args.totalSteps})${args.scope ? ` (scope: ${args.scope})` : ''}${args.requirements ? `\n\nRequirements: ${args.requirements}` : ''}${args.isRevision ? `\n\nThis is a revision of step ${args.revisingStep}` : ''}${args.isBranching ? `\n\nThis branches from step ${args.branchingFrom} as ${args.branchId}` : ''}${args.provider ? ` (using ${args.provider} provider)` : ''}`
        }
      }]
    }));
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. 'Multi-step planning with revisions and branches' suggests iterative, branching planning capabilities but doesn't describe what the tool actually produces (e.g., plans, outlines, structured outputs), how revisions work, what branching entails, or any limitations. It mentions features but not their implementation or behavioral characteristics.

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 extremely concise at just 5 words. It's front-loaded with the core concept and wastes no words. Every word contributes to the basic understanding of the tool's purpose. This is appropriate brevity for a tool name that already suggests its domain.

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?

For a complex planning tool with 11 parameters, no annotations, and no output schema, the description is inadequate. It doesn't explain what the tool returns, how planning sessions are structured, what 'revisions' and 'branches' mean operationally, or how the planning process works. The agent would struggle to understand what invoking this tool actually accomplishes.

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 all 11 parameters thoroughly. The description adds no parameter-specific information beyond what's in the schema. It doesn't explain how parameters interact (e.g., how 'isRevision' relates to 'revisingStep') or provide usage examples. Baseline 3 is appropriate when schema does the heavy lifting.

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

Purpose3/5

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

The description 'Multi-step planning with revisions and branches' states the general purpose but is vague about what the tool actually does. It mentions planning features but doesn't specify what kind of planning (e.g., project planning, AI planning, strategic planning) or what resources it operates on. It doesn't clearly distinguish from sibling tools like 'plan-feature' or 'ultra-plan'.

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 alternatives. There's no mention of prerequisites, appropriate contexts, or when to choose this over similar planning tools like 'plan-feature' or 'ultra-plan'. The agent must infer usage from the tool name and parameters alone.

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/RealMikeChong/ultra-mcp'

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