Skip to main content
Glama
gworkspace-mcp
by ctschak

gworkspace-mcp

A Google Sheets and Docs MCP server with full API coverage, over stdio, acting as you.

The first-party Google MCP connectors can read an approximation of a file and cannot write to one. This server closes that gap: range reads including formulas, in-place cell writes, the whole Sheets structural surface, and index-safe editing of Google Docs.

Quickstart · Tools · Safety · Configuration · GCP setup: docs/setup-gcp.md · Design: docs/design.md · Known gaps: docs/open-tasks.md

Naming. The project was called gsheets-mcp before it gained Docs support. Environment variables (GSHEETS_*), the config directory (~/.config/gsheets-mcp/) and the Keychain service (gsheets-mcp) keep the old name so existing installs keep working.


Prerequisites

Need

Notes

Node.js 22+

node --version

A Google account

Personal Gmail or Workspace

A Google Cloud project you control

Free; used only to own the OAuth client. Walkthrough: docs/setup-gcp.md

An MCP client

Claude Code, Claude Desktop, or any stdio MCP client

Platform support

OS

Refresh-token storage

Login browser

Status

macOS

Keychain (service gsheets-mcp)

opens automatically

used daily

Linux

~/.config/gsheets-mcp/tokens/<email>.json, mode 0600

open the printed URL yourself

should work, not tested

Windows

same file store; POSIX file modes are not enforced

open the printed URL yourself

not tested


Related MCP server: Google Docs & Gmail MCP Server

Quickstart

1. Create an OAuth client (one time, ~10 minutes)

Follow docs/setup-gcp.md. In short: enable the Sheets, Docs and Drive APIs, set the consent screen to External, add the scopes, add yourself as a test user, create a Desktop app client, and save its JSON:

mkdir -p ~/.config/gsheets-mcp && chmod 700 ~/.config/gsheets-mcp
mv ~/Downloads/client_secret_*.json ~/.config/gsheets-mcp/client.json
chmod 600 ~/.config/gsheets-mcp/client.json

Or set GSHEETS_CLIENT_ID and GSHEETS_CLIENT_SECRET instead of the file.

2. Install and build

git clone https://github.com/ctschak/gworkspace-mcp.git
cd gworkspace-mcp
npm install
npm run build

3. Create a profile

A profile is a config/<name>.env file saying which account an instance acts as and what it may touch. It holds no credentials.

cp config/example.env config/work.env    # edit: GSHEETS_DEFAULT_ACCOUNT=you@example.com

Only config/example.env is tracked by git; every other *.env is ignored. Details and precedence: config/README.md. Profiles are optional — without one, the server uses the only (or default) authorised account.

4. Authorise

node dist/cli.js login --profile work    # browser consent, once per account
node dist/cli.js accounts                # confirm

Google shows "Google hasn't verified this app" — expected for your own unverified client. Choose Advanced → Go to … (unsafe) and grant.

5. Register with your MCP client

Claude Code — one instance per profile, so the account follows from the tool you reach for:

claude mcp add -s user gws-work -- node "$(pwd)/dist/index.js" --profile work

Claude Desktop / other stdio clients — add to the client's MCP config (Claude Desktop: claude_desktop_config.json), using an absolute path:

{
  "mcpServers": {
    "gws-work": {
      "command": "node",
      "args": ["/absolute/path/to/gworkspace-mcp/dist/index.js", "--profile", "work"]
    }
  }
}

Restart the client so it connects.

6. First call

Ask your agent to run sheets_describe (or docs_describe) on a spreadsheet (or document) URL you own. It returns the tabs and used ranges (or the outline) without any cell data.

A read-only profile for daily use and a read-write one enabled deliberately — GSHEETS_READ_ONLY=1 in the first, GSHEETS_ALLOWED_IDS in the second. See config/README.md.


Re-authorisation and token lifetime

Disclaimer — token lifetime is Google's policy, not this project's. The figures below are Google's published rules, checked against Google's OAuth 2.0 docs on 2026-11-29. Google can change them without notice, and observed lifetimes vary (tokens have been seen surviving past 7 days and dying sooner). Plan for re-authorisation at any time; do not build unattended automation on a user refresh token from a Testing app.

