Skip to main content
Glama
softgridinc-pte-ltd

Excel Reader Server

read_excel_by_sheet_name

Extract data from a specific sheet in Excel files by specifying the sheet name. Reads the first sheet by default when no name is provided, returning structured JSON output.

Instructions

Read content from a specific sheet by name in Excel (xlsx) files. Reads first sheet if sheet_name not provided.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYesPath to the Excel file
sheet_nameNoName of the sheet to read (optional, defaults to first sheet)

Implementation Reference

  • Handler function logic for executing 'read_excel_by_sheet_name': selects sheet by name (defaults to first), reads all rows as list of lists with string values.
    elif name == "read_excel_by_sheet_name":
        # Get sheet by name, default to first sheet if not specified
        sheet_name = arguments.get("sheet_name")
        if not sheet_name:
            sheet_name = workbook.sheetnames[0]
        elif sheet_name not in workbook.sheetnames:
            raise ValueError(f"Sheet '{sheet_name}' not found in workbook")
            
        sheet = workbook[sheet_name]
        sheet_data = []
        
        for row in sheet.rows:
            row_data = [str(cell.value) if cell.value is not None else "" for cell in row]
            sheet_data.append(row_data)
        
        result[sheet_name] = sheet_data
  • Tool schema definition including input JSON schema for file_path (required) and optional sheet_name.
    types.Tool(
        name="read_excel_by_sheet_name",
        description="Read content from a specific sheet by name in Excel (xlsx) files. Reads first sheet if sheet_name not provided.",
        inputSchema={
            "type": "object",
            "properties": {
                "file_path": {
                    "type": "string",
                    "description": "Path to the Excel file"
                },
                "sheet_name": {
                    "type": "string",
                    "description": "Name of the sheet to read (optional, defaults to first sheet)"
                }
            },
            "required": ["file_path"]
        }
    ),
  • Tool name validation in the call_tool handler to recognize 'read_excel_by_sheet_name'.
    if name not in ["read_excel", "read_excel_by_sheet_name", "read_excel_by_sheet_index"]:

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/softgridinc-pte-ltd/mcp-excel-reader-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server