append_row
Add new rows to the end of Google Sheets spreadsheets programmatically to maintain updated data records and automate spreadsheet management tasks.
Instructions
スプレッドシートの最後に新しい行を追加します
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sheetName | Yes | シート名 | |
| spreadsheetId | Yes | スプレッドシートのID | |
| values | Yes | 追加する行のデータ |
Implementation Reference
- src/index.ts:248-273 (handler)The main handler function that executes the append_row tool by appending the provided values as a new row to the end of the specified sheet in the Google Spreadsheet using the Google Sheets API's 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:87-107 (schema)The input schema for the append_row tool, defining the required parameters: spreadsheetId (string), sheetName (string), and values (array of strings).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:84-108 (registration)The tool registration definition in the tools array returned by ListToolsRequestHandler, including name, description, and inputSchema.{ 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 dispatch case in the CallToolRequestHandler switch statement that routes 'append_row' calls to the appendRow handler function.case "append_row": return await appendRow( args.spreadsheetId as string, args.sheetName as string, args.values as string[] );