sheets_append_values
Add rows of data to a specified table in Google Sheets using a spreadsheet ID and A1 notation range. Choose how data is interpreted and inserted for precise control.
Instructions
Append values to the end of a table in a Google Sheets spreadsheet
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| insertDataOption | No | How the input data should be inserted (default: OVERWRITE) | |
| range | Yes | The A1 notation range of the table to append to (e.g., "Sheet1!A:B") | |
| spreadsheetId | Yes | The ID of the spreadsheet (found in the URL after /d/) | |
| valueInputOption | No | How the input data should be interpreted (default: USER_ENTERED) | |
| values | Yes | A 2D array of values to append, where each inner array represents a row |
Implementation Reference
- src/tools/append-values.ts:46-65 (handler)The main handler function that validates input, authenticates with Google Sheets API, appends values, formats the response, and handles errors.export async function handleAppendValues(input: any) { try { const validatedInput = validateAppendValuesInput(input); const sheets = await getAuthenticatedClient(); const response = await sheets.spreadsheets.values.append({ spreadsheetId: validatedInput.spreadsheetId, range: validatedInput.range, valueInputOption: validatedInput.valueInputOption, insertDataOption: validatedInput.insertDataOption, requestBody: { values: validatedInput.values, }, }); return formatAppendResponse(response.data.updates || {}); } catch (error) { return handleError(error); } }
- src/tools/append-values.ts:13-43 (schema)Input schema defining parameters for the sheets_append_values tool, including spreadsheetId, range, values, and optional formatting options.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 of the table to append to (e.g., "Sheet1!A:B")', }, values: { type: 'array', items: { type: 'array', }, description: 'A 2D array of values to append, where each inner array represents a row', }, valueInputOption: { type: 'string', enum: ['RAW', 'USER_ENTERED'], description: 'How the input data should be interpreted (default: USER_ENTERED)', }, insertDataOption: { type: 'string', enum: ['OVERWRITE', 'INSERT_ROWS'], description: 'How the input data should be inserted (default: OVERWRITE)', }, }, required: ['spreadsheetId', 'range', 'values'], },
- src/index.ts:39-39 (registration)Registers the handleAppendValues function as the executor for the 'sheets_append_values' tool in the toolHandlers Map.['sheets_append_values', tools.handleAppendValues],
- src/index.ts:74-74 (registration)Registers the appendValuesTool definition in the allTools array for listing available tools.tools.appendValuesTool,