Skip to main content
Glama

get_workbook_metadata

Read-only

Retrieve workbook metadata, including sheets and ranges, to understand document structure.

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

  • Registration of the 'get_workbook_metadata' tool as an MCP tool via @mcp.tool decorator with ToolAnnotations including title and readOnlyHint=True.
    @mcp.tool(
        annotations=ToolAnnotations(
            title="Get Workbook Metadata",
            readOnlyHint=True,
        ),
    )
  • Handler function that resolves the filepath via get_excel_path(), calls get_workbook_info() and returns the result as a string. Catches WorkbookError and generic exceptions.
    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
  • Helper function get_workbook_info() that loads the workbook, collects metadata (filename, sheets, size, modified time), and optionally includes 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))
  • Input schema for the tool: filepath (str) and include_ranges (bool, default False). The return type is str.
    filepath: str,
    include_ranges: bool = False
  • WorkbookError exception class used by get_workbook_info and get_workbook_metadata for error handling.
    class WorkbookError(ExcelMCPError):
        """Raised when workbook operations fail."""
        pass
Behavior3/5

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

Annotations already declare readOnlyHint=true, so agent knows safety. Description adds metadata scope but doesn't elaborate on behavior like error handling or file requirements. No contradiction.

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?

Single sentence, efficient. However, 'etc.' adds vagueness without substance. Could be slightly improved.

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?

With output schema present, description needn't detail return values. However, it omits usage context and behavioral details beyond the annotations. Adequate for a simple tool but could specify what 'metadata' includes.

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

Parameters1/5

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

Both parameters lack schema descriptions (0% coverage). The description mentions 'sheets, ranges' but does not map these to filepath or include_ranges. No parameter semantics provided.

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?

Description clearly specifies a read operation ('Get') on a specific resource ('workbook metadata'), mentioning included elements ('sheets, ranges'). Differentiates from sibling mutation tools like create_workbook or write_data. The 'etc.' adds slight vagueness, but overall purpose is clear.

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 explicit guidance on when to use this tool vs alternatives. Lacks context like prerequisites (file existence) or comparison to read_data_from_excel. Implied usage only.

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

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