Skip to main content
Glama

sequential_thinking

Break down complex coding problems into structured steps, validating each before proceeding to ensure systematic problem-solving and architectural decisions.

Instructions

A tool to facilitate sequential, structured thinking. It forces the AI to break down complex problems into steps, validating each before moving to the next. Use this when facing a complex coding task or architectural decision.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
thoughtYesThe current thought or step in the reasoning process.
stepYesThe current step number (1-indexed).
total_stepsYesThe estimated total number of steps.
is_revisionNoSet to true if revising a previous step.
next_actionYesWhat to do next: continue thinking, revise previous thoughts, or provide the final answer.

Implementation Reference

  • Executes the sequential_thinking tool logic by echoing back structured thought data to reinforce step-by-step reasoning.
    export function sequentialThinkingHandler(args: any) {
        // In a real scenario, this might log to a file or maintain state across turns.
        // For now, it simply echoes back the structured thought to reinforce the behavior.
        return {
            content: [
                {
                    type: "text",
                    text: JSON.stringify({
                        status: "THOUGHT_RECORDED",
                        step: args.step,
                        of: args.total_steps,
                        thought: args.thought,
                        next: args.next_action
                    }, null, 2)
                }
            ]
        };
    }
  • Defines the input schema using Zod for validating arguments to the sequential_thinking tool.
    export const sequentialThinkingSchema = {
        name: "sequential_thinking",
        description: "A tool to facilitate sequential, structured thinking. It forces the AI to break down complex problems into steps, validating each before moving to the next. Use this when facing a complex coding task or architectural decision.",
        inputSchema: z.object({
            thought: z.string().describe("The current thought or step in the reasoning process."),
            step: z.number().describe("The current step number (1-indexed)."),
            total_steps: z.number().describe("The estimated total number of steps."),
            is_revision: z.boolean().optional().describe("Set to true if revising a previous step."),
            next_action: z.enum(["CONTINUE", "REVISE", "The final conclusion or answer"]).describe("What to do next: continue thinking, revise previous thoughts, or provide the final answer.")
        })
    };
  • src/index.ts:78-78 (registration)
    Registers the sequential_thinking tool in the toolRegistry Map used by the stdio MCP server.
    ["sequential_thinking", { schema: sequentialThinkingSchema, handler: sequentialThinkingHandler }],
  • src/server.ts:88-88 (registration)
    Registers the sequential_thinking tool in the toolRegistry Map used by the HTTP MCP server.
    ["sequential_thinking", { schema: sequentialThinkingSchema, handler: sequentialThinkingHandler }],

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/millsydotdev/Code-MCP'

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