google-sheets-mcp
Enables Claude to read, write, append, create, and clear Google Sheets data using natural language.
README
google-sheets-mcp
A Model Context Protocol (MCP) server that lets Claude interact with Google Sheets — read, write, append, create, and clear spreadsheet data using natural language.
Features
| Tool | Description |
|---|---|
read_cells |
Read cell values from a spreadsheet (single cell, range, or entire sheet) |
write_cells |
Write values to a cell range |
append_rows |
Append rows to the end of a sheet |
create_spreadsheet |
Create a new spreadsheet with custom sheet tabs |
list_sheets |
List all sheet tabs in a spreadsheet |
clear_cells |
Clear cell values while preserving formatting |
Prerequisites
1. Google Cloud Setup
- Go to Google Cloud Console
- Create a project (or select an existing one)
- Enable the Google Sheets API: APIs & Services → Library → search "Google Sheets API" → Enable
- Create OAuth 2.0 credentials:
- APIs & Services → Credentials → + Create Credentials → OAuth client ID
- Application type: Desktop app
- Name:
google-sheets-mcp(or any name) - Click Create → Download JSON
- Save the downloaded file as
credentials/client_secret.json
Important: Make sure to select Desktop app as the application type. Web application credentials will cause a
redirect_uri_mismatcherror.
2. Requirements
- Python 3.11+
- uv (recommended) or pip
Installation
Using uv (recommended)
git clone https://github.com/takehirokawaguchi/google-sheets-mcp.git
cd google-sheets-mcp
uv sync
Using pip
git clone https://github.com/takehirokawaguchi/google-sheets-mcp.git
cd google-sheets-mcp
pip install -e .
Configuration
Create a .env file in the project root:
# Path to your OAuth2 client secret JSON (required)
GOOGLE_OAUTH_CLIENT_SECRET_FILE=/path/to/google-sheets-mcp/credentials/client_secret.json
# Path to token cache file (optional, defaults to ~/.config/google-sheets-mcp/token.json)
# GOOGLE_OAUTH_TOKEN_FILE=/path/to/token.json
First-time authentication
Run the server once to complete the OAuth2 flow in your browser:
uv run google-sheets-mcp
A browser window will open asking you to sign in to your Google account and grant access to Google Sheets. After authorization, the token is cached at ~/.config/google-sheets-mcp/token.json and subsequent runs will not require browser interaction.
Usage with Claude Desktop
Add the following to your Claude Desktop configuration file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"google-sheets": {
"command": "uv",
"args": [
"run",
"--project",
"/path/to/google-sheets-mcp",
"google-sheets-mcp"
],
"env": {
"GOOGLE_OAUTH_CLIENT_SECRET_FILE": "/path/to/google-sheets-mcp/credentials/client_secret.json"
}
}
}
}
Restart Claude Desktop after saving the configuration. The Google Sheets tools will then be available in your conversations.
Example prompts
Read the data from Sheet1 of my spreadsheet (ID: 1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgVE2upms)
Append a new row with ["Alice", 30, "Tokyo"] to the "Users" sheet
Create a new spreadsheet called "Q1 Budget" with sheets: Overview, Jan, Feb, Mar
MCP Tools Reference
read_cells
Read cell values from a Google Spreadsheet.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
spreadsheet_id |
string | yes | — | Spreadsheet ID from the URL |
range |
string | yes | — | A1 notation range, e.g. Sheet1!A1:D5 |
value_render |
string | no | FORMATTED_VALUE |
FORMATTED_VALUE / UNFORMATTED_VALUE / FORMULA |
write_cells
Write values to a cell range.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
spreadsheet_id |
string | yes | — | Spreadsheet ID |
range |
string | yes | — | A1 notation range, e.g. Sheet1!A1:C2 |
values |
array | yes | — | 2D array of values, e.g. [["Name", "Age"], ["Alice", 30]] |
value_input |
string | no | USER_ENTERED |
USER_ENTERED (parse formulas) / RAW (literal strings) |
append_rows
Append rows to the end of data in a sheet.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
spreadsheet_id |
string | yes | — | Spreadsheet ID |
sheet_name |
string | yes | — | Sheet tab name, e.g. Sheet1 |
values |
array | yes | — | 2D array of rows to append |
value_input |
string | no | USER_ENTERED |
USER_ENTERED / RAW |
insert_data_option |
string | no | INSERT_ROWS |
INSERT_ROWS / OVERWRITE |
create_spreadsheet
Create a new Google Spreadsheet.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
title |
string | yes | — | Title of the new spreadsheet |
sheet_names |
array | no | ["Sheet1"] |
List of sheet tab names to create |
list_sheets
List all sheet tabs in a spreadsheet.
| Parameter | Type | Required | Description |
|---|---|---|---|
spreadsheet_id |
string | yes | Spreadsheet ID |
clear_cells
Clear cell values (formatting is preserved).
| Parameter | Type | Required | Description |
|---|---|---|---|
spreadsheet_id |
string | yes | Spreadsheet ID |
range |
string | yes | A1 notation range to clear, e.g. Sheet1!A1:Z100 |
Development
Run tests
uv run pytest -v
Project structure
google-sheets-mcp/
├── src/
│ └── google_sheets_mcp/
│ ├── auth.py # OAuth2 authentication
│ ├── sheets_client.py # Google Sheets API wrapper
│ ├── server.py # MCP tool definitions (FastMCP)
│ └── __main__.py # Entry point
├── tests/
│ ├── conftest.py
│ ├── test_auth.py
│ ├── test_sheets_client.py
│ └── test_server.py
├── credentials/ # Place client_secret.json here (git-ignored)
└── pyproject.toml
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。