Skip to main content
Glama

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
NameRequiredDescriptionDefault
spreadsheetIdYesスプレッドシートのID
sheetNameYesシート名
valuesYes追加する行のデータ

Implementation Reference

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

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