excel_create_named_range
Define named ranges in Excel workbooks to simplify financial formulas, improve formula readability, and streamline financial modeling workflows.
Instructions
Create a named range in the workbook
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | ||
| range | Yes | ||
| worksheetName | No |
Implementation Reference
- src/excel/excel-manager.ts:195-202 (handler)Core handler method in ExcelManager class that creates the named range using ExcelJS workbook.definedNames.add()async createNamedRange(name: string, range: string, worksheetName?: string): Promise<void> { if (!this.workbook) { throw new Error('No workbook is currently open'); } const fullRange = worksheetName ? `${worksheetName}!${range}` : range; this.workbook.definedNames.add(name, fullRange); }
- src/tools/excel-tools.ts:225-251 (registration)Tool object definition including name, description, input schema, and thin wrapper handler that calls ExcelManager.createNamedRange and handles ToolResult{ name: "excel_create_named_range", description: "Create a named range in the workbook", inputSchema: { type: "object", properties: { name: { type: "string" }, range: { type: "string" }, worksheetName: { type: "string" } }, required: ["name", "range"] }, handler: async (args: any): Promise<ToolResult> => { try { await excelManager.createNamedRange(args.name, args.range, args.worksheetName); return { success: true, message: `Created named range: ${args.name}` }; } catch (error) { return { success: false, error: error instanceof Error ? error.message : String(error) }; } } },
- src/index.ts:32-44 (registration)Main MCP server aggregates excelTools (containing excel_create_named_range) into allTools list used for tool listing and executionconst allTools = [ ...excelTools, ...financialTools, ...rentalTools, ...expenseTools, ...reportingTools, ...cashFlowTools, ...taxTools, ...analyticsTools, ...chartTools, ...complianceTools, ...propertyTools, ];
- src/tools/excel-tools.ts:228-236 (schema)Input schema defining parameters for the excel_create_named_range tool: name (string, required), range (string, required), worksheetName (string, optional)inputSchema: { type: "object", properties: { name: { type: "string" }, range: { type: "string" }, worksheetName: { type: "string" } }, required: ["name", "range"] },