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
| Name | Required | Description | Default |
|---|---|---|---|
| branch_from | No | Step number to branch from for alternative exploration | |
| branch_id | No | Unique identifier for this branch | |
| branch_name | No | Descriptive name for this branch | |
| confidence | No | Confidence level in this step (0-1 scale) | |
| context | Yes | What is already known or has been completed to avoid redundancy | |
| dependencies | No | Step numbers this step depends on | |
| estimated_total | Yes | Current estimate of total steps needed (can be adjusted) | |
| external_context | No | External data or tool outputs relevant to this step | |
| next_action | Yes | Next tool or action to use (string or structured object) | |
| outcome | Yes | Expected or actual result from this step | |
| purpose | Yes | What this step accomplishes (analysis, action, validation, exploration, hypothesis, correction, planning, or custom) | |
| rationale | Yes | Why using this next action (natural language, no prefix required) | |
| revises_step | No | Step number being revised/corrected | |
| revision_reason | No | Why this revision is needed | |
| session_id | No | Session identifier for grouping related reasoning chains | |
| step_number | Yes | Sequential step number | |
| thought | Yes | Current reasoning. Express naturally without forced prefixes. | |
| tools_used | No | Tools used in this step | |
| uncertainty_notes | No | Notes about uncertainties or doubts |
Input Schema (JSON Schema)
Implementation Reference
- src/index.ts:179-319 (handler)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, }; });
- src/schema.ts:29-158 (schema)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' ] } };