explain_formula
Understand Excel formulas by translating them into plain English explanations. Enter any formula to get a clear breakdown of its function and purpose.
Instructions
Explain what an Excel formula does in plain English
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| formula | Yes | Excel formula to explain (e.g., "=VLOOKUP(A2,B:C,2,FALSE)") | |
| provider | No | Preferred AI provider: anthropic, openai, deepseek, gemini, or local (optional) |
Implementation Reference
- src/index.ts:1261-1263 (registration)Dispatch registration in the CallToolRequestSchema handler that routes 'explain_formula' tool calls to AIOperationsHandler.explainFormulacase 'explain_formula': return await this.aiOpsHandler.explainFormula(toolArgs); case 'ai_provider_status':
- src/index.ts:884-901 (schema)Tool schema definition including input schema with required 'formula' parameter and optional AI 'provider'name: 'explain_formula', description: 'Explain what an Excel formula does in plain English', inputSchema: { type: 'object', properties: { formula: { type: 'string', description: 'Excel formula to explain (e.g., "=VLOOKUP(A2,B:C,2,FALSE)")', }, provider: { type: 'string', description: 'Preferred AI provider: anthropic, openai, deepseek, gemini, or local (optional)', enum: ['anthropic', 'openai', 'deepseek', 'gemini', 'local'], }, }, required: ['formula'], }, },
- src/handlers/ai-operations.ts:196-229 (handler)Main handler function that extracts arguments, delegates to NLPProcessor.explainFormula, formats response as MCP ToolResponseasync explainFormula(args: ToolArgs): Promise<ToolResponse> { const { formula, provider } = args; try { const explanation = await this.nlpProcessor.explainFormula(formula, provider); return { content: [ { type: 'text', text: JSON.stringify({ formula, explanation, success: true, provider: this.nlpProcessor.getActiveProvider()?.name || 'Local' }, null, 2), }, ], }; } catch (error) { return { content: [ { type: 'text', text: JSON.stringify({ formula, error: error instanceof Error ? error.message : 'Unknown error', success: false }, null, 2), }, ], }; } }
- src/ai/nlp-processor.ts:94-111 (helper)Core helper function in NLPProcessor that generates AI prompt for formula explanation, calls AIManager for completion, with fallback explainerasync explainFormula(formula: string, preferredProvider?: ProviderType): Promise<string> { const prompt = `Explain this Excel formula in simple terms: ${formula}`; try { const response = await this.aiManager.createCompletion([ { role: 'user', content: prompt } ], { maxTokens: 300, temperature: 0, preferredProvider }); return response.content; } catch (error) { // console.error('Error explaining formula:', error); return this.fallbackFormulaExplainer(formula); } }