Skip to main content
Glama

add_worksheet

Add a new worksheet to an existing Excel workbook by specifying the file path and sheet name using the Excel MCP Server tool.

Instructions

既存のワークブックにワークシートを追加します

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filePathYes対象のExcelファイルの絶対パス。既存のファイルである必要があります
sheetNameYes作成するワークシート名。英数字、日本語、アンダースコア、ハイフンが使用可能です

Implementation Reference

  • Zod schema defining the input parameters for the add_worksheet tool: filePath and sheetName.
    const AddWorksheetSchema = z.object({
      filePath: z.string().describe("対象のExcelファイルの絶対パス。既存のファイルである必要があります"),
      sheetName: z.string().describe("作成するワークシート名。英数字、日本語、アンダースコア、ハイフンが使用可能です"),
    });
  • Core handler function that loads the Excel workbook, checks for existing sheet, adds new worksheet using ExcelJS, saves the file, and returns confirmation.
    async function addWorksheet(filePath: string, sheetName: string): Promise<string> {
      try {
        if (!sheetName || sheetName.trim() === '') {
          throw new Error("ワークシート名が空です");
        }
        
        const workbook = await loadWorkbook(filePath);
        
        // 既存のシート名と重複チェック
        const existingSheet = workbook.getWorksheet(sheetName);
        if (existingSheet) {
          throw new Error(`ワークシート '${sheetName}' は既に存在します`);
        }
        
        workbook.addWorksheet(sheetName);
        await workbook.xlsx.writeFile(filePath);
        
        return `ワークシート '${sheetName}' を追加しました。`;
      } catch (error) {
        throw new McpError(ErrorCode.InternalError, `ワークシート追加エラー: ${error}`);
      }
    }
  • src/index.ts:476-480 (registration)
    Tool registration in the listTools handler, defining name, description, and input schema.
    {
      name: "add_worksheet", 
      description: "既存のワークブックにワークシートを追加します",
      inputSchema: zodToJsonSchema(AddWorksheetSchema)
    },
  • src/index.ts:535-538 (registration)
    Tool implementation wrapper in the dispatch map, which parses args with schema and delegates to the handler function.
    add_worksheet: async (args: any) => {
      const { filePath, sheetName } = AddWorksheetSchema.parse(args);
      return await addWorksheet(filePath, sheetName);
    },
  • Helper function to load and validate an Excel workbook, used by the addWorksheet handler.
    async function loadWorkbook(filePath: string): Promise<ExcelJS.Workbook> {
      try {
        validateFilePath(filePath);
        
        const workbook = new ExcelJS.Workbook();
        await workbook.xlsx.readFile(filePath);
        return workbook;
      } catch (error) {
        throw new McpError(ErrorCode.InternalError, `ワークブック読み込みエラー: ${error}`);
      }
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states this is a write operation ('adds') but doesn't mention permission requirements, whether the operation is reversible, what happens if a sheet with the same name exists, or any rate limits. For a mutation tool with zero annotation coverage, this leaves significant behavioral gaps.

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

Conciseness4/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. It's appropriately sized for a simple tool, though it could be slightly more front-loaded with key constraints. No wasted words or unnecessary elaboration.

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?

For a mutation tool with no annotations and no output schema, the description is insufficiently complete. It doesn't explain what the tool returns, error conditions, or important behavioral aspects like what happens when adding duplicate sheet names. The description should provide more context given the tool's complexity as a write operation.

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?

Schema description coverage is 100%, so the schema already fully documents both parameters with good descriptions. The tool description adds no additional parameter information beyond what's in the schema. According to scoring rules, when schema_description_coverage is high (>80%), the baseline is 3 even with no param info in the description.

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 ('adds a worksheet') and target resource ('to an existing workbook'), providing a specific verb+resource combination. However, it doesn't explicitly differentiate from sibling tools like 'create_workbook' (which creates new workbooks) or 'get_workbook_info' (which reads workbook information), though the distinction is somewhat implied by the 'existing workbook' context.

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 minimal guidance - it mentions 'existing workbook' which implies when to use this vs. 'create_workbook', but doesn't offer explicit when/when-not instructions or mention alternatives like modifying existing worksheets. No prerequisites or constraints beyond the 'existing workbook' requirement are stated.

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