Skip to main content
Glama
taylorwilsdon

Google Workspace MCP Server - Control Gmail, Calendar, Docs, Sheets, Slides, Chat, Forms & Drive

create_sheet

Add a new sheet to an existing Google Spreadsheet by specifying the user's email, spreadsheet ID, and desired sheet name. Returns a confirmation message upon successful creation.

Instructions

Creates a new sheet within an existing spreadsheet.

Args:
    user_google_email (str): The user's Google email address. Required.
    spreadsheet_id (str): The ID of the spreadsheet. Required.
    sheet_name (str): The name of the new sheet. Required.

Returns:
    str: Confirmation message of the successful sheet creation.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
serviceYes
sheet_nameYes
spreadsheet_idYes
user_google_emailYes

Implementation Reference

  • The handler function decorated with @server.tool() that implements the create_sheet tool. It uses the Google Sheets API to add a new sheet to an existing spreadsheet via batchUpdate request.
    @server.tool()
    @handle_http_errors("create_sheet", service_type="sheets")
    @require_google_service("sheets", "sheets_write")
    async def create_sheet(
        service,
        user_google_email: str,
        spreadsheet_id: str,
        sheet_name: str,
    ) -> str:
        """
        Creates a new sheet within an existing spreadsheet.
    
        Args:
            user_google_email (str): The user's Google email address. Required.
            spreadsheet_id (str): The ID of the spreadsheet. Required.
            sheet_name (str): The name of the new sheet. Required.
    
        Returns:
            str: Confirmation message of the successful sheet creation.
        """
        logger.info(f"[create_sheet] Invoked. Email: '{user_google_email}', Spreadsheet: {spreadsheet_id}, Sheet: {sheet_name}")
    
        request_body = {
            "requests": [
                {
                    "addSheet": {
                        "properties": {
                            "title": sheet_name
                        }
                    }
                }
            ]
        }
    
        response = await asyncio.to_thread(
            service.spreadsheets()
            .batchUpdate(spreadsheetId=spreadsheet_id, body=request_body)
            .execute
        )
    
        sheet_id = response["replies"][0]["addSheet"]["properties"]["sheetId"]
    
        text_output = (
            f"Successfully created sheet '{sheet_name}' (ID: {sheet_id}) in spreadsheet {spreadsheet_id} for {user_google_email}."
        )
    
        logger.info(f"Successfully created sheet for {user_google_email}. Sheet ID: {sheet_id}")
        return text_output
  • Exports the create_sheet tool function for use in the gsheets package, facilitating its availability and registration upon module import.
    from .sheets_tools import (
        list_spreadsheets,
        get_spreadsheet_info,
        read_sheet_values,
        modify_sheet_values,
        create_spreadsheet,
        create_sheet,
    )
    
    __all__ = [
        "list_spreadsheets",
        "get_spreadsheet_info", 
        "read_sheet_values",
        "modify_sheet_values",
        "create_spreadsheet",
        "create_sheet",
    ]

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/taylorwilsdon/google_workspace_mcp'

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