Skip to main content
Glama
Google Sheets Import and Export MCP Server

Google Sheets Import and Export MCP Server

Read or write a Google Sheet

google_sheets_import_export
Read-only

Read Google Sheets into rows or write, append, replace, and upsert rows using your own Google credentials, with execution handled on Apify.

Instructions

Read a Google Sheet into rows, or write rows into a Google Sheet. Modes: read (one row per sheet row, keyed by the header row), append, replace (clear the tab, then write), and upsert (update rows whose key_column value already exists, add the rest). Writes need the buyer's own Google credential: a service account key JSON with the sheet shared to its client_email, or an OAuth refresh token with its client, or an OAuth access token. A sheet shared as anyone with the link reads with no credential. Pay per event on Apify: 0.01 USD per block of up to 100 rows written, 0.005 USD per block of up to 100 rows read.

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "google_sheets_import_export"
  }
}

Input Schema

NameRequiredDescriptionDefault
modeNoread (default): the sheet becomes one dataset row per sheet row. append: add rows after the last row. replace: clear the tab, then write the rows. upsert: overwrite the rows whose key_column value is already in the sheet and add the rest. The three write modes need a credential below.
rowsNoWrite modes, instead of a dataset. A JSON list of objects, one per sheet row, for example [{"name": "Ann", "email": "ann@example.com"}].
rangeNoOptional, read mode. An A1 range without the tab name, for example A1:F500 or B:D. Default: the whole tab.
sheetNoOptional. The tab name, or its gid number. Default: the gid in the URL, else the first tab. In a write mode a tab name that does not exist is created.
columnsNoOptional, write modes. Only these keys are written, in this order. Default: every key in the rows, in first seen order.
max_rowsNoMost rows to read or write in this run, 1 to 1,000,000 (default 100,000).
dataset_idNoWrite modes. The Apify dataset whose items go into the sheet, for example the default dataset of another run. In an Apify integration, pass the triggering run's resource.defaultDatasetId variable. Fields starting with # are skipped.
header_rowNotrue (default) or false. When true, read rows are keyed by the header row, and writes match your row keys to the header columns and add new columns at the end. When false, read rows are keyed by column letter and writes go column by column in key order.
key_columnNoUpsert mode. The column whose value identifies a row, for example email or url. A row whose value is already in that column is overwritten in place; the rest are added. Rows with no value in it are skipped.
spreadsheetNoThe Google Sheets URL as copied from the browser, or the spreadsheet ID. A #gid= in the URL picks that tab.
value_inputNoraw (default): every value is stored exactly as given, so text starting with = is not run as a formula. user_entered: Google parses values as if typed, so formulas run and dates and numbers are converted.
max_charge_usdNoOptional. The run stops before a charge that would pass this amount, and never writes a block of rows it could not charge. Summary rows are always returned.
oauth_client_idNoThe client ID that issued the refresh token.
oauth_access_tokenNoInstead of the above: a current OAuth access token with the spreadsheets scope. It expires in about an hour, so it suits a single run.
oauth_client_secretNoThe client secret that issued the refresh token.
oauth_refresh_tokenNoInstead of a service account: a refresh token from your own Google OAuth client with the spreadsheets scope. Needs oauth_client_id and oauth_client_secret from the same client.
service_account_jsonNoYour own service account key file, pasted whole. Share the spreadsheet with its client_email as an Editor (Viewer to read). It is sent only to Google and is never stored, logged, or written to a row.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.2

TDQS

A3.5/5.0
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description states this tool writes, appends, replaces and upserts rows, and that replace 'clear[s] the tab' before writing, which directly contradicts the supplied annotations readOnlyHint=true and destructiveHint=false. Under the scoring rule an annotation contradiction caps this dimension at 1, even though the text otherwise adds genuinely useful context (credential options, per-event pricing, max_charge_usd cutoff, tab creation, and the promise that service_account_json is never stored or logged).

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with the core verb-resource statement, then modes, then prerequisites, then pricing in a compact four-sentence block with no filler. The mode sentence does repeat the mode enum almost verbatim from the schema, which is the main redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 17-parameter dual read/write tool with no output schema, the description covers the things an agent most needs: mode selection, credential acquisition, credential-free reads, destructive tab clearing, and cost per 100-row block with a max_charge_usd guard. What it omits is the return shape for read mode (dataset rows vs summary rows) and pagination/row-limit behaviour, which the schema only hints at via max_rows.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the baseline is 3; the schema already explains mode, rows, range, sheet, columns, header_row, key_column, value_input and every credential field in detail. The description adds a small amount beyond it by grouping the credential parameters into a prose rule (service account key, OAuth refresh token, or access token) and noting the link-shared no-credential path, but it mostly paraphrases the mode enum.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The opening sentence names two specific verbs and the exact resource ('Read a Google Sheet into rows, or write rows into a Google Sheet'), and the mode list (read/append/replace/upsert) makes the operation envelope unambiguous. An agent knows precisely what the tool does before reading the schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Each mode is given a condition that selects it ('append: add rows after the last row', 'replace: clear the tab, then write', 'upsert: update rows whose key_column value already exists'), and the credential rule is stated with an explicit exception ('a sheet shared as anyone with the link reads with no credential'). It stops short of when-not-to-use guidance such as limits, quota behaviour, or when to prefer passing rows vs a dataset, so it is not a 5.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools