Integrates with Google Cloud Console for API management and OAuth 2.0 authentication setup required to access Google Sheets data.
Enables natural language analysis of Google Sheets data with smart syncing, multi-tab support, SQL queries across spreadsheets, and automated data insights for spreadsheet analytics and reporting.
TNTM Google Sheets Analytics MCP Server
A clean, practical MCP (Model Context Protocol) server for analyzing Google Sheets data with multi-tab support. Built for Claude Code and other MCP-compatible AI assistants by TNTM.
🚀 Features
- Smart Sync - Sync Google Sheets with configurable row limits to prevent timeouts
- Multi-tab Support - Query across multiple sheets with SQL JOINs
- SQL Queries - Direct SQL access to synced data
- Sheet Analysis - Get suggestions for cross-sheet queries
- Quick Preview - Preview sheets without full sync
- Performance Optimized - Row limits and result pagination for large datasets
📋 Prerequisites
- Python 3.8+
- Claude Code or another MCP-compatible client
- Google Cloud Project with Sheets API enabled
- OAuth2 credentials from Google Cloud Console
🛠️ Setup
⚡ One-Click Setup with Claude Code (Recommended)
- Drag this project folder into Claude Code
- Ask Claude Code: "Follow the README instructions to install this MCP server into Claude Code"
- Get Google OAuth credentials (Claude Code will guide you through this):
- Go to Google Cloud Console
- Create a new project or select existing one
- Enable the Google Sheets API
- Create OAuth2 credentials (Desktop Application)
- Download and save as
credentials.json
in the project root
That's it! Claude Code will handle virtual environments, dependencies, and OAuth setup automatically.
🚀 Automated Installation (Alternative)
For non-Claude Code users or manual setup:
Option 1: Shell Script (macOS/Linux)
Option 2: Python Script (All platforms)
Option 3: Manual Step-by-step
🔐 Getting Google Credentials
Before first use, you need OAuth2 credentials:
- Go to Google Cloud Console
- Create a new project or select existing one
- Enable the Google Sheets API
- Go to APIs & Services > Credentials
- Click Create Credentials > OAuth 2.0 Client IDs
- Choose Desktop Application
- Download the JSON file
- Save it as
credentials.json
in the project root
🚀 First Run - OAuth Setup
After adding your credentials.json
file, run the OAuth setup:
This will:
- Open your browser for Google authentication
- Create a
token.json
file with your access credentials - Verify the connection works
You only need to do this once! After setup, all MCP tools will work automatically.
🔧 Tools
smart_sync
Sync Google Sheet data with intelligent chunking for large datasets.
url
(required): Google Sheets URLmax_rows
(optional): Max rows per sheet (default: 100000, supports up to 1M+)sheets
(optional): Array of specific sheet names to sync
Auto-scaling behavior:
- Sheets <10K rows: Single fetch
- Sheets 10K-100K rows: 10K row chunks
- Sheets >100K rows: 50K row chunks with sampling
query_sheets
Run SQL queries on synced data, including JOINs across tabs.
query
(required): SQL query to execute
list_synced_sheets
View all synced sheets and their table names.
analyze_sheets
Get suggestions for queries across multiple sheets.
question
(required): What you want to analyze
get_sheet_preview
Quick preview without syncing.
url
(required): Google Sheets URLsheet_name
(optional): Specific sheet to previewrows
(optional): Number of rows to preview (default: 10)
📊 How It Works
- Authentication - Uses OAuth2 to securely access Google Sheets API
- Sync - Downloads sheet data to local SQLite database with configurable limits
- Query - Enables SQL queries across all synced sheets
- Multi-tab - Each sheet becomes a separate table, joinable via SQL
🏗️ Project Structure
⚡ Performance
Scale & Capacity
- 1 Million Row Support: Handles sheets with up to 1M rows efficiently
- Chunked Processing: Automatically chunks large sheets (>10K rows) for optimal performance
- Bulk Operations: 50-100x faster inserts using batch processing
- Configurable Limits: Default 1000 rows, expandable to 1M+ rows per sheet
Optimizations
- Smart Caching: Skip unchanged sheets, 5-minute cache TTL
- Streaming Queries: Results streamed in batches to prevent memory overflow
- Progressive Hashing: Samples large datasets for efficient change detection
- Dynamic Indexing: Auto-creates indexes on large tables for faster queries
- Memory Management: Automatic cleanup after processing large datasets
Performance Metrics
- Sync Speed: 50,000-100,000 rows/second (vs 1,000 rows/second previously)
- Query Response: <1 second for most queries on 1M rows
- Memory Usage: Constant ~200-500MB regardless of dataset size
- 1M Row Sync Time: ~10-20 seconds
🔍 Example Use Cases
Multi-tab Analysis
Cross-sheet Aggregation
🔒 Security
- OAuth2 authentication with Google
- Credentials stored locally (never committed to repo)
- Read-only access to Google Sheets
- Local SQLite database (no external data transmission)
🐛 Troubleshooting
Installation Issues
Issue | Solution |
---|---|
"Failed to reconnect to google-sheets-analytics" | Run automated setup: python3 setup.py or ./install.sh |
"ModuleNotFoundError: No module named 'google'" | Dependencies not installed - use automated installer or manual venv setup |
"externally-managed-environment" | Use virtual environment (automated installers handle this) |
"MCP server not appearing" | Check Claude Code config and restart app |
Common Runtime Issues
Issue | Solution |
---|---|
"No credentials found" | Ensure credentials.json exists in project root or config/ directory |
"Authentication failed" | Check token status with venv/bin/python src/auth/oauth_setup.py --status |
"Token expired" | Run venv/bin/python src/auth/oauth_setup.py --test (auto-refreshes) |
"Sync timeout" | Reduce max_rows parameter in smart_sync |
"Tools not appearing" | Restart Claude Desktop after configuration |
"Rate limit errors" | Wait a few minutes and try again with smaller batches |
OAuth Troubleshooting
- Check status:
venv/bin/python src/auth/oauth_setup.py --status
- Test auth:
venv/bin/python src/auth/oauth_setup.py --test
- Reset OAuth:
venv/bin/python src/auth/oauth_setup.py --reset
- Manual setup:
venv/bin/python src/auth/oauth_setup.py --manual
MCP Server Not Appearing
- Verify config:
cat ~/.config/claude-code/config.json
- Check the config includes the google-sheets-analytics server
- Ensure the virtual environment and dependencies are properly installed
- Check that the Python path in the config is correct
Database Issues
- Database location:
data/sheets_data.sqlite
- Reset database: Delete the file and re-sync
- Check synced sheets: Use the
list_synced_sheets
tool
🤝 Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🙏 Acknowledgments
- Built for the Model Context Protocol
- Designed for Claude Code
- Uses Google Sheets API
Need help? Open an issue on GitHub or check the troubleshooting section above.
This server cannot be installed
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
This MCP server enables AI assistants to automatically sync Google Sheets data to a local database and perform natural language queries and analysis on spreadsheet data.
Related MCP Servers
- -securityAlicense-qualityThis MCP server integrates with Google Drive to allow listing, reading, and searching files, as well as the ability to read and write to Google Sheets.Last updated -2452MIT License
- -securityAlicense-qualityAn MCP server that enables AI assistants to access and interact with Google Classroom data, allowing users to view courses, course details, and assignments through natural language commands.Last updated -7801MIT License
- -securityFlicense-qualityThis MCP Server provides a natural language interface to interact with Google's Policy Analyzer API, allowing users to analyze policies and evaluate compliance through conversations.Last updated -
- -securityFlicense-qualityAn MCP server that enables interaction with Google Sheets through natural language, allowing users to create, read, update, and manage spreadsheet data via the Google Sheets API v4.Last updated -