Skip to main content
Glama

Google Sheets MCP Server

An MCP (Model Context Protocol) server that exposes Google Sheets as queryable database tables. Designed to run as a Google Cloud Function.

Features

  • list_sheets - List all sheet names in a spreadsheet

  • get_schema - Get column headers for a sheet

  • query_rows - Fetch rows with optional pagination (limit/offset)

Prerequisites

  1. A Google Cloud project with the Sheets API enabled

  2. A service account with access to the spreadsheets you want to query

  3. Google Cloud CLI (gcloud) installed and configured

Setup

1. Create a Service Account

# Create the service account gcloud iam service-accounts create sheets-mcp \ --display-name="Google Sheets MCP Server" # Create and download the key gcloud iam service-accounts keys create service-account-key.json \ --iam-account=sheets-mcp@YOUR_PROJECT_ID.iam.gserviceaccount.com

2. Share Spreadsheets

Share your Google Spreadsheets with the service account email:

sheets-mcp@YOUR_PROJECT_ID.iam.gserviceaccount.com

Grant "Viewer" permission for read-only access.

3. Install Dependencies

npm install

4. Build

npm run build

Local Development

Set the environment variable and run:

export GOOGLE_SERVICE_ACCOUNT_KEY=$(cat service-account-key.json) npm start

Deploy to Google Cloud Functions

Deploy Command

gcloud functions deploy google-sheets-mcp \ --gen2 \ --runtime=nodejs20 \ --region=us-central1 \ --source=. \ --entry-point=googleSheetsMcp \ --trigger-http \ --allow-unauthenticated \ --set-env-vars="GOOGLE_SERVICE_ACCOUNT_KEY=$(cat service-account-key.json | jq -c .)"

For authenticated access (recommended for production):

gcloud functions deploy google-sheets-mcp \ --gen2 \ --runtime=nodejs20 \ --region=us-central1 \ --source=. \ --entry-point=googleSheetsMcp \ --trigger-http \ --set-env-vars="GOOGLE_SERVICE_ACCOUNT_KEY=$(cat service-account-key.json | jq -c .)"

For better security, store credentials in Secret Manager:

# Create the secret gcloud secrets create sheets-mcp-credentials \ --data-file=service-account-key.json # Deploy with secret reference gcloud functions deploy google-sheets-mcp \ --gen2 \ --runtime=nodejs20 \ --region=us-central1 \ --source=. \ --entry-point=googleSheetsMcp \ --trigger-http \ --set-secrets="GOOGLE_SERVICE_ACCOUNT_KEY=sheets-mcp-credentials:latest"

MCP Client Configuration

Add the deployed function URL to your MCP client configuration:

{ "mcpServers": { "google-sheets": { "url": "https://REGION-PROJECT_ID.cloudfunctions.net/google-sheets-mcp" } } }

Tool Usage

list_sheets

List all sheets in a spreadsheet:

{ "spreadsheetId": "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms" }

get_schema

Get column headers for a sheet:

{ "spreadsheetId": "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms", "sheetName": "Sheet1" }

query_rows

Fetch rows from a sheet:

{ "spreadsheetId": "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms", "sheetName": "Sheet1", "limit": 10, "offset": 0 }

Finding the Spreadsheet ID

The spreadsheet ID is in the URL of your Google Sheet:

https://docs.google.com/spreadsheets/d/SPREADSHEET_ID/edit

License

MIT

-
security - not tested
F
license - not found
-
quality - not tested

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/matty-v/google-sheets-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server