📇 ☁️ - Google Sheets API integration for reading, writing, formatting and sheet management
MCP Google Sheets Server
以下摘录自该仓库的 README(片段) · 在 GitHub 读完整 README →
A Model Context Protocol (MCP) server for Google Sheets API integration. Enables reading, writing, and managing Google Sheets documents directly from your MCP client (e.g., Claude Code, Claude Desktop, Cursor, etc.).
Key Features
- **Complete Google Sheets Integration**: Read, write, and manage spreadsheets
- **Advanced Operations**: Batch operations, formatting, charts, and conditional formatting
- **Flexible Authentication**: Support for both file-based and JSON string credentials
- **Production Ready**: Built with TypeScript, comprehensive error handling, and full test coverage
Requirements
- Node.js v20 or higher
- Google Cloud Project with Sheets API enabled
- Service Account with JSON key file
- npm
Getting Started
Quick Install (Recommended)
Add the following config to your MCP client:
> [!NOTE]
> Using mcp-gsheets@latest ensures that your MCP client will always use the latest version of the MCP Google Sheets server.
MCP Client Configuration
Claude Code
Use the Claude Code CLI to add the MCP Google Sheets server ( guide ):
After adding, edit your Claude Code config to add the required environment variables:
Claude Desktop
Add to your Claude Desktop config:
- macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
- Windows: %APPDATA%\Claude\claude_desktop_config.json
- Linux: ~/.config/claude/claude_desktop_config.json
Cursor
Go to Cursor Settings → MCP → New MCP Server. Use the config provided above.
Cline
Follow https://docs.cline.bot/mcp/configuring-mcp-servers and use the config provided above.
Other MCP Clients
For other MCP clients, use the standard configuration format shown above. Ensure the command is set to npx and include the environment variables for Google Cloud authentication.
Google Cloud Setup
1. Go to Google Cloud Console
2. Create a new project or select existing
3. Enable Google Sheets API:
- Navigate to "APIs & Services" → "Library"
- Search for "Google Sheets API" and click "Enable"
4. Create Service Account:
- Go to "APIs & Services" → "Credentials"
- Click "Create Credentials" → "Service Account"
- In the service accounts list, click the three dots in the Actions column → Manage keys → Add key → Create new key → select JSON format
- Download the JSON key file
5. Share your spreadsheets:
- Open your Google Sheet
- Click Share and add the service account email (from JSON file)
- Grant "Editor" permissions
Alternative Authentication Methods
Option 1: JSON String Authentication
Instead of using a file path for credentials, you can provide the service account credentials directly as a JSON string. This is useful for containerized environments, CI/CD pipelines, or when you want to avoid managing credential files.
**Note**: When using GOOGLE_SERVICE_ACCOUNT_KEY:
- The entire JSON must be on a single line
- All quotes must be escaped with backslashes
- Newlines in the private key must be represented as \\n
- If the JSON includes a project_id, you can omit GOOGLE_PROJECT_ID
Option 2: Private Key Authentication (Simplified)
For the most user-friendly approach, you can provide just the private key and email directly. This is the simplest method and requires only two fields from your service account JSON:
**Note**: When using GOOGLE_PRIVATE_KEY:
- Newlines in the private key should be represented as \\n
- The private key must include the -----BEGIN PRIVATE KEY----- and -----END PRIVATE KEY----- markers
- The client email should be the service account email from your JSON file
- GOOGLE_PROJECT_ID is optional when using this method
Local Development Setup
If you want to develop or contribute to this project, you can clone and build it locally:
Interactive Setup Script
Run the interactive setup script to configure your local MCP client:
This will:
- Guide you through the configuration
- Automatically detect your Node.js installation (including nvm)
- Find your Claude Desktop config
- Create the proper JSON configuration
- Optionally create a .env file for development
Manual Local Configuration
If you prefer manual configuration with a local build, add to your MCP client config:
📦 Build & Development
Development Commands
Task Runner (Alternative)
If you have Task installed:
Development Setup
1. Create .env file for testing:
2. Run in development mode:
🎚️ Reducing context cost with toolsets