Skip to main content
Glama

set_cell_value

Assign values to specific cells in Excel spreadsheets by specifying file path, sheet name, cell location, and value. Supports strings, numbers, and boolean inputs for precise data entry.

Instructions

指定されたセルに値を設定します

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cellYesセル位置。A1形式で指定(例: A1, B2, AA10, Z99)。範囲指定(A1:B2)は不可
filePathYes対象のExcelファイルの絶対パス
sheetNameYes対象のワークシート名。既存のワークシート名を指定してください
valueYesセルに設定する値。文字列、数値、真偽値のいずれか

Implementation Reference

  • Core handler function that validates the cell address, loads the Excel workbook using ExcelJS, retrieves the specified worksheet, sets the value in the target cell, saves the file, and returns a confirmation message.
    async function setCellValue(filePath: string, sheetName: string, cell: string, value: any): Promise<string> {
      try {
        validateCellAddress(cell);
        
        const workbook = await loadWorkbook(filePath);
        const worksheet = workbook.getWorksheet(sheetName);
        if (!worksheet) {
          throw new Error(`ワークシート '${sheetName}' が見つかりません。利用可能なシート: ${getSheetNames(workbook)}`);
        }
        worksheet.getCell(cell).value = value;
        await workbook.xlsx.writeFile(filePath);
        
        return `セル ${cell} に値 '${value}' を設定しました。`;
      } catch (error) {
        throw new McpError(ErrorCode.InternalError, `セル値設定エラー: ${error}`);
      }
    }
  • Zod schema defining the input parameters for the set_cell_value tool: filePath, sheetName, cell, and value.
    const SetCellValueSchema = z.object({
      filePath: z.string().describe("対象のExcelファイルの絶対パス"),
      sheetName: z.string().describe("対象のワークシート名。既存のワークシート名を指定してください"),
      cell: z.string().describe("セル位置。A1形式で指定(例: A1, B2, AA10, Z99)。範囲指定(A1:B2)は不可"),
      value: z.union([z.string(), z.number(), z.boolean()]).describe("セルに設定する値。文字列、数値、真偽値のいずれか"),
    });
  • src/index.ts:482-484 (registration)
    Tool registration in the ListTools response, specifying name, description, and input schema.
    name: "set_cell_value",
    description: "指定されたセルに値を設定します",
    inputSchema: zodToJsonSchema(SetCellValueSchema)
  • MCP tool handler wrapper that parses arguments using the schema and delegates to the core setCellValue function.
    set_cell_value: async (args: any) => {
      const { filePath, sheetName, cell, value } = SetCellValueSchema.parse(args);
      return await setCellValue(filePath, sheetName, cell, value);
    },
  • Helper function to validate cell address format (A1 style), used in setCellValue.
    function validateCellAddress(cell: string): void {
      const cellPattern = /^[A-Z]+[1-9]\d*$/;
      if (!cellPattern.test(cell)) {
        throw new Error(`無効なセル位置: '${cell}'。正しい形式: A1, B2, AA10など`);
      }
    }
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 tool sets a value but doesn't mention whether this is a write operation, if it overwrites existing data, what permissions are needed, or error handling. This is inadequate for a mutation tool with zero annotation coverage.

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 purpose without any fluff. It's appropriately sized and front-loaded, with every word earning its place.

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 this is a mutation tool with no annotations and no output schema, the description is incomplete. It doesn't cover behavioral aspects like side effects, error cases, or return values, leaving significant gaps for the agent to understand the tool's full context.

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 schema description coverage is 100%, so the schema already documents all four parameters thoroughly. The description adds no additional meaning beyond what the schema provides, such as examples or constraints, meeting the baseline for high schema coverage.

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 clearly states the action ('set a value') and the target ('specified cell'), which is a specific verb+resource combination. However, it doesn't explicitly differentiate from sibling tools like 'set_range_values' or 'format_cell', which would require a 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 like 'set_range_values' for multiple cells or 'add_formula' for formulas. It lacks context about prerequisites or exclusions, leaving the agent to infer usage from the schema alone.

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