sheets_unmerge_cells
Unmerge cells in Google Sheets to separate merged data ranges, enhancing spreadsheet organization and data manipulation. Specify spreadsheet ID and range for targeted unmerging.
Instructions
Unmerge cells in a Google Sheet
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| range | Yes | ||
| spreadsheetId | Yes |
Implementation Reference
- src/tools/merge-cells.ts:79-111 (handler)The primary handler function that executes the sheets_unmerge_cells tool. It validates the input using Zod, authenticates the Google Sheets client, resolves the sheet ID, parses the range, and sends a batchUpdate request with the unmergeCells operation.export async function unmergeCellsHandler(input: any): Promise<ToolResponse> { try { const validatedInput = unmergeCellsInputSchema.parse(input) as UnmergeCellsInput; const sheets = await getAuthenticatedClient(); // Extract sheet name and get sheet ID const { sheetName, range: cleanRange } = extractSheetName(validatedInput.range); const sheetId = await getSheetId(sheets, validatedInput.spreadsheetId, sheetName); // Parse range to GridRange const gridRange = parseRange(cleanRange, sheetId); // Execute the unmerge const response = await sheets.spreadsheets.batchUpdate({ spreadsheetId: validatedInput.spreadsheetId, requestBody: { requests: [ { unmergeCells: { range: gridRange, }, }, ], }, }); return formatToolResponse(`Successfully unmerged cells in range ${validatedInput.range}`, { spreadsheetId: response.data.spreadsheetId, }); } catch (error) { return handleError(error); } }
- src/tools/merge-cells.ts:31-39 (schema)The Tool definition for sheets_unmerge_cells, including the inputSchema used for MCP tool listing and validation (spreadsheetId and range required).export const unmergeCellsTool: Tool = { name: 'sheets_unmerge_cells', description: 'Unmerge cells in a Google Sheet', inputSchema: { type: 'object', properties: unmergeCellsInputSchema.shape, required: ['spreadsheetId', 'range'], }, };
- src/tools/merge-cells.ts:16-19 (schema)Zod schema for input validation in the unmergeCellsHandler (spreadsheetId: string, range: string).const unmergeCellsInputSchema = z.object({ spreadsheetId: z.string(), range: z.string(), });
- src/index.ts:50-50 (registration)Registration of the unmergeCellsHandler in the toolHandlers Map for tool execution dispatching.['sheets_unmerge_cells', tools.unmergeCellsHandler],
- src/index.ts:85-85 (registration)Registration of the unmergeCellsTool in the allTools array for ListTools response.tools.unmergeCellsTool,