Skip to main content
Glama
nikkoxgonzales

CRASH - Cascaded Reasoning with Adaptive Step Handling

crash

Organize and break down complex tasks into structured, iterative steps for analysis, planning, and problem-solving. Use adaptive reasoning, confidence tracking, and revision mechanisms to explore multiple solution paths systematically.

Instructions

Facilitates structured, iterative reasoning for complex problem-solving and analysis. Use this to organize thoughts, break down tasks, and plan actions step-by-step. This tool is ideal for scenarios requiring careful consideration of multiple factors, such as code optimization, system design, or strategic planning.

When to use CRASH:

  • When user says "use crash" or similar phrases

  • For multi-step or complex tasks requiring careful breakdown

  • For understanding, planning, or analyzing codes or content

  • When systematic reasoning is needed

  • When you need to revise or correct previous reasoning

  • When exploring multiple solution paths

Key Features:

  • Flexible purpose types (analysis, action, validation, exploration, hypothesis, etc.)

  • Confidence tracking for uncertain situations

  • Revision mechanism to correct previous steps

  • Branching support for parallel exploration

  • Structured tool integration

  • No rigid formatting requirements (configurable)

Instructions:

  • Each step must specify a clear purpose and reasoning approach

  • Track context to avoid redundancy

  • Use confidence scores when uncertain (0-1 scale)

  • Revise previous steps when needed using revises_step

  • Branch to explore alternatives using branch_from

  • Continue until task completion or solution found

Input Schema

NameRequiredDescriptionDefault
branch_fromNoStep number to branch from for alternative exploration
branch_idNoUnique identifier for this branch
branch_nameNoDescriptive name for this branch
confidenceNoConfidence level in this step (0-1 scale)
contextYesWhat is already known or has been completed to avoid redundancy
dependenciesNoStep numbers this step depends on
estimated_totalYesCurrent estimate of total steps needed (can be adjusted)
external_contextNoExternal data or tool outputs relevant to this step
next_actionYesNext tool or action to use (string or structured object)
outcomeYesExpected or actual result from this step
purposeYesWhat this step accomplishes (analysis, action, validation, exploration, hypothesis, correction, planning, or custom)
rationaleYesWhy using this next action (natural language, no prefix required)
revises_stepNoStep number being revised/corrected
revision_reasonNoWhy this revision is needed
session_idNoSession identifier for grouping related reasoning chains
step_numberYesSequential step number
thoughtYesCurrent reasoning. Express naturally without forced prefixes.
tools_usedNoTools used in this step
uncertainty_notesNoNotes about uncertainties or doubts

Input Schema (JSON Schema)

{ "properties": { "branch_from": { "description": "Step number to branch from for alternative exploration", "minimum": 1, "type": "integer" }, "branch_id": { "description": "Unique identifier for this branch", "type": "string" }, "branch_name": { "description": "Descriptive name for this branch", "type": "string" }, "confidence": { "description": "Confidence level in this step (0-1 scale)", "maximum": 1, "minimum": 0, "type": "number" }, "context": { "description": "What is already known or has been completed to avoid redundancy", "type": "string" }, "dependencies": { "description": "Step numbers this step depends on", "items": { "type": "integer" }, "type": "array" }, "estimated_total": { "description": "Current estimate of total steps needed (can be adjusted)", "minimum": 1, "type": "integer" }, "external_context": { "description": "External data or tool outputs relevant to this step", "type": "object" }, "next_action": { "description": "Next tool or action to use (string or structured object)", "oneOf": [ { "description": "Simple next action description", "type": "string" }, { "description": "Structured action with tool integration", "properties": { "action": { "description": "Action to perform", "type": "string" }, "expectedOutput": { "description": "What we expect from this action", "type": "string" }, "parameters": { "description": "Parameters for the action", "type": "object" }, "tool": { "description": "Tool name if applicable", "type": "string" } }, "required": [ "action" ], "type": "object" } ] }, "outcome": { "description": "Expected or actual result from this step", "type": "string" }, "purpose": { "description": "What this step accomplishes (analysis, action, validation, exploration, hypothesis, correction, planning, or custom)", "type": "string" }, "rationale": { "description": "Why using this next action (natural language, no prefix required)", "type": "string" }, "revises_step": { "description": "Step number being revised/corrected", "minimum": 1, "type": "integer" }, "revision_reason": { "description": "Why this revision is needed", "type": "string" }, "session_id": { "description": "Session identifier for grouping related reasoning chains", "type": "string" }, "step_number": { "description": "Sequential step number", "minimum": 1, "type": "integer" }, "thought": { "description": "Current reasoning. Express naturally without forced prefixes.", "type": "string" }, "tools_used": { "description": "Tools used in this step", "items": { "type": "string" }, "type": "array" }, "uncertainty_notes": { "description": "Notes about uncertainties or doubts", "type": "string" } }, "required": [ "step_number", "estimated_total", "purpose", "context", "thought", "outcome", "next_action", "rationale" ], "type": "object" }

