Skip to main content

Read-only Google Sheets MCP server with ADC auth for Cascade, Cursor, Copilot, Claude, and other MCP clients

Project description

๐Ÿ“„ Google Sheets MCP

g-sheet-mcp is a read-only Model Context Protocol (MCP) server that gives AI assistants (Claude, Cursor, Copilot, Cascade, and other MCP clients) direct access to Google Sheets data โ€” authenticated via Application Default Credentials (ADC).

No service account JSON. No hardcoded secrets. One command to authenticate, works everywhere.

Repo: google-sheets-mcp ยท PyPI ยท CLI/package: g-sheet-mcp ยท Python import: g_sheet_mcp

All examples in this repo are generic and sanitized for public release.


โœจ Features

MCP Tool Description
get_spreadsheet_info Title, locale, timezone, and all sheet tab metadata
list_sheets List every worksheet tab with row/column dimensions
read_range Read an A1-notation range (e.g. 'Sheet1'!A1:D10)
read_sheet Read an entire worksheet by tab name (spaces in name handled automatically)
read_sheet_as_records Best for LLMs โ€” returns rows as [{"col": val, ...}] dicts
get_cell Read a single cell by 1-based row/column index
find_in_spreadsheet Substring search across all cells (with optional sheet filter)
batch_read_ranges Read multiple ranges in one API call

Both full Google Sheets URLs and bare spreadsheet IDs are accepted by all tools.
Sheet names with spaces (e.g. Example Sheet 1) are quoted automatically.


๐Ÿš€ Installation

Prerequisites

# Python 3.11+ and uv
brew install uv                  # macOS
# or: curl -LsSf https://astral.sh/uv/install.sh | sh

# Google Cloud SDK
brew install google-cloud-sdk
# or: https://cloud.google.com/sdk/docs/install

Step 1 โ€” โœจ Recommended: Install from PyPI (uvx g-sheet-mcp)

This is the recommended setup for most users now that the package is published on PyPI.

uvx g-sheet-mcp

# Optional: pin an exact release
uvx --from g-sheet-mcp==0.1.2 g-sheet-mcp

# Optional persistent install
pipx install g-sheet-mcp

Use one of the alternatives below only if you need unreleased changes or want to work on the repository itself.

Other setup options

GitHub (uvx --from git+...)

uvx --from git+https://github.com/mariadb-RupeshBiswas/google-sheets-mcp g-sheet-mcp

Local path (uvx --from /absolute/path/...)

uvx --from /absolute/path/to/google-sheets-mcp g-sheet-mcp

Local clone (uv sync)

git clone https://github.com/mariadb-RupeshBiswas/google-sheets-mcp.git
cd google-sheets-mcp
uv sync

See Publishing guide for release details.

Step 2 โ€” Authenticate (once)

gcloud auth login --enable-gdrive-access --update-adc

This writes ~/.config/gcloud/application_default_credentials.json. The server picks it up automatically on every subsequent run โ€” including auto-detection if it is missing. If you re-run gcloud auth login later, the running server reloads the updated ADC file on the next request, so you usually do not need to restart your editor.

Step 3 โ€” Run the server

uvx g-sheet-mcp          # stdio mode (recommended for MCP clients)
uvx g-sheet-mcp --http   # HTTP mode โ†’ http://127.0.0.1:8000/mcp
uvx g-sheet-mcp --debug  # verbose logging

# If you are working from a local clone instead:
uv run g-sheet-mcp

๐Ÿ“š Documentation


๐Ÿงฉ Editor Integration

Full step-by-step guides โ†’ Editor Setup

Quick JSON snippets below use the recommended published PyPI / uvx setup. GitHub and local development variants for every editor are in the full editor guide.

Windsurf โ€” ~/.codeium/windsurf/mcp_config.json

{
  "mcpServers": {
    "google-sheets": {
      "command": "uvx",
      "args": ["g-sheet-mcp"]
    }
  }
}

Cursor โ€” ~/.cursor/mcp.json

