Google Sheets MCP Server

Google Sheets MCP Server

Enables AI coding agents to read, write, and query Google Sheets as a database through the Model Context Protocol.

Category
Visit Server

README

Google Sheets MCP Server

Connect Google Sheets to Cursor, VS Code, Claude Code and AI agents β€” in 3 minutes.

Your spreadsheet becomes a data source that AI agents can read, write, and query.

🎯 What is this?

A Model Context Protocol (MCP) server that lets AI coding agents (Cursor, Copilot, Claude, Codex) interact with Google Sheets as a database.

Once configured, you can tell your AI agent:

"Read all users from the Users sheet"
"Add a new order row: name=Anton, total=150"
"Update the status column for row 23"
"List all sheets in my spreadsheet"

⚑ Quick Start

πŸ‡·πŸ‡Ί Π˜Π½ΡΡ‚Ρ€ΡƒΠΊΡ†ΠΈΡ Π½Π° русском: docs/quickstart-ru.md β€” пошагово для Π½ΠΎΠ²ΠΈΡ‡ΠΊΠΎΠ².

Pick the auth method that fits your use case:

Service Account (recommended for team/automation)

npx google-sheet-mcp init

You'll need:

  • Google Sheet URL β€” paste your sheet link
  • Service Account JSON key β€” download from Google Cloud Console

Personal Account via OAuth2 (for personal sheets)

Use when you want the AI to act on your behalf β€” access your private sheets without sharing them with a service account.

npx google-sheet-mcp init --auth oauth

You'll go through a browser-based OAuth2 flow. A refresh token is saved and auto-refreshed β€” you never need to re-login.

πŸ“– When to use OAuth2 β†’ β€” detailed guide and scenarios.

2. Connect your IDE

The init wizard will generate IDE configs for you automatically β€” just pick Project or System-wide when asked.

If you prefer manual setup, add to your IDE config:

<details> <summary>Cursor β€” <code>.cursor/mcp.json</code></summary>

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

</details>

<details> <summary>VS Code β€” <code>.vscode/mcp.json</code></summary>

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

</details>

<details> <summary>Claude Code β€” <code>.claude/mcp.json</code></summary>

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

</details>

<details> <summary>Codex CLI β€” <code>codex.json</code></summary>

{
  "mcpServers": {
    "google-sheets": {
      "command": "npx",
      "args": ["-y", "google-sheet-mcp"]
    }
  }
}

</details>

More configs: examples/ β€” Cursor, VS Code, Claude, Codex.

3. Restart your IDE

That's it. Your AI agent now has access to your Google Sheet.

πŸ›  CLI Commands

Command Description
npx google-sheet-mcp init Interactive setup wizard (service account)
npx google-sheet-mcp init --auth oauth Setup with personal Google account (OAuth2)
npx google-sheet-mcp test Test connection + list sheets
npx google-sheet-mcp token-status Check OAuth2 refresh token health
npx google-sheet-mcp list List all sheets in the spreadsheet
npx google-sheet-mcp read -s <name> Read data from a sheet
npx google-sheet-mcp create -s <name> Create a new sheet tab
npx google-sheet-mcp append -s <name> -d '{"col":"val"}' Append a row
npx google-sheet-mcp config Show current configuration

🧠 MCP Tools (for AI Agents)

Once connected, AI agents get these tools:

Tool What it does
sheets_list_tabs List all sheet tabs with row/column counts
sheets_read_range Read data from a range (returns objects with header keys)
sheets_get_sheet Get spreadsheet metadata (title, URL, locale)
sheets_write_range Write a 2D array of values to a range
sheets_create_tab Create a new sheet tab
sheets_append_row Append a row (auto-aligns with headers)

πŸ” Prerequisites

Google Cloud Setup (3 min)

  1. Go to Google Cloud Console
  2. Create a project (or use existing)
  3. Enable Sheets API: APIs & Services β†’ Library β†’ "Google Sheets API" β†’ Enable
  4. Create Service Account: APIs & Services β†’ Credentials β†’ Create Credentials β†’ Service Account
  5. Give it a name β†’ Create β†’ Done
  6. Click the service account β†’ Keys β†’ Add Key β†’ Create New Key β†’ JSON β†’ Download
  7. Share your sheet: Open your Google Sheet β†’ Share β†’ add the service account email (from the JSON) as Editor

πŸ“– Detailed guide with screenshots: docs/setup-google.md

OAuth2 Setup (for personal Google accounts)

When to use OAuth2 instead of Service Account:

  • You want AI to access your personal sheets that you don't want to share with a service account
  • You're the only user and don't want to create a service account
  • Your sheets contain sensitive data that shouldn't be accessible via a shared key

Setup:

npx google-sheet-mcp init --auth oauth

The wizard will:

  1. Ask for your OAuth2 Client ID and Client Secret (from Google Cloud Console)
  2. Open a browser for you to grant access
  3. Capture the authorization code automatically
  4. Exchange it for a refresh token (stored locally)

How refresh tokens work:

  • The refresh token is stored in .google-sheet-mcp.json
  • Access tokens are auto-refreshed by googleapis β€” you never need to re-login
  • If a token becomes invalid, just run npx google-sheet-mcp init --auth oauth to replace it

Check token health:

npx google-sheet-mcp token-status

πŸ”‘ Key benefit: The AI agent acts as you β€” it accesses exactly the sheets you have access to. No need to share sheets with a service account email.

πŸ“– Detailed guide: docs/setup-oauth2.md

πŸ“ Configuration

Config is stored in .google-sheet-mcp.json (in your project or home directory):

{
  "spreadsheetId": "1ABC...xyz",
  "credentialsPath": "./credentials.json",
  "sheets": ["Users", "Orders", "Payments"]
}

Or use environment variables:

export GOOGLE_SPREADSHEET_ID="1ABC...xyz"
export GOOGLE_APPLICATION_CREDENTIALS="./credentials.json"

πŸ— Architecture

google-sheet-mcp/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ cli/              # CLI commands (init, test, list, read, append)
β”‚   β”œβ”€β”€ server/           # MCP stdio server + Google Sheets client
β”‚   └── config/           # Config loader (.google-sheet-mcp.json + env)
β”œβ”€β”€ examples/             # MCP configs for Cursor, VS Code, Claude, Codex
β”œβ”€β”€ docs/                 # Setup guides
β”œβ”€β”€ README.md
└── package.json

❓ FAQ

Do I need to clone this repo?

No. Just use npx google-sheet-mcp init. No installation required.

What permissions does the service account need?

Only "Editor" on the specific spreadsheet. Not on your entire Google Drive.

Can I connect multiple sheets?

Yes. Use different config files per project, or set env vars per spreadsheet.

Does it work with private sheets?

Yes. Share the sheet with the service account email (found in the JSON key).

Is my data sent to a third party?

No. The MCP server runs locally on your machine. Google Sheets API calls go directly from your machine to Google. No intermediate servers.

πŸ“„ License

MIT

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured