Skip to main content
Glama

get_workbook_metadata

Extract metadata from Excel workbooks, including sheet details and optional range information, using this tool to analyze and manage workbook structures efficiently.

Instructions

Get metadata about workbook including sheets, ranges, etc.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filepathYes
include_rangesNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • MCP tool handler function for get_workbook_metadata. Decorated with @mcp.tool() for registration and execution. Wraps get_workbook_info helper.
    @mcp.tool()
    def get_workbook_metadata(
        filepath: str,
        include_ranges: bool = False
    ) -> str:
        """Get metadata about workbook including sheets, ranges, etc."""
        try:
            full_path = get_excel_path(filepath)
            result = get_workbook_info(full_path, include_ranges=include_ranges)
            return str(result)
        except WorkbookError as e:
            return f"Error: {str(e)}"
        except Exception as e:
            logger.error(f"Error getting workbook metadata: {e}")
            raise
  • Core helper function that loads the workbook using openpyxl and extracts metadata: filename, sheets list, file size, modification time, and optional used ranges per sheet.
    def get_workbook_info(filepath: str, include_ranges: bool = False) -> dict[str, Any]:
        """Get metadata about workbook including sheets, ranges, etc."""
        try:
            path = Path(filepath)
            if not path.exists():
                raise WorkbookError(f"File not found: {filepath}")
                
            wb = load_workbook(filepath, read_only=False)
            
            info = {
                "filename": path.name,
                "sheets": wb.sheetnames,
                "size": path.stat().st_size,
                "modified": path.stat().st_mtime
            }
            
            if include_ranges:
                # Add used ranges for each sheet
                ranges = {}
                for sheet_name in wb.sheetnames:
                    ws = wb[sheet_name]
                    if ws.max_row > 0 and ws.max_column > 0:
                        ranges[sheet_name] = f"A1:{get_column_letter(ws.max_column)}{ws.max_row}"
                info["used_ranges"] = ranges
                
            wb.close()
            return info
            
        except WorkbookError as e:
            logger.error(str(e))
            raise
        except Exception as e:
            logger.error(f"Failed to get workbook info: {e}")
            raise WorkbookError(str(e))
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It states 'Get metadata' which implies a read-only operation, but doesn't disclose behavioral traits such as error handling (e.g., if filepath is invalid), performance considerations, or output format details. The description is minimal and lacks critical context for safe and effective use.

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 that front-loads the core purpose. There's no wasted verbiage, and it directly states the tool's function. However, it could be slightly more structured by explicitly mentioning parameters or usage context, but it earns high marks for brevity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's low complexity (2 parameters, no nested objects) and the presence of an output schema (which handles return values), the description is somewhat complete for basic understanding. However, with no annotations and 0% schema coverage, it lacks details on error handling, behavioral traits, and parameter meanings, making it only minimally adequate.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It mentions 'metadata about workbook including sheets, ranges, etc.', which hints at what the parameters might control but doesn't explain the two parameters (filepath and include_ranges) or their semantics. The description adds minimal value beyond the schema, failing to address the coverage gap adequately.

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

Purpose4/5

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

The description clearly states the verb 'Get' and the resource 'metadata about workbook', specifying it includes 'sheets, ranges, etc.' This distinguishes it from siblings like read_data_from_excel or get_merged_cells by focusing on metadata rather than data or specific features. However, it doesn't explicitly differentiate from all siblings (e.g., get_data_validation_info), so it's not a perfect 5.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., file existence), exclusions, or compare it to siblings like read_data_from_excel for data extraction or get_merged_cells for specific metadata. Usage is implied only by the tool name and description, lacking explicit context.

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/haris-musa/excel-mcp-server'

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