Skip to main content
Glama

sheets_delete_sheet

Remove unwanted sheets from a Google Sheets document by specifying the spreadsheet ID and sheet ID, streamlining document organization and management.

Instructions

Delete a sheet from a Google Sheets spreadsheet

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sheetIdYesThe ID of the sheet to delete (use sheets_get_metadata to find sheet IDs)
spreadsheetIdYesThe ID of the spreadsheet (found in the URL after /d/)

Implementation Reference

  • The handler function that validates input, authenticates with Google Sheets API, performs the batchUpdate to delete the specified sheet, formats the response, and handles errors.
    export async function handleDeleteSheet(input: any) {
      try {
        const validatedInput = validateDeleteSheetInput(input);
        const sheets = await getAuthenticatedClient();
    
        await sheets.spreadsheets.batchUpdate({
          spreadsheetId: validatedInput.spreadsheetId,
          requestBody: {
            requests: [
              {
                deleteSheet: {
                  sheetId: validatedInput.sheetId,
                },
              },
            ],
          },
        });
    
        return formatSheetOperationResponse('Sheet deleted', {
          sheetId: validatedInput.sheetId,
        });
      } catch (error) {
        return handleError(error);
      }
    }
  • The tool definition including name, description, and input schema for the sheets_delete_sheet tool.
    export const deleteSheetTool: Tool = {
      name: 'sheets_delete_sheet',
      description: 'Delete a sheet from a Google Sheets spreadsheet',
      inputSchema: {
        type: 'object',
        properties: {
          spreadsheetId: {
            type: 'string',
            description: 'The ID of the spreadsheet (found in the URL after /d/)',
          },
          sheetId: {
            type: 'number',
            description: 'The ID of the sheet to delete (use sheets_get_metadata to find sheet IDs)',
          },
        },
        required: ['spreadsheetId', 'sheetId'],
      },
    };
  • src/index.ts:32-64 (registration)
    Registration of tool handlers in a Map, including 'sheets_delete_sheet' mapped to tools.handleDeleteSheet for execution handling.
    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 tools in an array including deleteSheetTool 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 tool deletes a sheet, implying a destructive, irreversible mutation, but lacks details on permissions required, error handling (e.g., if sheetId is invalid), or confirmation prompts. This is inadequate for a mutation tool with zero annotation coverage, leaving critical behavioral traits unspecified.

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, direct sentence that front-loads the core action ('Delete a sheet') without unnecessary words. It efficiently communicates the purpose, making it easy to scan and understand, with no wasted verbiage or structural issues.

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 tool's complexity (a destructive mutation), lack of annotations, and no output schema, the description is incomplete. It fails to address critical aspects like what happens post-deletion (e.g., sheet removal, potential data loss), error conditions, or return values, leaving significant gaps for 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 schema description coverage is 100%, with clear descriptions for both parameters (sheetId and spreadsheetId), including usage tips (e.g., 'use sheets_get_metadata to find sheet IDs'). The description adds no additional parameter information beyond what the schema provides, so it meets the baseline of 3 without compensating or detracting.

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 ('Delete') and resource ('a sheet from a Google Sheets spreadsheet'), making the purpose immediately understandable. It distinguishes from siblings like 'sheets_insert_sheet' or 'sheets_duplicate_sheet' by specifying deletion rather than creation or copying. However, it doesn't explicitly differentiate from other destructive operations like 'sheets_clear_values' or 'sheets_unmerge_cells', which is why it's not a perfect 5.

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. It doesn't mention prerequisites (e.g., needing sheetId from 'sheets_get_metadata'), warn about irreversible deletion, or suggest alternatives like hiding sheets instead. Without such context, users might misuse it or overlook safer options.

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