Skip to main content
Glama

get_cell_value

Retrieve specific cell values from an Excel file by providing the file path, sheet name, and cell location in A1 format.

Instructions

指定されたセルの値を取得します

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cellYesセル位置。A1形式で指定(例: A1, B2, AA10)
filePathYes対象のExcelファイルの絶対パス
sheetNameYes対象のワークシート名

Implementation Reference

  • Core handler function that validates the cell address, loads the Excel workbook using loadWorkbook, retrieves the specified worksheet, gets the cell value using ExcelJS, and returns the formatted result or throws an MCP error on failure.
    async function getCellValue(filePath: string, sheetName: string, cell: string): Promise<string> { try { validateCellAddress(cell); const workbook = await loadWorkbook(filePath); const worksheet = workbook.getWorksheet(sheetName); if (!worksheet) { throw new Error(`ワークシート '${sheetName}' が見つかりません。利用可能なシート: ${getSheetNames(workbook)}`); } const cellValue = worksheet.getCell(cell).value; return `セル ${cell} の値: ${cellValue}`; } catch (error) { throw new McpError(ErrorCode.InternalError, `セル値取得エラー: ${error}`); } }
  • Zod schema defining the input parameters for the get_cell_value tool: filePath (absolute path to Excel file), sheetName, and cell (A1-style address). Used for validation in tool calls.
    const GetCellValueSchema = z.object({ filePath: z.string().describe("対象のExcelファイルの絶対パス"), sheetName: z.string().describe("対象のワークシート名"), cell: z.string().describe("セル位置。A1形式で指定(例: A1, B2, AA10)"), });
  • src/index.ts:487-490 (registration)
    Tool registration in the ListToolsRequestSchema handler, specifying name, description, and inputSchema for discovery by MCP clients.
    name: "get_cell_value", description: "指定されたセルの値を取得します", inputSchema: zodToJsonSchema(GetCellValueSchema) },
  • MCP tool dispatcher wrapper that parses input arguments using the schema and delegates to the core getCellValue handler function.
    get_cell_value: async (args: any) => { const { filePath, sheetName, cell } = GetCellValueSchema.parse(args); return await getCellValue(filePath, sheetName, cell); },
  • Helper function to validate the cell address format using regex (A-Z+ followed by digits starting from 1), throws error on invalid format. Called by getCellValue.
    function validateCellAddress(cell: string): void { const cellPattern = /^[A-Z]+[1-9]\d*$/; if (!cellPattern.test(cell)) { throw new Error(`無効なセル位置: '${cell}'。正しい形式: A1, B2, AA10など`); } }

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