Skip to main content
Glama

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
NameRequiredDescriptionDefault
rangeYes
spreadsheetIdYes

Implementation Reference

  • 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); } }
  • 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'], }, };
  • 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,

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