get_workbook_info
Retrieve detailed information from an Excel workbook, including sheet lists and metadata, specified by file path using the MCP Server.
Instructions
Excelワークブックの詳細情報を取得します(シート一覧、メタデータ等)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filePath | Yes | 情報を取得するExcelファイルの絶対パス |
Implementation Reference
- src/index.ts:21-23 (schema)Zod schema for input validation of get_workbook_info tool (filePath parameter).const GetWorkbookInfoSchema = z.object({ filePath: z.string().describe("情報を取得するExcelファイルの絶対パス"), });
- src/index.ts:163-191 (handler)Core handler function that loads the Excel workbook using ExcelJS and returns detailed information including sheet count, names, creator, and dates.async function getWorkbookInfo(filePath: string): Promise<string> { try { validateFilePath(filePath); // ファイル存在確認 try { await fs.access(filePath); } catch { throw new Error(`ファイルが見つかりません: ${filePath}`); } const workbook = new ExcelJS.Workbook(); await workbook.xlsx.readFile(filePath); const info = { ファイルパス: filePath, ワークシート数: workbook.worksheets.length, ワークシート名一覧: workbook.worksheets.map(sheet => sheet.name), 作成者: workbook.creator || "不明", 最終更新者: workbook.lastModifiedBy || "不明", 作成日時: workbook.created ? workbook.created.toISOString() : "不明", 最終更新日時: workbook.modified ? workbook.modified.toISOString() : "不明" }; return `ワークブック情報:\n${JSON.stringify(info, null, 2)}`; } catch (error) { throw new McpError(ErrorCode.InternalError, `ワークブック情報取得エラー: ${error}`); } }
- src/index.ts:472-474 (registration)Registration of the tool in the list_tools handler, specifying name, description, and input schema.name: "get_workbook_info", description: "Excelワークブックの詳細情報を取得します(シート一覧、メタデータ等)", inputSchema: zodToJsonSchema(GetWorkbookInfoSchema)
- src/index.ts:531-533 (registration)Registration of the tool implementation in the toolImplementations map, which handles argument parsing and delegates to the core handler.get_workbook_info: async (args: any) => { const { filePath } = GetWorkbookInfoSchema.parse(args); return await getWorkbookInfo(filePath);