Google Sheets MCP Server
by we2go
README.md
# Google MCP Server
Connect Google Sheets & Docs to Cursor, VS Code, Claude Code and AI agents β **in 3 minutes**.
> Your spreadsheets and documents become data sources 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 and Google Docs.
Once configured, you can tell your AI agent:
**π Sheets:**
```
"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"
```
**π Docs:**
```
"Create a new document titled 'Sprint Report'"
"Read the content of my meeting notes"
"Append a summary paragraph to the project doc"
"Find and replace all 'TODO' with 'DONE'"
"List all my Google Docs"
```
## β‘ Quick Start
> π·πΊ **ΠΠ½ΡΡΡΡΠΊΡΠΈΡ Π½Π° ΡΡΡΡΠΊΠΎΠΌ:** [docs/quickstart-ru.md](docs/quickstart-ru.md) β ΠΏΠΎΡΠ°Π³ΠΎΠ²ΠΎ Π΄Π»Ρ Π½ΠΎΠ²ΠΈΡΠΊΠΎΠ².
Pick the auth method that fits your use case:
### Service Account (recommended for team/automation)
```bash
npx google-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/docs)
Use when you want the AI to act **on your behalf** β access your private sheets and docs without sharing them with a service account.
```bash
npx google-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 β](docs/setup-oauth2.md)** β 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>
```json
{
"mcpServers": {
"google-mcp": {
"command": "npx",
"args": ["google-mcp"]
}
}
}
```
</details>
<details>
<summary>VS Code β <code>.vscode/mcp.json</code></summary>
```json
{
"servers": {
"google-mcp": {
"type": "stdio",
"command": "npx",
"args": ["google-mcp"]
}
}
}
```
</details>
<details>
<summary>Claude Code β <code>.claude/mcp.json</code></summary>
```json
{
"mcpServers": {
"google-mcp": {
"command": "npx",
"args": ["google-mcp"]
}
}
}
```
</details>
<details>
<summary>Codex CLI β <code>codex.json</code></summary>
```json
{
"mcpServers": {
"google-mcp": {
"command": "npx",
"args": ["-y", "google-mcp"]
}
}
}
```
</details>
More configs: [`examples/`](examples/) β Cursor, VS Code, Claude, Codex.
### 3. Restart your IDE
That's it. Your AI agent now has access to your Google Sheets and Docs.
## π CLI Commands
| Command | Description |
|---------|------------|
| `npx google-mcp init` | Interactive setup wizard (service account) |
| `npx google-mcp init --auth oauth` | Setup with personal Google account (OAuth2) |
| `npx google-mcp test` | Test connection + list sheets |
| `npx google-mcp token-status` | Check OAuth2 refresh token health |
| `npx google-mcp list` | List all sheets in the spreadsheet |
| `npx google-mcp read -s <name>` | Read data from a sheet |
| `npx google-mcp create -s <name>` | Create a new sheet tab |
| `npx google-mcp append -s <name> -d '{"col":"val"}'` | Append a row |
| `npx google-mcp config` | Show current configuration |
| `npx google-mcp docs-list` | List Google Docs in your Drive |
| `npx google-mcp docs-read -d <id>` | Read a Google Doc by ID |
| `npx google-mcp docs-create -t <title>` | Create a new Google Doc |
> π‘ **Backward compatible:** `npx google-sheet-mcp` still works as an alias for `npx google-mcp`.
## π§ MCP Tools (for AI Agents)
Once connected, AI agents get these tools:
### π Sheets
| 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) |
### π Docs
| Tool | What it does |
|------|-------------|
| `docs_create` | Create a new Google Doc |
| `docs_read` | Read document content (plain text or structured) |
| `docs_get` | Get document metadata (title, URL, revision, length) |
| `docs_write` | Write/append text to a document |
| `docs_replace` | Find and replace text in a document |
| `docs_list` | List Google Docs in your Drive |
## π Prerequisites
### Google Cloud Setup (3 min)
1. Go to [Google Cloud Console](https://console.cloud.google.com/)
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](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:**
```bash
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:**
```bash
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](docs/setup-oauth2.md)
## π Configuration
Config is stored in `.google-sheet-mcp.json` (in your project or home directory):
```json
{
"spreadsheetId": "1ABC...xyz",
"credentialsPath": "./credentials.json",
"sheets": ["Users", "Orders", "Payments"]
}
```
Or use environment variables:
```bash
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
TDQS
A3.9/5.0
Scored across 6 tools
Disambiguation5/5
Each tool targets a distinct operation: appending rows, creating tabs, getting metadata, listing tabs, reading ranges, and writing ranges. No two tools overlap in purpose.
Naming Consistency5/5
All tools follow a consistent 'sheets_verb_noun' pattern (e.g., sheets_append_row, sheets_read_range), making it easy for agents to predict tool names.
Tool Count5/5
With 6 tools, the set is well-scoped for a Google Sheets MCP server. It covers core operations without being bloated or overly minimal.
Completeness4/5
The tool surface covers basic CRUD for rows and tabs, and metadata retrieval, but lacks deletion operations (remove tab, delete row) and cell-level editing. Minor gaps for a typical spreadsheet workflow.
Maintenance
ActivityInactive
ResponsivenessNo issues