Skip to main content
Glama

add_formula

Insert formulas into specified Excel cells using file path, sheet name, and cell position. Automates Excel calculations for data manipulation and analysis.

Instructions

セルに数式を追加します

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cellYesセル位置(例: A1)
filePathYesExcelファイルのパス
formulaYes数式(=SUM(A1:A10)など、=で始まる)
sheetNameYesワークシート名

Implementation Reference

  • Implements the core logic for adding a formula to a specific cell in an Excel worksheet using ExcelJS.
    async function addFormula(filePath: string, sheetName: string, cell: string, formula: string): Promise<string> { try { const workbook = await loadWorkbook(filePath); const worksheet = workbook.getWorksheet(sheetName); if (!worksheet) { throw new Error(`ワークシート '${sheetName}' が見つかりません。`); } worksheet.getCell(cell).value = { formula: formula }; await workbook.xlsx.writeFile(filePath); return `セル ${cell} に数式 '${formula}' を設定しました。`; } catch (error) { throw new McpError(ErrorCode.InternalError, `数式追加エラー: ${error}`); } }
  • Zod schema for validating the input parameters of the add_formula tool.
    const AddFormulaSchema = z.object({ filePath: z.string().describe("Excelファイルのパス"), sheetName: z.string().describe("ワークシート名"), cell: z.string().describe("セル位置(例: A1)"), formula: z.string().describe("数式(=SUM(A1:A10)など、=で始まる)"), });
  • src/index.ts:559-561 (registration)
    Registers the add_formula tool in the toolImplementations map by providing a wrapper that parses arguments and delegates to the main handler function.
    add_formula: async (args: any) => { const { filePath, sheetName, cell, formula } = AddFormulaSchema.parse(args); return await addFormula(filePath, sheetName, cell, formula);
  • src/index.ts:507-509 (registration)
    Registers the add_formula tool metadata (name, description, schema) in the ListTools response.
    name: "add_formula", description: "セルに数式を追加します", inputSchema: zodToJsonSchema(AddFormulaSchema)

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/SuperPyonchiX/excel_mcp_server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server