Skip to main content
Glama

get_range_values

Extract specific data ranges from Excel sheets by specifying file path, sheet name, and range (e.g., A1:C10). Streamlines data retrieval for analysis or processing through the Excel MCP Server.

Instructions

指定された範囲のデータを取得します

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filePathYes対象のExcelファイルの絶対パス
rangeYes取得する範囲。A1:C3形式で指定(例: A1:C10, B2:D5)
sheetNameYes対象のワークシート名

Implementation Reference

  • Core handler function that validates the range, loads the Excel workbook and worksheet, parses the range boundaries, iterates over the cells to collect values into a 2D array, and returns a formatted JSON string of the values.
    async function getRangeValues(filePath: string, sheetName: string, range: string): Promise<string> {
      try {
        validateRangeAddress(range);
        
        const workbook = await loadWorkbook(filePath);
        const worksheet = workbook.getWorksheet(sheetName);
        if (!worksheet) {
          throw new Error(`ワークシート '${sheetName}' が見つかりません。利用可能なシート: ${getSheetNames(workbook)}`);
        }
        
        const rangeCells = worksheet.getCell(range);
        const values: any[][] = [];
        
        // 指定範囲のデータを取得する正しい実装
        const [startCell, endCell] = range.split(':');
        const startCellObj = worksheet.getCell(startCell);
        const endCellObj = worksheet.getCell(endCell);
        
        const startRow = Number(startCellObj.row);
        const startCol = Number(startCellObj.col);
        const endRow = Number(endCellObj.row);
        const endCol = Number(endCellObj.col);
        
        for (let row = startRow; row <= endRow; row++) {
          const rowValues: any[] = [];
          for (let col = startCol; col <= endCol; col++) {
            rowValues.push(worksheet.getCell(row, col).value);
          }
          values.push(rowValues);
        }
        
        return `範囲 ${range} の値:\n${JSON.stringify(values, null, 2)}`;
      } catch (error) {
        throw new McpError(ErrorCode.InternalError, `範囲値取得エラー: ${error}`);
      }
    }
  • Zod schema defining the input parameters for the get_range_values tool: filePath (absolute path to Excel file), sheetName (worksheet name), range (cell range like A1:C3).
    const GetRangeValuesSchema = z.object({
      filePath: z.string().describe("対象のExcelファイルの絶対パス"),
      sheetName: z.string().describe("対象のワークシート名"),
      range: z.string().describe("取得する範囲。A1:C3形式で指定(例: A1:C10, B2:D5)"),
    });
  • src/index.ts:551-554 (registration)
    Tool registration in the toolImplementations map: parses input arguments using the schema and delegates to the core getRangeValues handler function.
    get_range_values: async (args: any) => {
      const { filePath, sheetName, range } = GetRangeValuesSchema.parse(args);
      return await getRangeValues(filePath, sheetName, range);
    },
  • src/index.ts:496-500 (registration)
    Tool declaration in the list of available tools for ListToolsRequestSchema, including name, description, and JSON schema derived from Zod schema.
    {
      name: "get_range_values",
      description: "指定された範囲のデータを取得します",
      inputSchema: zodToJsonSchema(GetRangeValuesSchema)
    },
  • Helper function to validate the format of the range string (e.g., A1:C3) using a regex pattern. Called at the start of the handler.
    function validateRangeAddress(range: string): void {
      const rangePattern = /^[A-Z]+[1-9]\d*:[A-Z]+[1-9]\d*$/;
      if (!rangePattern.test(range)) {
        throw new Error(`無効な範囲指定: '${range}'。正しい形式: A1:C3, B2:D10など`);
      }
    }
Behavior2/5

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

With no annotations, the description carries full burden but only states it retrieves data. It doesn't disclose behavioral traits such as read-only nature (implied but not stated), error handling, performance, or output format. For a tool with 3 parameters and no annotations, this is a significant gap.

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 with no wasted words. It's appropriately sized and front-loaded, though it could be more informative. Every sentence earns its place, but it's under-specified rather than concise.

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 3 parameters, no annotations, and no output schema, the description is incomplete. It doesn't explain the Excel context, return values, or error conditions. For a data retrieval tool in a sibling-rich environment, more context is needed to be fully helpful.

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 fully documents parameters (filePath, range, sheetName). The description adds no meaning beyond what the schema provides, as it doesn't explain parameter interactions or usage examples. Baseline 3 is appropriate when schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description '指定された範囲のデータを取得します' (Retrieves data from a specified range) states the basic purpose with a verb (取得/retrieves) and resource (データ/data), but it's vague about the context (Excel files) and doesn't distinguish from siblings like get_cell_value or find_data. It's adequate but lacks specificity.

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?

No guidance is provided on when to use this tool versus alternatives. The description doesn't mention Excel context, prerequisites, or compare to siblings like get_cell_value (single cell) or find_data (search-based). Usage is implied but not explicit.

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