Skip to main content
Glama

get_merged_cells

Read-only

Retrieve all merged cell ranges from an Excel worksheet. Provide the file path and sheet name to get the merged cells.

Instructions

Get merged cells in a worksheet.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filepathYes
sheet_nameYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The MCP tool handler function 'get_merged_cells' - decorated with @mcp.tool, it takes filepath and sheet_name, calls get_merged_ranges(), and returns the result as a string.
    @mcp.tool(
        annotations=ToolAnnotations(
            title="Get Merged Cells",
            readOnlyHint=True,
        ),
    )
    def get_merged_cells(filepath: str, sheet_name: str) -> str:
        """Get merged cells in a worksheet."""
        try:
            full_path = get_excel_path(filepath)
            return str(get_merged_ranges(full_path, sheet_name))
        except (ValidationError, SheetError) as e:
            return f"Error: {str(e)}"
        except Exception as e:
            logger.error(f"Error getting merged cells: {e}")
            raise
  • The helper function 'get_merged_ranges' - loads the workbook, validates the sheet exists, and returns a list of merged cell range strings from worksheet.merged_cells.ranges.
    def get_merged_ranges(filepath: str, sheet_name: str) -> list[str]:
        """Get merged cells in a worksheet."""
        try:
            wb = load_workbook(filepath)
            if sheet_name not in wb.sheetnames:
                raise SheetError(f"Sheet '{sheet_name}' not found")
            worksheet = wb[sheet_name]
            return [str(merged_range) for merged_range in worksheet.merged_cells.ranges]
        except SheetError as e:
            logger.error(str(e))
            raise
        except Exception as e:
            logger.error(f"Failed to get merged cells: {e}")
            raise SheetError(str(e))
  • Tool registration via @mcp.tool decorator with annotations including title 'Get Merged Cells' and readOnlyHint=True.
    @mcp.tool(
        annotations=ToolAnnotations(
            title="Get Merged Cells",
            readOnlyHint=True,
        ),
    )
  • Function signature defines input schema: filepath: str and sheet_name: str; return type is str.
    def get_merged_cells(filepath: str, sheet_name: str) -> str:
Behavior2/5

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

The description does not add behavioral context beyond the 'readOnlyHint' annotation. It fails to mention return format, error handling, or performance considerations, missing an opportunity to enhance agent understanding.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence that directly conveys the tool's purpose. It is concise without any fluff, earning its place.

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?

For a simple read tool with 2 parameters and an output schema, the description is minimally sufficient. However, it lacks details on the returned data (e.g., ranges or addresses) and does not fully equip the agent to interpret results.

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?

With 0% schema description coverage, the description should clarify parameters but does not. The names 'filepath' and 'sheet_name' are somewhat self-explanatory, but no additional format or constraints are provided.

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

Purpose5/5

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

The description clearly states the action ('Get') and the resource ('merged cells in a worksheet'). It is distinct from sibling tools like 'merge_cells' and 'unmerge_cells', making the purpose unambiguous.

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, such as when to retrieve vs merge/unmerge cells. There are no context or prerequisite hints.

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