excel_get_formulas
Extract all formulas from Excel worksheets to analyze financial calculations, verify formulas, and maintain spreadsheet integrity for accounting workflows.
Instructions
Extract all formulas from a worksheet
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| worksheetName | Yes |
Implementation Reference
- src/tools/excel-tools.ts:292-316 (registration)Tool registration object defining name, description, input schema, and handler function that delegates to ExcelManager.getCellFormulas{ name: "excel_get_formulas", description: "Extract all formulas from a worksheet", inputSchema: { type: "object", properties: { worksheetName: { type: "string" } }, required: ["worksheetName"] }, handler: async (args: any): Promise<ToolResult> => { try { const formulas = await excelManager.getCellFormulas(args.worksheetName); return { success: true, data: formulas }; } catch (error) { return { success: false, error: error instanceof Error ? error.message : String(error) }; } } },
- src/tools/excel-tools.ts:302-315 (handler)The tool handler function that calls the ExcelManager to get formulas from the specified worksheethandler: async (args: any): Promise<ToolResult> => { try { const formulas = await excelManager.getCellFormulas(args.worksheetName); return { success: true, data: formulas }; } catch (error) { return { success: false, error: error instanceof Error ? error.message : String(error) }; } }
- src/excel/excel-manager.ts:310-330 (helper)Core implementation that traverses the worksheet rows and cells to collect all formulas into a dictionary by cell addressasync getCellFormulas(worksheetName: string): Promise<{ [cell: string]: string }> { if (!this.workbook) { throw new Error('No workbook is currently open'); } const worksheet = this.workbook.getWorksheet(worksheetName); if (!worksheet) { throw new Error(`Worksheet "${worksheetName}" not found`); } const formulas: { [cell: string]: string } = {}; worksheet.eachRow((row) => { row.eachCell((cell) => { if ((cell as any).formula) { formulas[cell.address] = (cell as any).formula; } }); }); return formulas;
- src/index.ts:32-44 (registration)Main tools registry where excelTools (containing excel_get_formulas) is included in the allTools array used by the MCP serverconst allTools = [ ...excelTools, ...financialTools, ...rentalTools, ...expenseTools, ...reportingTools, ...cashFlowTools, ...taxTools, ...analyticsTools, ...chartTools, ...complianceTools, ...propertyTools, ];