Google Sheets MCP Server
Provides a secure bridge for AI assistants to interact with the Google Sheets API via 31 tools for spreadsheet management, data manipulation, and table-level operations. It supports both Service Account and OAuth 2.0 authentication for tasks including batch updates, CSV imports, and conditional formatting.
README
Google Sheets MCP Server
A Model Context Protocol (MCP) server that provides a secure bridge between MCP-compatible clients (like Claude Desktop) and the Google Sheets API.
Overview
This MCP server provides a secure interface for AI assistants to interact with Google Spreadsheets, enabling powerful automation and data manipulation workflows. It supports both Service Account and OAuth 2.0 authentication methods and runs as a containerized service for enhanced security.
Key Features
- 31 Tools for comprehensive spreadsheet manipulation
- Service Account & OAuth 2.0 authentication support
- Docker-based deployment with non-root user execution
- Table-level operations for structured data management
- Batch operations for efficient API usage
- Conditional formatting with custom rules and formulas
- CSV import/export capabilities
Architecture
Claude Desktop → MCP Gateway → Google Sheets Server → Google Sheets API
↓
Docker Desktop Secrets
Tools Available
Spreadsheet Management (3 tools)
list_spreadsheets- List spreadsheets from Drive folder or user accesscreate_spreadsheet- Create new spreadsheetshare_spreadsheet- Share with users/emails (reader, commenter, writer roles)
Sheet Operations (6 tools)
list_sheets- List all sheet names in a spreadsheetcreate_sheet- Add new sheet (tab)rename_sheet- Rename existing sheetcopy_sheet- Duplicate sheet within or across spreadsheetsadd_columns- Add columns to sheetadd_conditional_formatting- Add conditional formatting rulesupdate_conditional_formatting- Update or move existing rules
Data Access (4 tools)
get_sheet_data- Read data from range (with optional grid metadata)get_sheet_formulas- Read formulas from rangeget_multiple_sheet_data- Fetch multiple ranges in one callget_multiple_spreadsheet_summary- Get titles, headers, and preview rows
Data Modification (3 tools)
update_cells- Write data to specific range (overwrites)batch_update_cells- Update multiple ranges in one calladd_rows- Append rows to end of sheet
Table Operations (11 tools)
list_tables- List defined tables (named ranges)create_table- Create table with headers and optional dataget_table_data- Read table data with filters, limit, offsetinsert_table_rows- Insert rows into tableupdate_table_rows- Update rows matching criteriadelete_table_rows- Delete rows matching criteriaadd_table_columns- Add columns to tablerename_table_column- Rename table headerexport_table_as_csv- Export table to CSV formatimport_csv_to_table- Import CSV content into table
Prerequisites
- Docker Desktop with MCP Toolkit enabled
- Docker MCP CLI plugin (
docker mcpcommand) - Google Cloud Project with:
- Google Sheets API enabled
- Google Drive API enabled
- Credentials:
- Service Account JSON file (recommended), OR
- OAuth 2.0 credentials for user authentication
Quick Start
1. Build Docker Image
git clone <repository-url>
cd MCP_GoogleSheets
docker build -t googlesheets-mcp-server .
2. Configure Credentials
# Service Account (recommended)
docker mcp secret set GOOGLE_APPLICATION_CREDENTIALS="/path/to/service-account.json"
docker mcp secret set SERVICE_ACCOUNT_EMAIL="your-sa@project.iam.gserviceaccount.com"
# Optional: Specify default Drive folder
docker mcp secret set DRIVE_FOLDER_ID="your-folder-id"
3. Create Custom Catalog
Create or edit ~/.docker/mcp/catalogs/custom.yaml:
version: 2
name: custom
displayName: Custom MCP Servers
registry:
googlesheets:
description: "Bridge between MCP clients and Google Sheets API"
title: "Google Sheets"
type: server
dateAdded: "2025-10-11T00:00:00Z"
image: googlesheets-mcp-server:latest
ref: ""
tools:
- name: list_spreadsheets
- name: create_spreadsheet
- name: get_sheet_data
# ... (see readme.txt for complete list)
secrets:
- name: GOOGLE_APPLICATION_CREDENTIALS
env: GOOGLE_APPLICATION_CREDENTIALS
- name: SERVICE_ACCOUNT_EMAIL
env: SERVICE_ACCOUNT_EMAIL
- name: DRIVE_FOLDER_ID
env: DRIVE_FOLDER_ID
metadata:
category: productivity
tags: [google, sheets, spreadsheet, data]
4. Update Registry
Edit ~/.docker/mcp/registry.yaml and add:
registry:
googlesheets:
ref: ""
5. Configure Claude Desktop
Edit your Claude Desktop config file:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json - Linux:
~/.config/Claude/claude_desktop_config.json
Add the custom catalog to the args array:
{
"mcpServers": {
"mcp-toolkit-gateway": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-v", "/var/run/docker.sock:/var/run/docker.sock",
"-v", "/Users/your_username/.docker/mcp:/mcp",
"docker/mcp-gateway",
"--catalog=/mcp/catalogs/docker-mcp.yaml",
"--catalog=/mcp/catalogs/custom.yaml",
"--config=/mcp/config.yaml",
"--registry=/mcp/registry.yaml",
"--tools-config=/mcp/tools.yaml",
"--transport=stdio"
]
}
}
}
6. Restart Claude Desktop
Quit and restart Claude Desktop completely. Your Google Sheets tools should now be available!
Usage Examples
Basic Operations
"List all my spreadsheets"
"Create a new spreadsheet called 'Q1 Sales Data 2025'"
"Get data from Sheet1 range A1:D10 in spreadsheet [ID]"
"Add a new sheet called 'Revenue' to my spreadsheet"
Table Operations
"Create a table with headers ['Name', 'Email', 'Status'] in Sheet1"
"Get all data from the 'Customers' table where Status is 'Active'"
"Insert rows [['John', 'john@example.com', 'Active']] into the Users table"
"Export the 'Sales' table as CSV"
Advanced Features
"Share my spreadsheet with user@example.com as a writer"
"Add conditional formatting to highlight values > 100 in A1:D10"
"Update cells A1:B2 with data [[1,2],[3,4]]"
"Batch update multiple ranges: A1:B2 and D5:E6"
Data Format Examples
2D Array (for update_cells, add_rows)
[["Header1", "Header2"], ["Value1", "Value2"]]
Multiple Ranges (for batch_update_cells)
{"A1:B2": [[1, 2], [3, 4]], "D5": [["Hello"]]}
Filters (for get_table_data)
{"Status": "Active", "Country": "USA"}
Conditional Formatting Rule
{
"type": "boolean",
"condition": {
"type": "NUMBER_GREATER",
"values": [{"userEnteredValue": "100"}]
},
"format": {
"backgroundColor": {"red": 1.0, "green": 0.8, "blue": 0.8},
"textFormat": {"bold": true}
}
}
Development
Local Testing
# Set environment variables
export GOOGLE_APPLICATION_CREDENTIALS="/path/to/service-account.json"
# Run server
python googlesheets_server.py
# Test MCP protocol
echo '{"jsonrpc":"2.0","method":"tools/list","id":1}' | python googlesheets_server.py
Adding New Tools
- Add function to
googlesheets_server.py - Decorate with
@mcp.tool() - Use single-line docstring only
- Use empty string defaults (
param: str = "") - Always return strings
- Update catalog with new tool name
- Rebuild Docker image
Implementation Rules
See CLAUDE.md for detailed guidelines:
- NO multi-line docstrings (causes gateway panic)
- NO type hints from typing module
- NO
Nonedefaults (use""instead) - Single-line docstrings ONLY
- Always return strings from tools
Troubleshooting
Tools Not Appearing
# Check Docker image
docker images | grep googlesheets
# Verify server in list
docker mcp server list
# Check logs
docker logs [container_name]
Authentication Errors
# Verify secrets
docker mcp secret list
# Check APIs enabled in Google Cloud Console:
# - Google Sheets API
# - Google Drive API
Common Issues
- Gateway panic: Check for multi-line docstrings in tools
- JSON parse errors: Ensure valid JSON with double quotes
- Empty results: Verify spreadsheet ID, sheet name, and range notation
Security
- Credentials stored in Docker Desktop secrets (never hardcoded)
- Server runs as non-root user (
mcpuser) - Sensitive data never logged
- Only operates on authorized spreadsheets
API Limits
Google Sheets API quotas:
- 500 requests per 100 seconds per project
- 100 requests per 100 seconds per user
Consider implementing request batching and caching for production use.
Files
googlesheets_server.py- Main MCP server implementationDockerfile- Container definitionrequirements.txt- Python dependenciesreadme.txt- Detailed installation guideCLAUDE.md- Development guidelines for Claude Codemcp-builder-prompt.md- Template prompt used to build this server
References
License
MIT License
Support
For issues and questions:
- Check the Troubleshooting section
- Review
readme.txtfor detailed setup instructions - See
CLAUDE.mdfor implementation guidelines - Check Docker logs:
docker logs [container_name]
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。