Uses Google Cloud Platform for API authentication and authorization, supporting both OAuth 2.0 and API key authentication methods for accessing Google Sheets.
Enables discovery and listing of Google Spreadsheets stored in Google Drive through Drive API metadata access.
Provides tools for reading and interacting with Google Sheets data, including listing spreadsheets, searching by name, reading sheet data from specific ranges, retrieving metadata, listing sheets/tabs, and searching content within sheets.
Google Sheets MCP Server
A Model Context Protocol (MCP) server that provides tools for reading and interacting with Google Sheets data. This server enables AI assistants like Claude Desktop to seamlessly access, search, and analyze Google Spreadsheets.
Built with uv for fast and reliable dependency management.
š Features
š List Spreadsheets: Discover all accessible Google Spreadsheets
š Search by Name: Find spreadsheets by name (exact or partial match)
š Read Sheet Data: Extract data from specific ranges or entire sheets
š Sheet Metadata: Get detailed information about spreadsheet structure
š List Sheets/Tabs: View all sheets within a spreadsheet
š Search Content: Find specific data within sheets
šÆ Range Data: Get formatted data from specific cell ranges
š Dual Authentication: Supports both OAuth 2.0 (private sheets) and API key (public sheets)
š¦ Installation
Prerequisites
Python 3.8+
uv package manager
Google Cloud Project with Sheets API enabled
Claude Desktop or other MCP-compatible client
Dependencies
This project uses uv for fast and reliable dependency management:
Note: All dependencies are managed through pyproject.toml and uv.lock files.
āļø Setup
Option 1: OAuth 2.0 Authentication (Recommended for Private Sheets)
Create Google Cloud Project:
Go to Google Cloud Console
Create a new project or select existing one
Enable Google Sheets API and Google Drive API
Create OAuth 2.0 Credentials:
Go to "Credentials" ā "Create Credentials" ā "OAuth 2.0 Client ID"
Choose "Desktop application"
Download the
credentials.jsonfilePlace it in the project root directory
Generate Authentication Token:
# Run the token generation script using uv uv run token_gen.pyA browser window will open for Google authentication
Grant necessary permissions
This will create
token.jsonfile for future use
Environment Setup (Optional):
# Create .env file if you want to use API key fallback echo "SHEET_API_KEY=your_api_key_here" > .env
Option 2: API Key Authentication (Public Sheets Only)
Create API Key:
Go to Google Cloud Console
Enable Google Sheets API
Go to "Credentials" ā "Create Credentials" ā "API Key"
Copy the API key
Environment Configuration:
# Create .env file echo "SHEET_API_KEY=your_api_key_here" > .env
Note: API key authentication only works with publicly shared spreadsheets.
šāāļø Running the Server
Prerequisites
Important: You must generate the authentication token before adding the MCP server to Claude Desktop.
Generate Token First:
uv run token_gen.pyComplete the OAuth flow in your browser.
Then Run Server:
Standalone Mode
With Claude Desktop
Only after completing token generation, add to your Claude Desktop configuration:
Replace
š ļø Available Tools
1. List Spreadsheets
Lists all Google Spreadsheets accessible to the authenticated user.
2. Search Spreadsheets by Name
Find spreadsheets by name with exact or partial matching.
3. Read Sheet Data
Extract data from a specific range or entire sheet.
4. Get Sheet Metadata
Retrieve detailed information about a spreadsheet.
5. List Sheets
Get all sheet/tab names within a spreadsheet.
6. Search Sheet Data
Find specific content within a sheet.
7. Get Range Data
Extract data with specific formatting options.
š Authentication Scopes
The server uses these Google API scopes:
https://www.googleapis.com/auth/spreadsheets.readonly- Read spreadsheet contenthttps://www.googleapis.com/auth/drive.metadata.readonly- List and discover spreadsheets
š Project Structure
š§ Configuration
Environment Variables
Create a .env file with:
Note: The .env file is optional. OAuth authentication via token_gen.py is the primary method.
š Troubleshooting
Common Issues
OAuth Browser Doesn't Open:
Check firewall settings
Ensure Python has internet access
Try running authentication manually first
Permission Denied Errors:
Verify spreadsheet is accessible with your Google account
Check if spreadsheet is shared appropriately
Ensure correct API scopes are enabled
API Key Limitations:
API keys only work with public spreadsheets
Use OAuth 2.0 for private spreadsheets
Verify spreadsheet sharing settings
Token Expiration:
Delete
token.jsonto force re-authenticationRun
uv run token_gen.pyagain to regenerateCheck if refresh token is still valid
uv Installation Issues:
Install uv:
curl -LsSf https://astral.sh/uv/install.sh | sh(Unix) orpowershell -c "irm https://astral.sh/uv/install.ps1 | iex"(Windows)Or use pip:
pip install uvVerify installation:
uv --version
Pre-Authentication
Recommended workflow to avoid OAuth interruption during use:
This ensures authentication is completed before Claude Desktop tries to use the server.
š Example Usage with Claude
š¤ Contributing
Fork the repository
Create a feature branch
Make your changes
Add tests if applicable
Submit a pull request
š License
This project is licensed under the MIT License - see the LICENSE file for details.
š Related Links
ā ļø Security Notes
Keep your
credentials.jsonandtoken.jsonfiles secureNever commit authentication files to version control
Use environment variables for API keys
Regularly review and rotate credentials
Follow the principle of least privilege for API scopes