Skip to main content
Glama

read_sheet

Extract data from specific ranges in Google Sheets to access spreadsheet information for analysis or integration.

Instructions

スプレッドシートの指定された範囲のデータを読み取ります

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
spreadsheetIdYesスプレッドシートのID
rangeYes読み取る範囲(例: 'Sheet1!A1:C10')

Implementation Reference

  • 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),
          },
        ],
      };
    }
  • 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);

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Kyohei-9841/google-spreadsheet-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server