Skip to main content
Glama

create_workbook

Generate an empty Excel workbook file at a specified file path. Use this tool to initialize a workbook before adding worksheets with the add_worksheet tool for data manipulation.

Instructions

新しいExcelワークブックを作成します。注意: 作成されるワークブックは空でシートを含みません。データを操作する前にadd_worksheetツールでワークシートを追加する必要があります。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filePathYes作成するExcelファイルの絶対パス。例: C:/Users/Username/Documents/report.xlsx。ファイル拡張子は.xlsxである必要があります。注意: 作成されるワークブックは空でシートを含みません

Implementation Reference

  • The core handler function that creates an empty Excel workbook (.xlsx) at the specified absolute file path using ExcelJS library. Validates the path and returns a success message.
    async function createWorkbook(filePath: string): Promise<string> { try { validateFilePath(filePath); // 空のワークブックを作成(シートは含まれない) const workbook = new ExcelJS.Workbook(); await workbook.xlsx.writeFile(filePath); return `Excelワークブック '${filePath}' を作成しました。注意: このワークブックはシートを含んでいません。データを操作する前に、add_worksheetツールを使用してワークシートを追加してください。`; } catch (error) { throw new McpError(ErrorCode.InternalError, `ワークブック作成エラー: ${error}`); } }
  • Zod schema defining the input for create_workbook tool: requires 'filePath' as a string with description.
    const CreateWorkbookSchema = z.object({ filePath: z.string().describe("作成するExcelファイルの絶対パス。例: C:/Users/Username/Documents/report.xlsx。ファイル拡張子は.xlsxである必要があります。注意: 作成されるワークブックは空でシートを含みません"), });
  • src/index.ts:466-470 (registration)
    Tool registration in the ListTools response: defines name, description, and input schema.
    { name: "create_workbook", description: "新しいExcelワークブックを作成します。注意: 作成されるワークブックは空でシートを含みません。データを操作する前にadd_worksheetツールでワークシートを追加する必要があります。", inputSchema: zodToJsonSchema(CreateWorkbookSchema) },
  • src/index.ts:527-530 (registration)
    Tool implementation registration in the toolImplementations map used by CallToolRequestSchema handler: parses args with schema and delegates to createWorkbook function.
    create_workbook: async (args: any) => { const { filePath } = CreateWorkbookSchema.parse(args); return await createWorkbook(filePath); },
  • Helper function to validate the filePath input: checks non-empty, .xlsx/.xls extension, and absolute path.
    function validateFilePath(filePath: string): void { if (!filePath) { throw new Error("ファイルパスが指定されていません"); } if (!filePath.endsWith('.xlsx') && !filePath.endsWith('.xls')) { throw new Error("ファイル拡張子は .xlsx または .xls である必要があります"); } if (!path.isAbsolute(filePath)) { throw new Error("絶対パスを指定してください(例: C:/Users/Username/Documents/file.xlsx)"); } }

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