Skip to main content
Glama

read_excel_by_sheet_name

Extract data from a specific sheet in Excel files by specifying the sheet name. If no sheet name is provided, it defaults to reading the first sheet. Results are returned in structured JSON format.

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 logic that selects the Excel sheet by name (defaults to first sheet), reads all rows converting cell values to strings, and populates the result dictionary.
    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
  • Registration of the 'read_excel_by_sheet_name' tool in the MCP server's list_tools handler, including name, description, and input schema.
    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"] } ),
  • JSON Schema defining the input parameters for the tool: required 'file_path' string and optional 'sheet_name' string.
    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"] }

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

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