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)
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the action ('adds a formula') but doesn't cover critical aspects like whether this overwrites existing cell content, requires file permissions, has side effects, or returns any confirmation. For a mutation tool with zero annotation coverage, this is a significant gap.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence in Japanese that directly states the tool's function. It's front-loaded with the core action and has no wasted words, making it highly concise and well-structured for quick comprehension.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (a mutation operation with 4 required parameters), lack of annotations, and no output schema, the description is incomplete. It doesn't address behavioral traits, usage context, or what happens post-execution (e.g., success confirmation or error handling), leaving the agent under-informed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds no parameter semantics beyond what the input schema provides. Since schema description coverage is 100% (each parameter has a clear description in Japanese), the baseline is 3. The tool description doesn't compensate with additional context like formula syntax examples or file path requirements.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'セルに数式を追加します' (Adds a formula to a cell) clearly states the verb ('adds') and resource ('formula to a cell'), making the tool's purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'set_cell_value' or 'set_range_values', which might also modify cell content, so it's not a perfect 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., file must exist), exclusions, or compare it to siblings like 'set_cell_value' for non-formula content. This leaves the agent guessing about appropriate contexts.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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