Skip to main content
Glama

sheets_duplicate_sheet

Duplicate a sheet in Google Sheets by specifying the spreadsheet ID, sheet ID, insertion index, and new name. Streamline worksheet replication for organized data management.

Instructions

Duplicate a sheet within a Google Sheets spreadsheet

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
insertSheetIndexNoThe index where the new sheet should be inserted (0-based)
newSheetNameNoThe name for the duplicated sheet
sheetIdYesThe ID of the sheet to duplicate (use sheets_get_metadata to find sheet IDs)
spreadsheetIdYesThe ID of the spreadsheet (found in the URL after /d/)

Implementation Reference

  • The core handler function that executes the sheet duplication logic using Google Sheets API's batchUpdate with duplicateSheet request. It validates input, calls the API, extracts the new sheet properties, and returns a formatted response.
    export async function handleDuplicateSheet(input: any) {
      try {
        const validatedInput = validateDuplicateSheetInput(input);
        const sheets = await getAuthenticatedClient();
    
        const response = await sheets.spreadsheets.batchUpdate({
          spreadsheetId: validatedInput.spreadsheetId,
          requestBody: {
            requests: [
              {
                duplicateSheet: {
                  sourceSheetId: validatedInput.sheetId,
                  insertSheetIndex: validatedInput.insertSheetIndex,
                  newSheetName: validatedInput.newSheetName,
                },
              },
            ],
          },
        });
    
        const duplicatedSheet = response.data.replies?.[0]?.duplicateSheet
          ? response.data.replies[0].duplicateSheet.properties
          : undefined;
        return formatSheetOperationResponse('Sheet duplicated', {
          newSheetId: duplicatedSheet ? duplicatedSheet.sheetId : undefined,
          title: duplicatedSheet ? duplicatedSheet.title : undefined,
          index: duplicatedSheet ? duplicatedSheet.index : undefined,
        });
      } catch (error) {
        return handleError(error);
      }
    }
  • The Tool schema definition specifying the name, description, and inputSchema (including properties for spreadsheetId, sheetId, insertSheetIndex, newSheetName; required: spreadsheetId, sheetId).
    export const duplicateSheetTool: Tool = {
      name: 'sheets_duplicate_sheet',
      description: 'Duplicate a sheet within 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 duplicate (use sheets_get_metadata to find sheet IDs)',
          },
          insertSheetIndex: {
            type: 'number',
            description: 'The index where the new sheet should be inserted (0-based)',
          },
          newSheetName: {
            type: 'string',
            description: 'The name for the duplicated sheet',
          },
        },
        required: ['spreadsheetId', 'sheetId'],
      },
    };
  • src/index.ts:44-44 (registration)
    Registration of the 'sheets_duplicate_sheet' tool with its handler (tools.handleDuplicateSheet) in the central toolHandlers Map used for tool execution.
    ['sheets_duplicate_sheet', tools.handleDuplicateSheet],
  • src/index.ts:79-79 (registration)
    Inclusion of the duplicateSheetTool in the allTools array used for listing available tools via ListToolsRequest.
    tools.duplicateSheetTool,
  • Re-export of the duplicateSheetTool and handleDuplicateSheet from duplicate-sheet.ts, making them available as tools.* in src/index.ts.
    export * from './duplicate-sheet.js';
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 ('duplicate') but doesn't mention whether this is a mutation requiring write permissions, if it's reversible, what happens on failure, or any rate limits. This leaves significant gaps for a tool that modifies spreadsheet structure.

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 unnecessary words. It's front-loaded with the core action, making it easy to parse quickly.

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?

For a mutation tool with no annotations and no output schema, the description is inadequate. It doesn't explain what the tool returns, error conditions, or behavioral nuances like whether the duplication includes formatting or data. Given the complexity of duplicating sheets in Google Sheets, more context is needed.

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 four parameters. The description adds no additional parameter information beyond what's in the schema, such as explaining relationships between parameters or usage examples. 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 ('duplicate') and resource ('a sheet within a Google Sheets spreadsheet'), making the purpose immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'sheets_copy_to' or 'sheets_insert_sheet', which might have overlapping functionality, preventing 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 like 'sheets_copy_to' or 'sheets_insert_sheet'. It lacks context about prerequisites, such as needing sheet IDs from 'sheets_get_metadata', which is only hinted at in the schema, not in the description itself.

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