google-sheets-readonly-mcp
# `google-sheets-readonly-mcp`
A lightweight, **strictly READ-ONLY** Model Context Protocol (MCP) server for reading Google Sheets from AI agents (**Antigravity**, **Claude Code**, **Claude Desktop**, Cursor, etc.).
Designed for teams and knowledge bases that enforce a **zero-write safety policy** on company spreadsheets.
## Why This Exists (3-Layer Read-Only Guarantee)
Most Google Sheets MCP servers request full read+write scopes and expose cell-editing tools. `google-sheets-readonly-mcp` enforces read-only access at **three independent layers**:
1. **OAuth Consent Layer:** Requests strictly one scope: `https://www.googleapis.com/auth/spreadsheets.readonly`.
2. **Token Verification Layer:** Refuses to run if `token.json` contains any non-readonly scope.
3. **Code & Transport Layer:** Only executes HTTP `GET` against allowlisted Google hosts (`sheets.googleapis.com` / `docs.google.com`) and exposes **only read tools** (`read_only_hint=True, destructive_hint=False`), plus built-in **PII cell warnings** (phones/emails) and **`?` hypothesis-cell highlighting**.
---
## Exposed Tools (4 Read-Only Tools)
| Tool | Auth Required | What It Does |
|---|---|---|
| `sheets_read_public_csv` | **None** *(view-only shared link)* | Reads a link-shared Google Sheet tab (`gid`) via HTTP GET CSV export; returns Markdown table, rows, PII cell warnings, and `?` cells. |
| `sheets_get_metadata` | OAuth `spreadsheets.readonly` | Lists spreadsheet title, locale, and all tab names & grid dimensions. |
| `sheets_read_tab` | OAuth `spreadsheets.readonly` | Reads any tab or A1 range from a private/shared Google Sheet as Markdown + rows + PII cell warnings. |
| `sheets_read_persona_matrix` | OAuth `spreadsheets.readonly` | Reads a structured matrix tab (e.g., qualitative Persona / research table) with `?` hypothesis extraction and PII warnings. |
---
## Installation
```bash
pip install git+https://github.com/taittag/google-sheets-readonly-mcp.git
```
Or install locally in editable mode:
```bash
git clone https://github.com/taittag/google-sheets-readonly-mcp.git
cd google-sheets-readonly-mcp
python3 -m venv .venv
.venv/bin/pip install -e ".[dev]"
.venv/bin/pytest -q
```
---
## Quick Setup
### Mode A — View-Only Shared Links (Zero OAuth)
Works immediately after installation via `sheets_read_public_csv`.
### Mode B — Private Google Sheets (One-Time OAuth `spreadsheets.readonly`, ~3 min)
1. In [Google Cloud Console](https://console.cloud.google.com/), enable **Google Sheets API**.
2. Configure **OAuth consent screen** (add scope `https://www.googleapis.com/auth/spreadsheets.readonly` and add your Google account under Test Users).
3. Create **Credentials → OAuth client ID → Desktop app** and download the JSON file.
4. Save it outside git with `0600` permissions:
```bash
mkdir -p ~/.config/google-sheets-readonly-mcp
mv ~/Downloads/client_secret_*.json ~/.config/google-sheets-readonly-mcp/credentials.json
chmod 600 ~/.config/google-sheets-readonly-mcp/credentials.json
```
5. Authorize once (opens browser, saves `token.json` at mode `0600`, auto-refreshes):
```bash
google-sheets-readonly-mcp --auth
google-sheets-readonly-mcp --status
```
---
## Agent Configuration
### Antigravity CLI (`~/.gemini/config/mcp_config.json`)
```json
{
"mcpServers": {
"google-sheets-readonly": {
"command": "/path/to/google-sheets-readonly-mcp/.venv/bin/google-sheets-readonly-mcp",
"args": []
}
}
}
```
### Claude Code (`.mcp.json` or `~/.claude.json`)
```json
{
"mcpServers": {
"google-sheets-readonly": {
"command": "/path/to/google-sheets-readonly-mcp/.venv/bin/google-sheets-readonly-mcp",
"args": []
}
}
}
```
*(Override credential directory via `GSHEETS_CONFIG_DIR`, `GSHEETS_CREDENTIALS_PATH`, or `GSHEETS_TOKEN_PATH`.)*
## License
MIT
TDQS
Scored across 4 tools
Each tool targets a distinct read path: metadata, generic tab/range, persona-matrix extraction, and public CSV export. The boundary between sheets_read_tab and sheets_read_persona_matrix is a bit soft (the latter is a specialized tab read), but descriptions make the difference clear.
All names use the sheets_ prefix with a verb_noun shape (sheets_read_tab, sheets_read_public_csv). The lone deviation is sheets_get_metadata using 'get' instead of 'read', which is a minor inconsistency rather than a confusing one.
Four tools is a sensible surface for a deliberately read-only Sheets server. No obvious padding, though the set is just shy of feeling thin since a couple of tools are narrowly scoped variants.
For a read-only scope, the surface covers the lifecycle: discover sheet structure (metadata), read arbitrary tabs/ranges, handle a specialized matrix format, and access link-shared sheets without OAuth. No write operations exist by design, so there are no true gaps for the stated purpose.