Skip to main content
Glama

unmerge_cells

Unmerge cells in an Excel sheet to split merged data back into individual cells. Specify file path, sheet name, and cell range to process.

Instructions

Unmerge a range of cells.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
end_cellYes
filepathYes
sheet_nameYes
start_cellYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • MCP tool handler for unmerge_cells, decorated with @mcp.tool() for registration, which delegates to the unmerge_range helper.
    @mcp.tool()
    def unmerge_cells(filepath: str, sheet_name: str, start_cell: str, end_cell: str) -> str:
        """Unmerge a range of cells."""
        try:
            full_path = get_excel_path(filepath)
            result = unmerge_range(full_path, sheet_name, start_cell, end_cell)
            return result["message"]
        except (ValidationError, SheetError) as e:
            return f"Error: {str(e)}"
        except Exception as e:
            logger.error(f"Error unmerging cells: {e}")
            raise
  • Core helper function implementing the unmerge logic using openpyxl. Validates the range, checks if merged, calls worksheet.unmerge_cells, and saves the workbook.
    def unmerge_range(filepath: str, sheet_name: str, start_cell: str, end_cell: str) -> Dict[str, Any]:
        """Unmerge a range of cells."""
        try:
            wb = load_workbook(filepath)
            if sheet_name not in wb.sheetnames:
                raise SheetError(f"Sheet '{sheet_name}' not found")
                
            worksheet = wb[sheet_name]
            
            start_row, start_col, end_row, end_col = parse_cell_range(start_cell, end_cell)
            
            if end_row is None or end_col is None:
                raise SheetError("Both start and end cells must be specified for unmerging")
    
            range_string = format_range_string(start_row, start_col, end_row, end_col)
            
            # Check if range is actually merged
            merged_ranges = worksheet.merged_cells.ranges
            target_range = range_string.upper()
            
            if not any(str(merged_range).upper() == target_range for merged_range in merged_ranges):
                raise SheetError(f"Range '{range_string}' is not merged")
                
            worksheet.unmerge_cells(range_string)
            wb.save(filepath)
            return {"message": f"Range '{range_string}' unmerged successfully"}
        except SheetError as e:
            logger.error(str(e))
            raise
        except Exception as e:
            logger.error(f"Failed to unmerge range: {e}")
            raise SheetError(str(e))
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states the action but doesn't cover critical aspects: whether this is destructive (likely yes, as unmerging alters spreadsheet structure), permission requirements, error conditions (e.g., if cells aren't merged), or what happens to data in merged cells. The description is minimal and lacks operational context.

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 extremely concise—a single sentence with no wasted words. It's front-loaded with the core action, making it easy to parse quickly. Every word earns its place, though this conciseness comes at the cost of completeness.

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

Completeness2/5

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

Given the tool's complexity (a destructive operation on spreadsheets with 4 parameters), no annotations, and 0% schema coverage, the description is inadequate. While an output schema exists (which might help with return values), the description fails to address behavioral aspects, parameter meanings, or usage context, leaving major gaps for an agent to understand and invoke the tool correctly.

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 but adds no parameter information. It doesn't explain what 'start_cell' and 'end_cell' represent (e.g., cell references like 'A1:B2'), the format for 'filepath' and 'sheet_name', or how parameters interact to define the range. With 4 undocumented parameters, this is a significant gap.

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 action ('Unmerge') and resource ('a range of cells'), making the purpose immediately understandable. It distinguishes itself from siblings like 'merge_cells' by specifying the opposite operation. However, it doesn't explicitly mention the spreadsheet context, which is implied but could be more specific.

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. The description doesn't mention prerequisites (e.g., cells must be merged first), exclusions, or related tools like 'get_merged_cells' for checking merge status. Usage context is entirely absent beyond the basic action.

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