Skip to main content
Glama

sheets_clear_values

Clear specified ranges of data in Google Sheets by defining the spreadsheet ID and A1 notation range. Simplify data management and maintain clean spreadsheets.

Instructions

Clear values in a specified range of a Google Sheets spreadsheet

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
rangeYesThe A1 notation range to clear (e.g., "Sheet1!A1:B10")
spreadsheetIdYesThe ID of the spreadsheet (found in the URL after /d/)

Implementation Reference

  • The main handler function for the 'sheets_clear_values' tool. It validates the input, authenticates with Google Sheets API, clears the specified range, and returns a formatted response or handles errors.
    export async function handleClearValues(input: any) {
      try {
        const validatedInput = validateClearValuesInput(input);
        const sheets = await getAuthenticatedClient();
    
        const response = await sheets.spreadsheets.values.clear({
          spreadsheetId: validatedInput.spreadsheetId,
          range: validatedInput.range,
        });
    
        return formatClearResponse(response.data.clearedRange || validatedInput.range);
      } catch (error) {
        return handleError(error);
      }
    }
  • Tool definition including the input schema for 'sheets_clear_values', specifying required spreadsheetId and range parameters.
    export const clearValuesTool: Tool = {
      name: 'sheets_clear_values',
      description: 'Clear values in a specified range of a Google Sheets spreadsheet',
      inputSchema: {
        type: 'object',
        properties: {
          spreadsheetId: {
            type: 'string',
            description: 'The ID of the spreadsheet (found in the URL after /d/)',
          },
          range: {
            type: 'string',
            description: 'The A1 notation range to clear (e.g., "Sheet1!A1:B10")',
          },
        },
        required: ['spreadsheetId', 'range'],
      },
    };
  • src/index.ts:32-64 (registration)
    Registration of the tool handler in the central toolHandlers Map used by the MCP server to dispatch tool calls.
    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-98 (registration)
    Registration of the tool definition in the allTools array used for listing available tools.
    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,
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the action is to 'clear values,' which implies a mutation operation, but does not specify whether this requires specific permissions, if it's reversible, what happens to formatting or formulas in the range, or any rate limits. This leaves significant gaps in understanding the tool's behavior.

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 that directly states the tool's purpose without any redundant words. It is front-loaded with the core action and resource, making it easy to parse quickly. Every part of the sentence earns its place by conveying essential information.

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 the complexity of a mutation tool with no annotations and no output schema, the description is insufficiently complete. It does not address key aspects like what 'clear values' entails (e.g., does it remove formulas, leave formatting intact?), error conditions, or return values. For a tool that modifies data, more contextual detail is needed to guide safe and effective use.

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?

The input schema has 100% description coverage, clearly documenting both parameters ('range' and 'spreadsheetId') with examples and types. The description does not add any additional semantic information beyond what the schema provides, such as explaining edge cases or interactions between parameters. This meets the baseline for high schema coverage.

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 action ('Clear values') and resource ('in a specified range of a Google Sheets spreadsheet'), making the purpose immediately understandable. However, it does not explicitly differentiate from sibling tools like 'sheets_delete_sheet' or 'sheets_unmerge_cells', which might also involve clearing content in different ways, so it falls short of a perfect score.

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. For example, it does not mention when to choose 'sheets_clear_values' over 'sheets_delete_sheet' for removing content, or whether it's suitable for clearing formulas versus data. This lack of context leaves the agent with minimal usage direction.

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