Skip to main content
Glama
adexltd
by adexltd

sheets_update_values

Modify data in a specified range of a Google Sheet by providing new values in a structured format.

Instructions

Update values in a Google Sheet range

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
spreadsheet_idYesID of the spreadsheet
rangeYesA1 notation range
valuesYes2D array of values

Implementation Reference

  • MCP tool handler for sheets_update_values. Parses input arguments, validates them, logs the operation, calls SheetsService.update_values, and returns the result.
    async def _handle_sheets_update_values( self, context: GoogleWorkspaceContext, arguments: dict ) -> Dict[str, Any]: """Handle sheets update values requests.""" spreadsheet_id = arguments.get("spreadsheet_id") range_name = arguments.get("range") values = arguments.get("values") if not spreadsheet_id or not range_name or values is None: raise ValueError("spreadsheet_id, range, and values are required") logger.debug(f"Updating sheet values - ID: {spreadsheet_id}, Range: {range_name}") result = await context.sheets.update_values( spreadsheet_id=spreadsheet_id, range_name=range_name, values=values ) logger.debug(f"Sheet values updated - Updated cells: {result.get('updatedCells', 0)}") return result
  • Input schema for the sheets_update_values tool, defining the required parameters: spreadsheet_id, range, and values (2D array).
    types.Tool( name="sheets_update_values", description="Update values in a Google Sheet range", inputSchema={ "type": "object", "properties": { "spreadsheet_id": { "type": "string", "description": "ID of the spreadsheet", }, "range": {"type": "string", "description": "A1 notation range"}, "values": { "type": "array", "items": {"type": "array", "items": {"type": "string"}}, "description": "2D array of values", }, }, "required": ["spreadsheet_id", "range", "values"], }, ),
  • Core implementation in SheetsService that performs the actual Google Sheets API update_values call, handling errors and formatting the request body.
    def update_values( self, spreadsheet_id: str, range_name: str, values: List[List[Any]], major_dimension: str = "ROWS", ) -> Dict[str, Any]: """Update values in a specific range of a spreadsheet.""" try: body = {"values": values, "majorDimension": major_dimension} result = ( self.service.spreadsheets() .values() .update( spreadsheetId=spreadsheet_id, range=range_name, valueInputOption="USER_ENTERED", body=body, ) .execute() ) return {"success": True, "result": result} except HttpError as error: return {"success": False, **self.handle_error(error)}

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/adexltd/mcp-google-suite'

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