{
  "mcpServers": {
    "google-sheets": {
      "command": "uvx",
      "args": ["g-sheet-mcp"]
    }
  }
}

Claude Desktop

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "google-sheets": {
      "command": "uvx",
      "args": ["g-sheet-mcp"]
    }
  }
}

VS Code + GitHub Copilot โ€” ~/.vscode/mcp.json

{
  "servers": {
    "google-sheets": {
      "type": "stdio",
      "command": "uvx",
      "args": ["g-sheet-mcp"]
    }
  }
}

Zed โ€” ~/.config/zed/settings.json

{
  "context_servers": {
    "google-sheets": {
      "command": {
        "path": "uvx",
        "args": ["g-sheet-mcp"]
      }
    }
  }
}

Claude Code (CLI)

claude mcp add --transport stdio google-sheets -- \
  uvx g-sheet-mcp

Example Prompts

Once connected to any editor:

List all sheet tabs in https://docs.google.com/spreadsheets/d/YOUR_ID/edit
Read 'Example Sheet 1' from that spreadsheet as records and show me the first 5 rows
Find all cells containing "invoice" in the spreadsheet
Read columns A through D from every tab in that spreadsheet

๐Ÿงฐ Available MCP Tools โ€” Reference

get_spreadsheet_info

spreadsheet_id_or_url: str       # Full URL or bare spreadsheet ID
โ†’ { spreadsheet_id, title, locale, time_zone, sheets: [SheetProperties, ...] }

list_sheets

spreadsheet_id_or_url: str
โ†’ [{ sheet_id, title, index, sheet_type, row_count, column_count }, ...]

read_range

spreadsheet_id_or_url: str
range_notation: str              # e.g. "'Sheet1'!A1:D10" or "A1:D10"
value_render_option: str         # FORMATTED_VALUE* | UNFORMATTED_VALUE | FORMULA
โ†’ { sheet_title, range_notation, row_count, column_count, values: [[...], ...] }

read_sheet

spreadsheet_id_or_url: str
sheet_title: str                 # Exact tab name (spaces OK โ€” quoted automatically)
value_render_option: str
โ†’ same as read_range

read_sheet_as_records โ˜… LLM-friendly

spreadsheet_id_or_url: str
sheet_title: str                 # First row is used as column headers
value_render_option: str
max_rows: int                    # Safety cap, default 1000
โ†’ [{"col_a": val, "col_b": val, ...}, ...]  โ€” missing cells โ†’ null

get_cell

spreadsheet_id_or_url: str
sheet_title: str
row: int                         # 1-based row (row 1 = first row)
column: int                      # 1-based column (1=A, 2=B, ...)
value_render_option: str
โ†’ { row, column, a1_notation, value }

find_in_spreadsheet

spreadsheet_id_or_url: str
query: str                       # Non-empty search string
sheet_title: str                 # "" = search all sheets
case_sensitive: bool             # default False
max_results: int                 # default 50, capped at 500
โ†’ [{ sheet_title, row, column, a1_notation, matched_value }, ...]

batch_read_ranges

spreadsheet_id_or_url: str
ranges: list[str]                # e.g. ["'Sheet1'!A1:B5", "'Sheet2'!C1:C10"]
value_render_option: str
โ†’ [RangeData, ...]               โ€” same order as input ranges

๐Ÿ›  Development

uv sync --extra dev              # install with dev deps
uv lock                          # refresh lockfile if dependencies change

uv run pytest tests/ --ignore=tests/test_integration.py       # unit tests (74 tests)
INTEGRATION=1 TEST_SPREADSHEET_ID=your_test_spreadsheet_id uv run pytest tests/test_integration.py -v -s

uv run ruff check src tests      # lint
uv run mypy src                  # type check

uv run mcp dev src/g_sheet_mcp/server.py   # MCP Inspector (interactive)

๐Ÿ” Authentication

gcloud auth login --enable-gdrive-access --update-adc
โ†’ ~/.config/gcloud/application_default_credentials.json

Required scopes (set automatically by --enable-gdrive-access):

  • spreadsheets.readonly
  • drive.readonly

