Skip to main content
Glama

create_sheet

Add a new sheet to a Google spreadsheet by specifying the user email, spreadsheet ID, and sheet name. Confirm successful creation with a message.

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
sheet_nameYes
spreadsheet_idYes
user_google_emailYes

Implementation Reference

  • The core handler function for the 'create_sheet' MCP tool. It uses the Google Sheets API to add a new sheet to an existing spreadsheet via batchUpdate request. Includes logging, error handling, and authentication decorators.
    @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
  • Registers and exposes the 'create_sheet' tool by importing it from sheets_tools.py and including it in __all__, making it available when the gsheets package is imported.
    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", ]

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

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