Skip to main content
Glama

update_spreadsheet_title_tool

Rename Google Spreadsheets by specifying the current name and new title. Quickly update spreadsheet titles for better organization and clarity.

Instructions

Update a Google Spreadsheet title.

Input Schema

NameRequiredDescriptionDefault
new_titleYesThe new title for the spreadsheet
spreadsheet_nameYesThe name of the spreadsheet to rename

Input Schema (JSON Schema)

{ "properties": { "new_title": { "description": "The new title for the spreadsheet", "title": "New Title", "type": "string" }, "spreadsheet_name": { "description": "The name of the spreadsheet to rename", "title": "Spreadsheet Name", "type": "string" } }, "required": [ "spreadsheet_name", "new_title" ], "title": "update_spreadsheet_title_toolArguments", "type": "object" }

Implementation Reference

  • Core handler function that finds the spreadsheet by name, performs the title update, handles errors, and returns structured JSON response.
    def update_spreadsheet_title_handler( drive_service, sheets_service, spreadsheet_name: str, new_title: str ) -> str: """Handler to update a spreadsheet title by name.""" spreadsheet_id = get_spreadsheet_id_by_name(drive_service, spreadsheet_name) if not spreadsheet_id: return compact_json_response({ "success": False, "message": f"Spreadsheet '{spreadsheet_name}' not found." }) try: update_spreadsheet_title(sheets_service, spreadsheet_id, new_title) return compact_json_response({ "success": True, "spreadsheet_name": spreadsheet_name, "new_title": new_title, "message": f"Successfully updated spreadsheet '{spreadsheet_name}' title to '{new_title}'" }) except Exception as e: return compact_json_response({ "success": False, "message": f"Error updating spreadsheet title: {str(e)}" })
  • Registers the 'update_spreadsheet_title_tool' with MCP server using @mcp.tool() decorator. Defines input schema via Pydantic Field descriptions and serves as entrypoint delegating to core handler.
    @mcp.tool() def update_spreadsheet_title_tool( spreadsheet_name: str = Field(..., description="The name of the spreadsheet to rename"), new_title: str = Field(..., description="The new title for the spreadsheet") ) -> str: """ Update a Google Spreadsheet title. """ sheets_service, drive_service = _get_google_services() return update_spreadsheet_title_handler(drive_service, sheets_service, spreadsheet_name, new_title)
  • Low-level helper function that executes the Google Sheets API batchUpdate request to change the spreadsheet's title property.
    def update_spreadsheet_title(sheets_service, spreadsheet_id: str, new_title: str) -> str: """Update a spreadsheet title by its ID.""" try: sheets_service.spreadsheets().batchUpdate( spreadsheetId=spreadsheet_id, body={ "requests": [ { "updateSpreadsheetProperties": { "properties": {"title": new_title}, "fields": "title" } } ] } ).execute() return f"Spreadsheet {spreadsheet_id} title updated to '{new_title}'" except HttpError as error: raise RuntimeError(f"Error updating spreadsheet title: {error}")
  • Pydantic Field definitions providing input schema validation and descriptions for the tool parameters.
    spreadsheet_name: str = Field(..., description="The name of the spreadsheet to rename"), new_title: str = Field(..., description="The new title for the spreadsheet") ) -> str: """ Update a Google Spreadsheet title. """ sheets_service, drive_service = _get_google_services() return update_spreadsheet_title_handler(drive_service, sheets_service, spreadsheet_name, new_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/henilcalagiya/google-sheets-mcp'

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