lionharrt/google-sheets-mcp-server
3.1
If you are the rightful owner of google-sheets-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
The Google Sheets MCP Server is a Model Context Protocol server that integrates Google Sheets with HTTP+Streamable transport, designed for Dify and other MCP clients.
Tools
8
Resources
0
Prompts
0
Google Sheets MCP Server
A Model Context Protocol (MCP) server that provides Google Sheets integration with HTTP+Streamable transport for Dify and other MCP clients.
Features
- ✅ Streamable HTTP Transport: Modern MCP transport for Dify integration
- ✅ Google Sheets API Integration: Full CRUD operations on spreadsheets
- ✅ Multiple Authentication Methods: Service Account, OAuth, ADC support
- ✅ Cloud-Ready: Containerized for Google Cloud Run deployment
- ✅ Production Logging: Structured logging with proper error handling
Available Tools
get_sheet_data- Read data from spreadsheet rangesupdate_cells- Update specific cell rangescreate_spreadsheet- Create new spreadsheetslist_spreadsheets- List available spreadsheetsadd_rows- Append rows to sheetslist_sheets- List sheets within a spreadsheetcreate_sheet- Add new sheet tabshealth_check- Server health monitoring
Quick Start
1. Prerequisites
- Python 3.10+
- Google Cloud Project with Sheets and Drive APIs enabled
- Service account credentials
2. Installation
git clone https://github.com/lionharrt/google-sheets-mcp-server.git
cd google-sheets-mcp-server
pip install -e .
3. Authentication Setup
Option A: Service Account (Recommended)
- Create a service account in Google Cloud Console
- Download the JSON key file as
service-account-key.json - Create a Google Drive folder and share it with the service account email
- Set environment variables:
export SERVICE_ACCOUNT_PATH=service-account-key.json
export DRIVE_FOLDER_ID=your_google_drive_folder_id
Option B: OAuth (Development)
- Download OAuth credentials as
credentials.json - Set environment variables:
export CREDENTIALS_PATH=credentials.json
export TOKEN_PATH=token.json
4. Run the Server
python -m google_sheets_mcp_server
The server will start on http://0.0.0.0:8000 with:
- Streamable HTTP endpoint:
/mcp - SSE endpoint:
/sse(backward compatibility)
Deployment
Docker
docker build -t google-sheets-mcp-server .
docker run -p 8000:8000 \
-e SERVICE_ACCOUNT_PATH=service-account-key.json \
-e DRIVE_FOLDER_ID=your_folder_id \
google-sheets-mcp-server
Google Cloud Run
# Build and push to Container Registry
gcloud builds submit --tag gcr.io/your-project/google-sheets-mcp-server
# Deploy to Cloud Run
gcloud run deploy google-sheets-mcp-server \
--image gcr.io/your-project/google-sheets-mcp-server \
--platform managed \
--region us-central1 \
--allow-unauthenticated \
--set-env-vars SERVICE_ACCOUNT_PATH=service-account-key.json,DRIVE_FOLDER_ID=your_folder_id
Dify Integration
- Deploy the MCP server to a publicly accessible URL
- In Dify, go to Tools → MCP
- Add MCP Server (HTTP) with:
- Server URL:
https://your-server-url/mcp - Name:
Google Sheets - Server Identifier:
google-sheets-mcp
- Server URL:
Environment Variables
| Variable | Description | Required |
|---|---|---|
SERVICE_ACCOUNT_PATH | Path to service account JSON key | Yes* |
DRIVE_FOLDER_ID | Google Drive folder ID for spreadsheets | Yes* |
CREDENTIALS_PATH | Path to OAuth credentials JSON | Yes* |
TOKEN_PATH | Path to store OAuth token | No |
CREDENTIALS_CONFIG | Base64 encoded service account JSON | Yes* |
PORT | Server port (default: 8000) | No |
DEBUG | Enable debug logging (default: false) | No |
*One authentication method required
Security Notes
- Never commit authentication files to version control
- Use service accounts for production deployments
- Restrict Google Drive folder access to necessary users
- Enable HTTPS for production deployments
Troubleshooting
Authentication Issues
- Verify service account has Editor role
- Check Google Drive folder is shared with service account email
- Ensure APIs are enabled in Google Cloud Console
Connection Issues
- Verify server is accessible on the configured port
- Check firewall settings for cloud deployments
- Confirm MCP endpoint paths are correct
Development
Running Tests
pip install -e ".[dev]"
pytest
Code Quality
# Format code
black src/
isort src/
# Type checking
mypy src/
# Linting
flake8 src/
License
MIT License - see LICENSE file for details.
Support
For issues and questions:
- Check the troubleshooting section
- Review Google Sheets API documentation
- Open an issue on GitHub