Skip to main content
Glama

rename_worksheet

Destructive

Rename a worksheet in an Excel workbook by specifying the file path, current sheet name, and new name.

Instructions

Rename worksheet in workbook.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filepathYes
old_nameYes
new_nameYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Registration of the 'rename_worksheet' tool as an MCP tool with FastMCP, including title 'Rename Worksheet' and destructiveHint=True annotation.
    @mcp.tool(
        annotations=ToolAnnotations(
            title="Rename Worksheet",
            destructiveHint=True,
        ),
    )
  • Tool handler for rename_worksheet: accepts filepath, old_name, new_name; calls get_excel_path for path resolution and rename_sheet from sheet.py for the actual renaming logic.
    def rename_worksheet(
        filepath: str,
        old_name: str,
        new_name: str
    ) -> str:
        """Rename worksheet in workbook."""
        try:
            full_path = get_excel_path(filepath)
            result = rename_sheet(full_path, old_name, new_name)
            return result["message"]
        except (ValidationError, SheetError) as e:
            return f"Error: {str(e)}"
        except Exception as e:
            logger.error(f"Error renaming worksheet: {e}")
            raise
  • Schema/type definition via function signature: filepath (str), old_name (str), new_name (str). Docstring: 'Rename worksheet in workbook.'
    def rename_worksheet(
        filepath: str,
        old_name: str,
        new_name: str
    ) -> str:
  • Helper function rename_sheet: loads workbook via openpyxl, validates old_name exists and new_name doesn't, renames the sheet via sheet.title = new_name, and saves.
    def rename_sheet(filepath: str, old_name: str, new_name: str) -> Dict[str, Any]:
        """Rename a worksheet."""
        try:
            wb = load_workbook(filepath)
            if old_name not in wb.sheetnames:
                raise SheetError(f"Sheet '{old_name}' not found")
                
            if new_name in wb.sheetnames:
                raise SheetError(f"Sheet '{new_name}' already exists")
                
            sheet = wb[old_name]
            sheet.title = new_name
            wb.save(filepath)
            return {"message": f"Sheet renamed from '{old_name}' to '{new_name}'"}
        except SheetError as e:
            logger.error(str(e))
            raise
        except Exception as e:
            logger.error(f"Failed to rename sheet: {e}")
            raise SheetError(str(e))
Behavior2/5

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

The annotations include destructiveHint=true, indicating a state change. The description adds no additional behavioral context beyond what the annotation already conveys, such as whether existing data is preserved or if permissions are required.

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 concise sentence that efficiently communicates the tool's purpose. It could be slightly expanded with parameter information without harming conciseness.

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 three required parameters and destructive nature, the description is too sparse. It omits important context like naming uniqueness, file existence requirements, and return value information, even though an output schema exists.

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 must compensate by explaining parameters. It does not describe filepath, old_name, or new_name beyond their names, which are self-explanatory but insufficient for clarifying format or constraints.

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 'rename' and the resource 'worksheet in workbook', making the tool's purpose obvious. However, it does not distinguish from sibling tools like 'copy_worksheet' or 'delete_worksheet', which are also worksheet-level operations.

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, nor any prerequisites or exclusions. The agent must infer usage solely from the tool's name and description.

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