explain_error
Analyzes error logs and stack traces with surrounding context to provide AI-driven explanations. Helps understand and diagnose errors.
Instructions
AI-assisted error analysis. Formats error content for AI analysis.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| errorContent | Yes | The error log or stack trace to analyze | |
| contextLines | No | Number of context lines around the error |
Implementation Reference
- src/tools/explain_error.ts:8-33 (handler)The main handler function for the 'explain_error' tool. It takes errorContent and contextLines input, formats an analysis request, and returns it as AI-prompt text.
export async function explainError(input: ToolInput): Promise<{ content: Array<{ type: string; text: string }> }> { const { errorContent, contextLines = 10 } = input as ExplainErrorInput; if (!errorContent) { return { content: [{ type: 'text', text: 'Error: errorContent is required' }] }; } const formatted = `Please analyze the following error and help me understand: 1. What is the root cause of this error? 2. What steps should I take to resolve it? 3. Are there any related logs or patterns I should look for? Error Log: \`\`\` ${errorContent} \`\`\` Context: The error occurred with ${contextLines} lines of context around it.`; return { content: [ { type: 'text', text: 'Error analysis request formatted. The AI will analyze the error content.' }, { type: 'text', text: formatted } ] }; } - src/tools/explain_error.ts:3-6 (schema)Type definition for ExplainErrorInput, extending ToolInput with errorContent (string) and optional contextLines (number).
interface ExplainErrorInput extends ToolInput { errorContent: string; contextLines?: number; } - src/index.ts:113-131 (registration)Tool registration in the TOOLS array: defines the 'explain_error' tool with name, description, and inputSchema (errorContent required, contextLines optional with default 10).
{ name: 'explain_error', description: 'AI-assisted error analysis. Formats error content for AI analysis.', inputSchema: { type: 'object', properties: { errorContent: { type: 'string', description: 'The error log or stack trace to analyze' }, contextLines: { type: 'number', default: 10, description: 'Number of context lines around the error' } }, required: ['errorContent'] } } - src/index.ts:156-157 (registration)Request handler routing: the 'explain_error' case in the switch statement dispatches to the explainError function.
case 'explain_error': return await explainError(args || {}); - src/types/index.ts:52-54 (helper)The ToolInput base interface used by ExplainErrorInput - defines a generic dictionary type for tool inputs.
export interface ToolInput { [key: string]: unknown; }