Why your client stays in Testing

Publishing an OAuth app to production requires a homepage and a privacy-policy URL on a domain you're authorised for, because spreadsheets is a sensitive scope. That's a poor trade for a local tool, so your client stays in Testing. Google's rule for that state: an External app in Testing is issued refresh tokens that expire in 7 days, unless it requests only openid / email / profile — this server also needs spreadsheets, documents and drive.file, so the rule applies.

When you will need to log in again

Scenario

What you see

Fix

7-day expiry (External + Testing app) — the common one

Google credentials for … have expired or been revoked

node dist/cli.js login --profile <name>

You revoked access at myaccount.google.com/permissions

same

same

Token unused for 6 months

same

same

More than 100 refresh tokens for one account on one OAuth client (e.g. logging in repeatedly, many machines) — Google silently invalidates the oldest

same, on the older machine/profile

log in again there; avoid needless re-logins

Workspace account: admin set a Google Cloud session length (can be 1–24 h)

same (Google's underlying subtype is invalid_rapt; the server shows the generic message)

log in again; ask the admin about session policy if it recurs

Workspace admin marks Sheets/Docs/Drive as Restricted

admin_policy_enforced at login or on calls

admin must allow the app; re-login won't help

Time-based access granted at consent has expired

expired or been revoked

log in again

A scope was added (e.g. GSHEETS_ENABLE_TITLE_SEARCH=1, or an upgrade that needs a new scope)

Google 403 insufficient authentication scopes

log in again — the new scope is requested at login

OAuth client deleted, recreated, or its secret reset

an OAuth client error at login or on calls (invalid_client / deleted_client / invalid_grant — Google's wording varies)

install the new client.json, log in again for every account

New machine, Keychain entry removed, or logout

no stored credentials for …

node dist/cli.js login --account <email>

Password changes do not revoke this server's tokens — per Google that applies only to tokens holding Gmail scopes, which this server never requests.

The expiry message always says "Expected roughly weekly": the server sees only invalid_grant and cannot tell which of the causes above fired. If re-authorising doesn't fix it, work down the table.

Which accounts are dead, and how to add a new account: the gworkspace-auth skill, usable by Claude Code or as a checklist.


Tools

Tool

Purpose

sheets_describe

Start here. Tabs with sheetId, index, allocated and used ranges, frozen panes, named ranges, protected ranges, chart and conditional-format counts. No cell data.

sheets_accounts

Authorised accounts, active default, granted scopes, write configuration.

sheets_read

Several A1 ranges in one call. valueRender: FORMATTED | UNFORMATTED | FORMULA. TSV by default, capped, reports nextRange when truncated.

sheets_inspect

Per-cell detail values cannot express: formulas, notes, data validation, effective formatting, hyperlinks.

sheets_write

Batch writes to A1 ranges. USER_ENTERED (default) parses like typing; RAW stores literal text.

sheets_append

Append rows below a table's last populated row.

sheets_clear

Clear values, retain formatting.

sheets_find_replace

Scoped find/replace, optional regex, returns occurrences changed.

sheets_create

New spreadsheet with tabs.

sheets_manage_tabs

Add, delete, duplicate, rename, reorder, hide/show, resize.

sheets_format

Number formats, fonts, colours, borders, alignment, wrapping, merges, freezes, column/row sizing.

sheets_data_tools

Data validation, conditional formatting, basic filters, sorting.

sheets_named_ranges

Named ranges; protected ranges.

sheets_batch_update_raw

Escape hatch. Literal Sheets v4 Request[] — charts, pivots, slicers, developer metadata, anything Google ships later.

Docs

Tool

Purpose

docs_describe

Start here. Outline without the full text: heading tree with index ranges, table positions, body length, named styles, tabs.

docs_read

Document text, sliceable by index range and capped. withIndices returns per-run boundaries.

docs_find

Locate exact text, return its index ranges. The safe way to get indices — measured now, not guessed, and matches spanning formatting boundaries are handled.

docs_insert

Insert at an index, at the end, or before/after existing text.

docs_replace_text

Find and replace. Carries no indices, so immune to drift — the safest way to change wording.

docs_delete

Delete index ranges.

docs_format

Text styling, links, paragraph named styles (headings), alignment, spacing, bullets.

docs_table

Insert a table, optionally populated.

docs_create

New document with optional initial text.

docs_batch_update_raw

Escape hatch. Literal Docs v1 Request[] — inline images, headers/footers, footnotes, bookmarks, positioned objects.

Docs indices shift under you

A document is one flat run of characters, addressed by absolute offset. Inserting 5 characters at index 10 invalidates every index after it — and within a single batchUpdate the requests apply in order, so request #2 sees a document you never measured.

Three defences, so this mostly does not need thinking about:

  1. Every batch is reordered back-to-front before sending, so an edit only disturbs text after itself. Stable, so same-index requests keep your order. The response says when reordering happened.

  2. docs_find measures indices immediately before use.

  3. docs_replace_text carries no indices at all. Prefer it for wording changes.

Never reuse an index across separate calls. Batch instead, or re-run docs_find.

Every mutating tool takes dryRun: true, which returns the exact request it would send plus an impact summary and sends nothing.

Workflow

sheets_describe first, always. It supplies the sheetIds that structural edits need and the used range that keeps a read from asking for A:ZZ and paying for empty cells.


Safety

Control

Effect

--read-only / GSHEETS_READ_ONLY=1

Registers only the 7 discovery and read tools: sheets_describe, sheets_accounts, sheets_read, sheets_inspect, docs_describe, docs_read, docs_find.

GSHEETS_ALLOWED_IDS

Comma-separated spreadsheet and document ids; writes to anything else are refused. Reads are unaffected.

dryRun: true

Returns the request instead of sending it.

~/.config/gsheets-mcp/audit.log

One JSON line per write: time, account, tool, file id, ranges, cell count.

Google's own version history is the undo mechanism. The audit log is how you find which revision.

What is stored where, and how to report a vulnerability: SECURITY.md.


Configuration

Set these in a config/<name>.env profile, or pass them with --env at registration. A real environment variable always wins over a profile file.

Variable

Effect

GSHEETS_PROFILE

Profile to load, same as --profile.

GSHEETS_CONFIG_DIR

Where profiles live. Defaults to config/ beside dist/.

GSHEETS_CLIENT_ID / GSHEETS_CLIENT_SECRET

OAuth client, instead of client.json.

GSHEETS_CLIENT_FILE

Alternative path to the client JSON.

GSHEETS_DEFAULT_ACCOUNT

Account to act as when a tool call does not name one.

GSHEETS_ALLOWED_IDS

Write allowlist.

GSHEETS_READ_ONLY=1

Same as --read-only.

GSHEETS_AUDIT_LOG

Alternative audit log path.

GSHEETS_FORCE_FILE_TOKENS=1

Skip the Keychain and use the 0600 file store.

GSHEETS_ENABLE_TITLE_SEARCH=1

Reserved: adds the drive.metadata.readonly scope at next login, but no tool uses it yet (open tasks). Off by default.

Scopes

Scope

Why

auth/spreadsheets

Read and write a spreadsheet whose id you already have

auth/documents

Read and write a document whose id you already have

openid, email

Identity only, no data access — returns the consenting account's email so credentials cannot be filed under the wrong account

auth/drive.file

Per-file, and reaches only files this OAuth client created. Present so the live test suite can delete its own scratch spreadsheets; it cannot list, read or touch anything else in your Drive

drive.readonly is not requested and never will be — it would grant read of every file you own to buy a filename lookup. Pass a spreadsheet URL or id, or use the Google Drive MCP to find one.

The Sheets, Docs and Drive APIs must all be enabled on the project that owns the OAuth client — its number is your client id's prefix. See docs/setup-gcp.md.


Development

npm run typecheck
npm run build               # tests run against dist/, so build first
npm test                    # unit, no network
node dist/cli.js profiles   # what is configured locally

Live smoke tests create a scratch spreadsheet, exercise every tool against it, and delete it. They never touch an existing spreadsheet, and run only when asked:

GSHEETS_LIVE_TEST=1 node --test test/live.test.js       # Sheets
GSHEETS_LIVE_TEST=1 node --test test/live-docs.test.js  # Docs

Both create a scratch file, exercise every tool against it, and delete it via drive.file.

No real spreadsheet ids or sheet content belong in this repo. Fixtures are synthetic.

Contributing: CONTRIBUTING.md. Agents working in this repo: CLAUDE.md.


License

MIT

Available Tools

24 tools
docs_batch_update_rawRaw Docs batchUpdateA

Send literal Docs API v1 Request objects. Covers the whole API, including inline images, headers and footers, footnotes, bookmarks and positioned objects, which the grouped tools do not wrap. Indices are document-wide and end-exclusive; requests are reordered back-to-front automatically. Use dryRun first.

Inputs: document (required), requests (required), tab, dryRun, +1 more.

docs_createCreate a documentB

Create a new Google Doc with a title and optional initial text. Returns its id and URL.

Inputs: title (required), text, dryRun, account.

docs_deleteDelete content rangesA

Delete index ranges, end-exclusive. Get the ranges from docs_find. Applied back-to-front. Supports dryRun.

Inputs: ranges (required), document (required), tab, dryRun, +1 more.

docs_describeDescribe a documentA

Outline of a Google Doc without its full text: title, heading tree with index ranges, table positions, body length, named styles, tabs. Call this first to see the shape of a document before reading or editing it.

Inputs: document (required), tab, account.

docs_findFind text and get its index rangesA

Locate exact text and return document index ranges for each match. This is the safe way to obtain indices for docs_format or docs_delete — they are measured now rather than guessed, and matches spanning formatting boundaries are handled. Indices are valid only until the next edit.

Inputs: text (required), document (required), tab, limit, +1 more.

docs_formatFormat text and paragraphsA

Bold/italic/underline, font, size, colours, links; paragraph named styles (headings), alignment, spacing; bullets and numbering. Uses a precise field mask, so styling you do not mention is left alone. Supports dryRun.

Inputs: document (required), operations (required), tab, dryRun, +1 more.

docs_insertInsert textA

Insert text at an index, at the end of the body, or before/after existing text. Several insertions are applied back-to-front in one batch so earlier ones cannot shift the indices later ones rely on. Supports dryRun.

Inputs: document (required), insertions (required), tab, dryRun, +1 more.

docs_readRead document textA

Plain text of a document, optionally sliced by index range and capped. Set withIndices to get per-run index boundaries for targeting edits.

Inputs: document (required), tab, account, endIndex, +3 more.

docs_replace_textReplace textA

Find and replace text throughout a document. Carries no indices, so it is immune to index drift and is the safest way to change wording. Supports dryRun.

Inputs: document (required), replacements (required), tab, dryRun, +1 more.

docs_tableInsert a tableB

Insert a table, optionally populating its cells. Populating costs a second round trip, because cell indices do not exist until the table does. Supports dryRun.

Inputs: rows (required), columns (required), document (required), tab, +4 more.

sheets_accountsList authorised accountsB

Google accounts this server can act as, the active default, granted scopes, and write configuration.

Inputs: no named parameters.

sheets_appendAppend rowsB

Append rows below the last populated row of a table. Supports dryRun.

Inputs: range (required), values (required), spreadsheet (required), dryRun, +3 more.

sheets_batch_update_rawRaw batchUpdateA

Send literal Sheets API v4 Request objects. Covers the entire API, including charts, pivot tables, slicers and developer metadata, which the grouped tools do not wrap. GridRange indices are zero-based and end-exclusive. Take sheetId values from sheets_describe, and run with dryRun first when the request shape is not obvious.

Inputs: requests (required), spreadsheet (required), dryRun, account, +1 more.

sheets_clearClear rangesB

Clear values from A1 ranges, leaving formatting intact. Supports dryRun.

Inputs: ranges (required), spreadsheet (required), dryRun, account.

sheets_createCreate a spreadsheetB

Create a new spreadsheet with the given title and tabs. Returns its id and URL.

Inputs: title (required), tabs, dryRun, account.

sheets_data_toolsValidation, conditional formatting, filters, sortingC

Data validation rules, conditional formatting, basic filters and range sorting. Supports dryRun.

Inputs: operations (required), spreadsheet (required), dryRun, account.

sheets_describeDescribe a spreadsheetA

Structure of a spreadsheet with no cell data: tabs with sheetId, index, allocated and USED ranges, frozen rows/columns, named ranges, protected ranges, and chart/conditional-format counts. Call this before any read or structural edit — the used range is what lets a read target A1:G412 instead of A:ZZ.

Inputs: spreadsheet (required), account, maxProbeCells, includeUsedRanges.

sheets_find_replaceFind and replaceA

Find and replace across a range, a tab, or every tab. Optional regex, case and whole-cell matching. Returns the number of occurrences changed. Supports dryRun.

Inputs: find (required), replacement (required), spreadsheet (required), range, +7 more.

sheets_formatFormat cellsB

Number formats, fonts, colours, borders, alignment, wrapping, merges, frozen panes, and column/row sizing. Uses a precise field mask, so formatting you do not mention is left alone. Supports dryRun.

Inputs: operations (required), spreadsheet (required), dryRun, account.

sheets_inspectInspect cell detailC

Per-cell detail values cannot express: formulas, notes, data validation rules, effective formatting, hyperlinks. Keep the range small — the payload per cell is large.

Inputs: range (required), spreadsheet (required), account, include.

sheets_manage_tabsManage tabsC

Add, delete, duplicate, rename, reorder, hide/show or resize tabs. Supports dryRun.

Inputs: operations (required), spreadsheet (required), dryRun, account.

sheets_named_rangesNamed and protected rangesB

Create, update and delete named ranges; protect and unprotect ranges or whole tabs. Supports dryRun.

Inputs: operations (required), spreadsheet (required), dryRun, account.

sheets_readRead rangesA

Read one or more A1 ranges in a single call. valueRender FORMULA returns formula text rather than results. Output is TSV by default and capped; a truncated range reports nextRange to continue from.

Inputs: ranges (required), spreadsheet (required), format, account, +3 more.

sheets_writeWrite cellsC

Write values to one or more A1 ranges in a single batch. valueInput USER_ENTERED (default) parses input as if typed, so formulas and dates work; RAW stores literal text. Supports dryRun.

Inputs: updates (required), spreadsheet (required), dryRun, account, +1 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.5/5.0

    Scored across 24 tools

    Disambiguation4/5

    Most tools target a clearly distinct resource+action, and the docs/sheets prefix plus explicit guidance (describe before read, find before format/delete) keeps selection predictable. The main soft spots are the catch-all groupings — sheets_data_tools vs sheets_format vs sheets_named_ranges, and sheets_write vs sheets_append vs the two *_batch_update_raw escape hatches — where an agent must read descriptions carefully to know which wrapper owns a given operation.

    Naming Consistency5/5

    Every tool follows the same snake_case prefix_action pattern (docs_*, sheets_*), with consistent verb placement and parallel operations across the two surfaces (describe/read/format/create/batch_update_raw). Minor outliers like sheets_accounts and sheets_data_tools are still readable and clearly namespaced.

    Tool Count4/5

    24 tools is on the heavy side but is defensible for two large Google APIs, with grouped wrappers and a raw escape hatch rather than one tool per API endpoint. A few grouped tools (sheets_data_tools, sheets_named_ranges) could plausibly be merged, so it is slightly over the ideal band rather than badly scoped.

    Completeness5/5

    Both domains have full lifecycle coverage: create/read/describe, insert/append/write, find, replace, delete/clear, format, and structural edits, plus *_batch_update_raw to reach anything unwrapped. No obvious dead ends for document or spreadsheet editing workflows.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers