Skip to main content
Glama

sheets_batch_update_values

Update multiple ranges in a Google Sheets spreadsheet with new values in one request. Specify spreadsheet ID, range-value pairs, and input interpretation (RAW or USER_ENTERED).

Instructions

Update values in multiple ranges of a Google Sheets spreadsheet

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dataYesArray of range-value pairs to update
spreadsheetIdYesThe ID of the spreadsheet (found in the URL after /d/)
valueInputOptionNoHow the input data should be interpreted (default: USER_ENTERED)

Implementation Reference

  • The main handler function that validates the input, calls the Google Sheets API to batch update values across multiple ranges, computes the total updated cells, and returns a formatted response.
    export async function handleBatchUpdateValues(input: any) {
      try {
        const validatedInput = validateBatchUpdateValuesInput(input);
        const sheets = await getAuthenticatedClient();
    
        const response = await sheets.spreadsheets.values.batchUpdate({
          spreadsheetId: validatedInput.spreadsheetId,
          requestBody: {
            valueInputOption: validatedInput.valueInputOption,
            data: validatedInput.data.map((item) => ({
              range: item.range,
              values: item.values,
            })),
          },
        });
    
        const totalUpdatedCells = response.data.responses
          ? response.data.responses.reduce(
              (sum: number, resp: any) => sum + (resp.updatedCells || 0),
              0
            )
          : 0;
    
        return formatUpdateResponse(totalUpdatedCells);
      } catch (error) {
        return handleError(error);
      }
    }
  • The Tool object defining the name, description, and input schema for validating parameters like spreadsheetId, data (array of range-value pairs), and optional valueInputOption.
    export const batchUpdateValuesTool: Tool = {
      name: 'sheets_batch_update_values',
      description: 'Update values in multiple ranges of a Google Sheets spreadsheet',
      inputSchema: {
        type: 'object',
        properties: {
          spreadsheetId: {
            type: 'string',
            description: 'The ID of the spreadsheet (found in the URL after /d/)',
          },
          data: {
            type: 'array',
            items: {
              type: 'object',
              properties: {
                range: {
                  type: 'string',
                  description: 'The A1 notation range to update',
                },
                values: {
                  type: 'array',
                  items: {
                    type: 'array',
                  },
                  description: 'A 2D array of values for this range',
                },
              },
              required: ['range', 'values'],
            },
            description: 'Array of range-value pairs to update',
          },
          valueInputOption: {
            type: 'string',
            enum: ['RAW', 'USER_ENTERED'],
            description: 'How the input data should be interpreted (default: USER_ENTERED)',
          },
        },
        required: ['spreadsheetId', 'data'],
      },
    };
  • src/index.ts:32-64 (registration)
    Registration of tool handlers in a Map, mapping 'sheets_batch_update_values' to its handleBatchUpdateValues function.
    const toolHandlers = new Map<string, (input: any) => Promise<any>>([
      ['sheets_check_access', tools.handleCheckAccess],
      ['sheets_get_values', tools.handleGetValues],
      ['sheets_batch_get_values', tools.handleBatchGetValues],
      ['sheets_get_metadata', tools.handleGetMetadata],
      ['sheets_update_values', tools.handleUpdateValues],
      ['sheets_batch_update_values', tools.handleBatchUpdateValues],
      ['sheets_append_values', tools.handleAppendValues],
      ['sheets_clear_values', tools.handleClearValues],
      ['sheets_create_spreadsheet', tools.handleCreateSpreadsheet],
      ['sheets_insert_sheet', tools.handleInsertSheet],
      ['sheets_delete_sheet', tools.handleDeleteSheet],
      ['sheets_duplicate_sheet', tools.handleDuplicateSheet],
      ['sheets_copy_to', tools.handleCopyTo],
      ['sheets_update_sheet_properties', tools.handleUpdateSheetProperties],
      ['sheets_format_cells', tools.formatCellsHandler],
      ['sheets_update_borders', tools.updateBordersHandler],
      ['sheets_merge_cells', tools.mergeCellsHandler],
      ['sheets_unmerge_cells', tools.unmergeCellsHandler],
      ['sheets_add_conditional_formatting', tools.addConditionalFormattingHandler],
      // Batch operations
      ['sheets_batch_delete_sheets', tools.handleBatchDeleteSheets],
      ['sheets_batch_format_cells', tools.handleBatchFormatCells],
      // Chart operations
      ['sheets_create_chart', tools.handleCreateChart],
      ['sheets_update_chart', tools.handleUpdateChart],
      ['sheets_delete_chart', tools.handleDeleteChart],
      // Link and date operations
      ['sheets_insert_link', tools.handleInsertLink],
      ['sheets_insert_date', tools.handleInsertDate],
      // Row operations
      ['sheets_insert_rows', tools.handleInsertRows],
    ]);
  • src/index.ts:67-99 (registration)
    Registration of all tool objects including batchUpdateValuesTool for the listTools request handler.
    const allTools = [
      tools.checkAccessTool,
      tools.getValuesTool,
      tools.batchGetValuesTool,
      tools.getMetadataTool,
      tools.updateValuesTool,
      tools.batchUpdateValuesTool,
      tools.appendValuesTool,
      tools.clearValuesTool,
      tools.createSpreadsheetTool,
      tools.insertSheetTool,
      tools.deleteSheetTool,
      tools.duplicateSheetTool,
      tools.copyToTool,
      tools.updateSheetPropertiesTool,
      tools.formatCellsTool,
      tools.updateBordersTool,
      tools.mergeCellsTool,
      tools.unmergeCellsTool,
      tools.addConditionalFormattingTool,
      // Batch operations
      tools.batchDeleteSheetsTool,
      tools.batchFormatCellsTool,
      // Chart operations
      tools.createChartTool,
      tools.updateChartTool,
      tools.deleteChartTool,
      // Link and date operations
      tools.insertLinkTool,
      tools.insertDateTool,
      // Row operations
      tools.insertRowsTool,
    ];
  • src/tools/index.ts:7-7 (registration)
    Re-export of the batch-update-values tool and handler from its module.
    export * from './batch-update-values.js';
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It states 'update values', implying a write/mutation operation, but does not disclose behavioral traits such as permission requirements, whether changes are reversible, rate limits, or error handling. This is inadequate for a mutation tool with zero annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero waste. It is appropriately sized and front-loaded, clearly stating the core functionality without unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given this is a mutation tool with no annotations and no output schema, the description is incomplete. It lacks details on behavioral aspects (e.g., permissions, side effects), output format, or error conditions, which are critical for safe and effective use by an AI agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents all parameters. The description adds no additional meaning beyond implying 'multiple ranges' (hinting at the 'data' array parameter), but does not explain parameter interactions or usage nuances. Baseline 3 is appropriate as the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'update' and resource 'values in multiple ranges of a Google Sheets spreadsheet', which is specific and unambiguous. However, it does not explicitly distinguish this tool from its sibling 'sheets_update_values', which appears to be a similar single-range update tool, missing full differentiation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'sheets_update_values' for single-range updates or 'sheets_append_values' for adding data. It lacks context on use cases, prerequisites, or exclusions, leaving the agent to infer usage from the name alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related 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/freema/mcp-gsheets'

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