The server auto-detects missing credentials and triggers the browser auth flow. If credentials are refreshed while the server is already running, the next request reloads the ADC file automatically. Full details โ†’ Authentication guide


๐Ÿ—‚ Project structure

google-sheets-mcp/
โ”œโ”€โ”€ src/g_sheet_mcp/
โ”‚   โ”œโ”€โ”€ auth.py        # ADC credential loading + auto-auth flow
โ”‚   โ”œโ”€โ”€ models.py      # Pydantic models for all API responses
โ”‚   โ”œโ”€โ”€ sheets.py      # Google Sheets API v4 wrapper (SheetsClient)
โ”‚   โ””โ”€โ”€ server.py      # FastMCP server โ€” 8 tools + 1 resource
โ”œโ”€โ”€ tests/
โ”‚   โ”œโ”€โ”€ conftest.py         # Shared fixtures + mock API responses
โ”‚   โ”œโ”€โ”€ test_auth.py        # Auth unit tests
โ”‚   โ”œโ”€โ”€ test_sheets.py      # Sheets client unit tests
โ”‚   โ”œโ”€โ”€ test_server.py      # MCP tool unit tests
โ”‚   โ””โ”€โ”€ test_integration.py # Live API tests (INTEGRATION=1)
โ”œโ”€โ”€ docs/
โ”‚   โ”œโ”€โ”€ QUICKSTART.md       # 5-minute setup guide
โ”‚   โ”œโ”€โ”€ EDITOR_SETUP.md     # Per-editor integration (Windsurf, Cursor, VS Code, Zedโ€ฆ)
โ”‚   โ”œโ”€โ”€ AUTH.md             # Authentication deep-dive
โ”‚   โ””โ”€โ”€ TROUBLESHOOTING.md  # Common errors and fixes
โ”œโ”€โ”€ mcp-config-examples/    # Ready-to-use config files per editor
โ”œโ”€โ”€ agents/                 # LLM instruction files
โ””โ”€โ”€ pyproject.toml

๐Ÿงฏ Troubleshooting

Error Fix
AuthError: No Application Default Credentials found Run gcloud auth login --enable-gdrive-access --update-adc
AuthError: Could not refresh credentials Re-run gcloud auth login --enable-gdrive-access --update-adc, then retry the request
PermissionError: Access denied Share the spreadsheet with your Google account (Viewer)
FileNotFoundError: Spreadsheet not found Check the spreadsheet ID/URL
403 insufficient permissions Re-run gcloud auth login โ€” old ADC may lack Drive scope
RuntimeError: rate limit exceeded Wait 30s and retry
LookupError: Sheet '...' not found Call list_sheets first to see exact tab names

Full guide โ†’ Troubleshooting guide


๐Ÿ“„ License

MIT โ€” see LICENSE

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

g_sheet_mcp-0.1.2.tar.gz (116.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

g_sheet_mcp-0.1.2-py3-none-any.whl (17.4 kB view details)

Uploaded Python 3

File details

Details for the file g_sheet_mcp-0.1.2.tar.gz.

File metadata

  • Download URL: g_sheet_mcp-0.1.2.tar.gz
  • Upload date:
  • Size: 116.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for g_sheet_mcp-0.1.2.tar.gz
Algorithm Hash digest
SHA256 420a22840c2fdc13c876c84e09c6a56ad4bbb9b730ddbc7090ea16afbf076e37
MD5 7e5831733f9070088f3e5ecf1d27b12a
BLAKE2b-256 6cebcd954d62ae10373d057e8f7521b6937cbace06c377d3b3e116135fdb1ed7

See more details on using hashes here.

File details

Details for the file g_sheet_mcp-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: g_sheet_mcp-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 17.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for g_sheet_mcp-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9659176efd5487be298cf8e6f8ccf78bdae6f3a960a748fa2e0c60a490f1e324
MD5 78be3ed5699f8f6aa66b4438690cd31e
BLAKE2b-256 9714719ad3c911ff9edfe9ccd6eac24745c52a940073b3f95b94a30aed0eaf28

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page