read_sheet
Extract data from specific ranges in Google Sheets to access spreadsheet information for analysis or integration.
Instructions
スプレッドシートの指定された範囲のデータを読み取ります
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| spreadsheetId | Yes | スプレッドシートのID | |
| range | Yes | 読み取る範囲(例: 'Sheet1!A1:C10') |
Implementation Reference
- src/index.ts:200-217 (handler)The main handler function that executes the read_sheet tool by fetching the specified range of values from a Google Spreadsheet using the Google Sheets API v4 and returning the data as JSON.async function readSheet(spreadsheetId: string, range: string) { const authClient = await auth.getClient(); const sheets = google.sheets({ version: "v4", auth: authClient as any }); const response = await sheets.spreadsheets.values.get({ spreadsheetId, range, }); return { content: [ { type: "text", text: JSON.stringify(response.data.values || [], null, 2), }, ], }; }
- src/index.ts:38-55 (schema)The tool definition including name, description, and input schema for validating parameters spreadsheetId and range.{ name: "read_sheet", description: "スプレッドシートの指定された範囲のデータを読み取ります", inputSchema: { type: "object", properties: { spreadsheetId: { type: "string", description: "スプレッドシートのID", }, range: { type: "string", description: "読み取る範囲(例: 'Sheet1!A1:C10')", }, }, required: ["spreadsheetId", "range"], }, },
- src/index.ts:160-162 (registration)The dispatch case in the CallToolRequestSchema handler that registers and invokes the readSheet function for the 'read_sheet' tool.case "read_sheet": return await readSheet(args.spreadsheetId as string, args.range as string);