append_row
Adds a new row to the end of a Google Sheets spreadsheet. Specify the spreadsheet ID, sheet name, and row values to insert data.
Instructions
スプレッドシートの最後に新しい行を追加します
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| spreadsheetId | Yes | スプレッドシートのID | |
| sheetName | Yes | シート名 | |
| values | Yes | 追加する行のデータ |
Implementation Reference
- src/index.ts:248-273 (handler)The main handler function for the 'append_row' tool. It authenticates with Google Sheets API and appends the provided values as a new row to the specified sheet using the spreadsheets.values.append method.async function appendRow( spreadsheetId: string, sheetName: string, values: string[] ) { const authClient = await auth.getClient(); const sheets = google.sheets({ version: "v4", auth: authClient as any }); const response = await sheets.spreadsheets.values.append({ spreadsheetId, range: `${sheetName}!A:Z`, valueInputOption: "RAW", requestBody: { values: [values], }, }); return { content: [ { type: "text", text: `行が正常に追加されました。更新されたセル数: ${response.data.updates?.updatedCells}`, }, ], }; }
- src/index.ts:84-107 (schema)The tool definition including name, description, and input schema for 'append_row' used for tool listing and validation.{ name: "append_row", description: "スプレッドシートの最後に新しい行を追加します", inputSchema: { type: "object", properties: { spreadsheetId: { type: "string", description: "スプレッドシートのID", }, sheetName: { type: "string", description: "シート名", }, values: { type: "array", items: { type: "string", }, description: "追加する行のデータ", }, }, required: ["spreadsheetId", "sheetName", "values"], },
- src/index.ts:170-175 (registration)The switch case in the CallToolRequestHandler that registers and dispatches to the appendRow handler when 'append_row' is called.case "append_row": return await appendRow( args.spreadsheetId as string, args.sheetName as string, args.values as string[] );