Implementation Reference

  • Core handler for the 'crash' tool. Processes input step, validates fields, handles strict mode checks, revisions, branching, sessions, updates history, formats and logs output, and returns structured JSON response.
    public async processStep(input: unknown): Promise<{ content: Array<{ type: string; text: string }>; isError?: boolean; }> { try { const step = input as CrashStep; const stepStartTime = Date.now(); // Validate required fields if (!step.step_number || !step.estimated_total || !step.purpose || !step.context || !step.thought || !step.outcome || !step.next_action || !step.rationale) { throw new Error('Missing required fields'); } // Apply strict mode if enabled if (this.config.validation.strictMode) { if (!this.validateThoughtPrefix(step.thought)) { throw new Error('Thought must start with one of the required phrases (strict mode)'); } if (!this.validateRationale(step.rationale)) { throw new Error('Rationale must start with "To " (strict mode)'); } if (!this.validatePurpose(step.purpose)) { throw new Error(`Invalid purpose: ${step.purpose} (strict mode)`); } } else { // Flexible validation if (!this.validatePurpose(step.purpose)) { console.error(`⚠️ Using custom purpose: ${step.purpose}`); } } // Add timestamp and duration step.timestamp = new Date().toISOString(); // Handle session management if (step.session_id && this.config.features.enableSessions) { if (!this.sessions.has(step.session_id)) { this.sessions.set(step.session_id, this.createNewHistory()); } this.history = this.sessions.get(step.session_id)!; } // Check if completed const completionPhrases = ['I have completed', 'Task completed', 'Solution found']; if (completionPhrases.some(phrase => step.thought.toLowerCase().includes(phrase.toLowerCase()))) { this.history.completed = true; } // Handle special features this.handleRevision(step); this.handleBranching(step); // Track tools used const toolsUsed = this.extractToolsUsed(step); if (toolsUsed.length > 0 && this.history.metadata) { this.history.metadata.tools_used = [ ...new Set([...(this.history.metadata.tools_used || []), ...toolsUsed]) ]; } // Add to history this.history.steps.push(step); // Update metadata if (this.history.metadata) { step.duration_ms = Date.now() - stepStartTime; this.history.metadata.total_duration_ms = Date.now() - this.startTime; } this.history.updated_at = new Date().toISOString(); // Trim history if needed if (this.history.steps.length > this.config.system.maxHistorySize) { this.history.steps = this.history.steps.slice(-this.config.system.maxHistorySize); console.error(`History trimmed to ${this.config.system.maxHistorySize} steps`); } // Display formatted step const formattedOutput = this.formatOutput(step); console.error(formattedOutput); // Show confidence warning if low if (step.confidence !== undefined && step.confidence < 0.5) { console.error(`⚠️ Low confidence (${Math.round(step.confidence * 100)}%): ${step.uncertainty_notes || 'Consider verification'}`); } // Prepare response const responseData: any = { step_number: step.step_number, estimated_total: step.estimated_total, completed: this.history.completed, total_steps: this.history.steps.length, next_action: step.next_action, }; // Add optional response fields if (step.confidence !== undefined) { responseData.confidence = step.confidence; } if (step.revises_step) { responseData.revised_step = step.revises_step; } if (step.branch_id) { responseData.branch = { id: step.branch_id, name: step.branch_name, from: step.branch_from }; } return { content: [ { type: 'text', text: JSON.stringify(responseData, null, 2), }, ], }; } catch (error) { return { content: [ { type: 'text', text: JSON.stringify( { error: error instanceof Error ? error.message : String(error), status: 'failed', hint: this.config.validation.strictMode ? 'Strict mode is enabled. Set CRASH_STRICT_MODE=false for flexible validation.' : 'Check that all required fields are provided.', }, null, 2 ), }, ], isError: true, }; } }
  • src/index.ts:364-382 (registration)
    Registers the 'crash' tool in the MCP server: lists it in ListToolsRequestHandler and dispatches calls to the processStep handler when name matches 'crash'.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [CRASH_TOOL], })); server.setRequestHandler(CallToolRequestSchema, async (request) => { if (request.params.name === 'crash') { return crashServer.processStep(request.params.arguments); } return { content: [ { type: 'text', text: `Unknown tool: ${request.params.name}`, }, ], isError: true, }; });
  • Defines the MCP Tool schema for 'crash', including detailed inputSchema with required fields for structured reasoning steps and optional fields for confidence, revisions, branching, etc.
    export const CRASH_TOOL: Tool = { name: 'crash', description: TOOL_DESCRIPTION, inputSchema: { type: 'object', properties: { // Core required fields step_number: { type: 'integer', description: 'Sequential step number', minimum: 1 }, estimated_total: { type: 'integer', description: 'Current estimate of total steps needed (can be adjusted)', minimum: 1 }, purpose: { type: 'string', description: 'What this step accomplishes (analysis, action, validation, exploration, hypothesis, correction, planning, or custom)', }, context: { type: 'string', description: 'What is already known or has been completed to avoid redundancy' }, thought: { type: 'string', description: 'Current reasoning. Express naturally without forced prefixes.' }, outcome: { type: 'string', description: 'Expected or actual result from this step' }, next_action: { oneOf: [ { type: 'string', description: 'Simple next action description' }, { type: 'object', description: 'Structured action with tool integration', properties: { tool: { type: 'string', description: 'Tool name if applicable' }, action: { type: 'string', description: 'Action to perform' }, parameters: { type: 'object', description: 'Parameters for the action' }, expectedOutput: { type: 'string', description: 'What we expect from this action' } }, required: ['action'] } ], description: 'Next tool or action to use (string or structured object)' }, rationale: { type: 'string', description: 'Why using this next action (natural language, no prefix required)' }, // Optional enhancement fields confidence: { type: 'number', description: 'Confidence level in this step (0-1 scale)', minimum: 0, maximum: 1 }, uncertainty_notes: { type: 'string', description: 'Notes about uncertainties or doubts' }, // Revision support revises_step: { type: 'integer', description: 'Step number being revised/corrected', minimum: 1 }, revision_reason: { type: 'string', description: 'Why this revision is needed' }, // Branching support branch_from: { type: 'integer', description: 'Step number to branch from for alternative exploration', minimum: 1 }, branch_id: { type: 'string', description: 'Unique identifier for this branch' }, branch_name: { type: 'string', description: 'Descriptive name for this branch' }, // Tool integration tools_used: { type: 'array', items: { type: 'string' }, description: 'Tools used in this step' }, external_context: { type: 'object', description: 'External data or tool outputs relevant to this step' }, dependencies: { type: 'array', items: { type: 'integer' }, description: 'Step numbers this step depends on' }, // Session support session_id: { type: 'string', description: 'Session identifier for grouping related reasoning chains' } }, required: [ 'step_number', 'estimated_total', 'purpose', 'context', 'thought', 'outcome', 'next_action', 'rationale' ] } };

Other Tools

Related 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/nikkoxgonzales/crash-mcp'

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