Skip to main content
Glama
marekrost

mcp-server-spreadsheet

add_sheet

Add a new sheet to a spreadsheet workbook, specifying name and position, with auto-generated options available.

Instructions

Add a new sheet to the workbook.

Returns the name of the newly created sheet. Not supported for CSV files.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fileYesPath to the spreadsheet file
nameNoName for the new sheet. Auto-generated if omitted.
positionNo1-based position to insert the sheet. Appended at the end if omitted.

Implementation Reference

  • The 'add_sheet' tool adds a new sheet to a workbook. It uses 'load_workbook' to load the file, 'wb.create_sheet' to add the sheet with a given title and index, and saves the changes.
    @mcp.tool()
    def add_sheet(
        file: Annotated[str, Field(description="Path to the spreadsheet file")],
        name: Annotated[str | None, Field(description="Name for the new sheet. Auto-generated if omitted.")] = None,
        position: Annotated[int | None, Field(description="1-based position to insert the sheet. Appended at the end if omitted.")] = None,
    ) -> str:
        """Add a new sheet to the workbook.
    
        Returns the name of the newly created sheet. Not supported for CSV files.
        """
        wb = load_workbook(file)
        ws = wb.create_sheet(title=name, index=position if position is None else position - 1)
        wb.save(file)
        return ws.title

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