Skip to main content
Glama
marekrost

mcp-server-spreadsheet

copy_sheet

Duplicate a sheet within the same spreadsheet workbook, copying all cell values to create a new sheet with an optional custom name and position.

Instructions

Duplicate a sheet within the same workbook.

Copies all cell values. Returns the name of the new sheet. Not supported for CSV files.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fileYesPath to the spreadsheet file
source_nameYesName of the existing sheet to duplicate
new_nameNoName for the copy. Auto-generated if omitted.
positionNo1-based position for the copied sheet. Placed at the end if omitted.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The MCP tool registration and handler function for `copy_sheet`. It takes the file path, source sheet name, and optional new name/position parameters, performs the copy via the backend, and saves the workbook.
    @mcp.tool()
    def copy_sheet(
        file: Annotated[str, Field(description="Path to the spreadsheet file")],
        source_name: Annotated[str, Field(description="Name of the existing sheet to duplicate")],
        new_name: Annotated[str | None, Field(description="Name for the copy. Auto-generated if omitted.")] = None,
        position: Annotated[int | None, Field(description="1-based position for the copied sheet. Placed at the end if omitted.")] = None,
    ) -> str:
        """Duplicate a sheet within the same workbook.
    
        Copies all cell values. Returns the name of the new sheet.
        Not supported for CSV files.
        """
        wb = load_workbook(file)
        copied = wb.copy_sheet(source_name)
        if new_name:
            copied.title = new_name
        if position is not None:
            current_idx = wb.sheetnames.index(copied.title)
            wb.move_sheet(copied, offset=position - 1 - current_idx)
        wb.save(file)
        return copied.title
    
    
    # ---------------------------------------------------------------------------
  • The backend implementation for copying a sheet in XLSX files using openpyxl's `copy_worksheet` method.
    def copy_sheet(self, source_name: str) -> XlsxSheet:
        if source_name not in self._wb.sheetnames:
            raise ValueError(f"Sheet not found: {source_name!r}")
        copied = self._wb.copy_worksheet(self._wb[source_name])
        return XlsxSheet(copied)
Behavior4/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 effectively describes key behaviors: the duplication operation, what gets copied ('all cell values'), return value ('Returns the name of the new sheet'), and a significant limitation ('Not supported for CSV files'). It doesn't mention error conditions, permissions needed, or whether the operation is reversible, but covers the essential behavioral traits for this tool.

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 perfectly concise with three short sentences that each earn their place: the core purpose, what gets copied, return value, and a critical limitation. It's front-loaded with the main functionality and wastes no words on redundant information.

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

Completeness4/5

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

Given that there's an output schema (which handles return value documentation) and 100% schema description coverage, the description provides good contextual completeness for a duplication tool. It covers the core operation, scope, return, and a key limitation. The main gap is lack of information about error conditions or permissions, but for a tool with good schema coverage and output schema, this is reasonably complete.

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

Parameters3/5

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

Schema description coverage is 100%, so the schema already documents all four parameters thoroughly. The description doesn't add any parameter-specific information beyond what's in the schema - it doesn't explain parameter interactions, provide examples, or clarify edge cases. The baseline of 3 is appropriate when the schema does the heavy lifting.

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 tool's purpose with specific verb ('Duplicate') and resource ('a sheet within the same workbook'), and distinguishes it from siblings like copy_workbook (which copies entire workbooks) and copy_range (which copies cell ranges). The phrase 'Copies all cell values' further clarifies the scope of duplication.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context for when to use this tool ('Duplicate a sheet within the same workbook') and includes one explicit exclusion ('Not supported for CSV files'). However, it doesn't mention when to use alternatives like copy_workbook for entire workbook duplication or rename_sheet for simple renaming, nor does it specify prerequisites like file format requirements beyond CSV exclusion.

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/marekrost/mcp-server-spreadsheet'

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