write_sheet
Write data to specified ranges in Google Sheets. Use this tool to update spreadsheet cells with new values programmatically.
Instructions
スプレッドシートの指定された範囲にデータを書き込みます
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| spreadsheetId | Yes | スプレッドシートのID | |
| range | Yes | 書き込む範囲(例: 'Sheet1!A1:C10') | |
| values | Yes | 書き込むデータ(2次元配列) |
Implementation Reference
- src/index.ts:220-245 (handler)The handler function that executes the write_sheet tool logic, using Google Sheets API to update values in the specified range.async function writeSheet( spreadsheetId: string, range: string, values: string[][] ) { const authClient = await auth.getClient(); const sheets = google.sheets({ version: "v4", auth: authClient as any }); const response = await sheets.spreadsheets.values.update({ spreadsheetId, range, valueInputOption: "RAW", requestBody: { values, }, }); return { content: [ { type: "text", text: `データが正常に書き込まれました。更新されたセル数: ${response.data.updatedCells}`, }, ], }; }
- src/index.ts:59-82 (schema)The input schema defining parameters for the write_sheet tool: spreadsheetId, range, and values (2D array).inputSchema: { type: "object", properties: { spreadsheetId: { type: "string", description: "スプレッドシートのID", }, range: { type: "string", description: "書き込む範囲(例: 'Sheet1!A1:C10')", }, values: { type: "array", items: { type: "array", items: { type: "string", }, }, description: "書き込むデータ(2次元配列)", }, }, required: ["spreadsheetId", "range", "values"], },
- src/index.ts:163-168 (registration)The switch case in the CallToolRequestSchema handler that registers and dispatches to the writeSheet function for write_sheet tool calls.case "write_sheet": return await writeSheet( args.spreadsheetId as string, args.range as string, args.values as string[][] );
- src/index.ts:56-83 (registration)The tool definition object in the tools array used for ListToolsRequestSchema, registering the write_sheet tool's name, description, and schema.{ name: "write_sheet", description: "スプレッドシートの指定された範囲にデータを書き込みます", inputSchema: { type: "object", properties: { spreadsheetId: { type: "string", description: "スプレッドシートのID", }, range: { type: "string", description: "書き込む範囲(例: 'Sheet1!A1:C10')", }, values: { type: "array", items: { type: "array", items: { type: "string", }, }, description: "書き込むデータ(2次元配列)", }, }, required: ["spreadsheetId", "range", "values"], }, },