Skip to main content
Glama

sheets_get_values

Retrieve values from a specific range in a Google Sheets spreadsheet using the spreadsheet ID, range, and optional parameters for major dimension and value rendering.

Instructions

Get values from a specified range in a Google Sheets spreadsheet

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
majorDimensionNoThe major dimension of the values (default: ROWS)
rangeYesThe A1 notation range to retrieve (e.g., "Sheet1!A1:B10")
spreadsheetIdYesThe ID of the spreadsheet (found in the URL after /d/)
valueRenderOptionNoHow values should be represented (default: FORMATTED_VALUE)

Implementation Reference

  • The main handler function that executes the sheets_get_values tool. Validates input, authenticates client, calls Google Sheets API to get values from range, formats response, and handles errors.
    export async function handleGetValues(input: any) { try { const validatedInput = validateGetValuesInput(input); const sheets = await getAuthenticatedClient(); const response = await sheets.spreadsheets.values.get({ spreadsheetId: validatedInput.spreadsheetId, range: validatedInput.range, majorDimension: validatedInput.majorDimension, valueRenderOption: validatedInput.valueRenderOption, }); return formatValuesResponse(response.data.values || [], response.data.range); } catch (error) { return handleError(error); } }
  • Tool definition object including name, description, and inputSchema for parameter validation (spreadsheetId, range, majorDimension, valueRenderOption).
    export const getValuesTool: Tool = { name: 'sheets_get_values', description: 'Get values from a specified range in a Google Sheets spreadsheet', inputSchema: { type: 'object', properties: { spreadsheetId: { type: 'string', description: 'The ID of the spreadsheet (found in the URL after /d/)', }, range: { type: 'string', description: 'The A1 notation range to retrieve (e.g., "Sheet1!A1:B10")', }, majorDimension: { type: 'string', enum: ['ROWS', 'COLUMNS'], description: 'The major dimension of the values (default: ROWS)', }, valueRenderOption: { type: 'string', enum: ['FORMATTED_VALUE', 'UNFORMATTED_VALUE', 'FORMULA'], description: 'How values should be represented (default: FORMATTED_VALUE)', }, }, required: ['spreadsheetId', 'range'], }, };
  • src/index.ts:32-64 (registration)
    Registration of tool handlers in a Map, mapping 'sheets_get_values' to tools.handleGetValues for execution.
    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 tool definitions in the allTools array, including getValuesTool, used 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, ];

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