sheets_copy_to
Copy a specific sheet from one Google Sheets spreadsheet to another by specifying source and destination spreadsheet IDs and the sheet ID to transfer.
Instructions
Copy a sheet to another Google Sheets spreadsheet
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| destinationSpreadsheetId | Yes | The ID of the destination spreadsheet | |
| sheetId | Yes | The ID of the sheet to copy (use sheets_get_metadata to find sheet IDs) | |
| spreadsheetId | Yes | The ID of the source spreadsheet (found in the URL after /d/) |
Implementation Reference
- src/tools/copy-to.ts:30-50 (handler)The main execution logic for the sheets_copy_to tool: validates input, uses Google Sheets API to copy the sheet, formats success response, and handles errors.export async function handleCopyTo(input: any) { try { const validatedInput = validateCopyToInput(input); const sheets = await getAuthenticatedClient(); const response = await sheets.spreadsheets.sheets.copyTo({ spreadsheetId: validatedInput.spreadsheetId, sheetId: validatedInput.sheetId, requestBody: { destinationSpreadsheetId: validatedInput.destinationSpreadsheetId, }, }); return formatSheetOperationResponse('Sheet copied', { destinationSheetId: response.data.sheetId, title: response.data.title, }); } catch (error) { return handleError(error); } }
- src/tools/copy-to.ts:7-28 (schema)Input schema and metadata definition for the sheets_copy_to tool.export const copyToTool: Tool = { name: 'sheets_copy_to', description: 'Copy a sheet to another Google Sheets spreadsheet', inputSchema: { type: 'object', properties: { spreadsheetId: { type: 'string', description: 'The ID of the source spreadsheet (found in the URL after /d/)', }, sheetId: { type: 'number', description: 'The ID of the sheet to copy (use sheets_get_metadata to find sheet IDs)', }, destinationSpreadsheetId: { type: 'string', description: 'The ID of the destination spreadsheet', }, }, required: ['spreadsheetId', 'sheetId', 'destinationSpreadsheetId'], }, };
- src/index.ts:45-45 (registration)Maps the tool name 'sheets_copy_to' to its handler function in the central toolHandlers registry.['sheets_copy_to', tools.handleCopyTo],
- src/index.ts:80-80 (registration)Includes the copyToTool in the list of all tools returned by ListTools.tools.copyToTool,
- src/tools/index.ts:14-14 (registration)Re-exports the copyToTool and handleCopyTo from copy-to.ts for use in main index.export * from './copy-to.js';