A Model Context Protocol (MCP) server written in Go that provides native integration with Google Sheets API. This server enables Claude and other MCP clients to create, read, update, and manage Google Sheets without resorting to xlsx files or Python code.
- Read Google Sheets: Retrieve data from any sheet with flexible range selection
- Write & Update: Write data to specific ranges or update existing content
- Append Data: Add new rows to sheets without overwriting existing data
- Create Spreadsheets: Create new Google Sheets programmatically
- Sheet Management: Add new sheets (tabs), clear data, get spreadsheet metadata
- Batch Operations: Perform multiple updates in a single request for efficiency
- Native Go Implementation: Fast, lightweight, and efficient
- MCP Protocol: Full compatibility with Claude Code and other MCP clients
- Go 1.21 or higher
- Google Account (no GCP project required!)
- OAuth 2.0 Client credentials (easy to set up)
- Go to Google Cloud Console
- Create a new project (or use an existing one)
- Enable the Google Sheets API:
- Navigate to "APIs & Services" > "Library"
- Search for "Google Sheets API"
- Click "Enable"
- Configure OAuth Consent Screen:
- Go to "APIs & Services" > "OAuth consent screen"
- Select "External" user type (unless you have a Google Workspace)
- Fill in app name (e.g., "MCP Google Sheets")
- Add your email as developer contact
- Click "Save and Continue"
- Add scope:
https://www.googleapis.com/auth/spreadsheets - Click "Save and Continue"
- Add your email as a test user
- Click "Save and Continue"
- Create OAuth 2.0 Client ID:
- Go to "APIs & Services" > "Credentials"
- Click "Create Credentials" > "OAuth client ID"
- Select "Desktop app" as application type
- Give it a name (e.g., "MCP Google Sheets Desktop")
- Click "Create"
- Download the JSON file
- Save it as
oauth_credentials.jsonin the project directory
# Clone the repository
git clone https://github.com/conallob/mcp-google-sheets.git
cd mcp-google-sheets
# Download dependencies
go mod download
# Build the server
go build -o mcp-google-sheets
# Or run directly
go run main.goOn the first run, you'll be prompted to authorize the application:
# Run the server (it will guide you through OAuth)
./mcp-google-sheetsThe server will:
- Display a URL for authorization
- Open your browser automatically (or you can copy/paste the URL)
- Ask you to sign in with your Google account
- Request permission to access your Google Sheets
- Save the access token for future use
After authorization, you can access any Google Sheets you own or have access to - no need to share with a service account!
Add to your Claude Code MCP settings (typically in ~/.claude/mcp_settings.json or through Claude Code settings):
{
"mcpServers": {
"google-sheets": {
"command": "/path/to/mcp-google-sheets/mcp-google-sheets",
"env": {
"GOOGLE_OAUTH_CREDENTIALS": "/path/to/oauth_credentials.json"
}
}
}
}Note: If you don't set the GOOGLE_OAUTH_CREDENTIALS environment variable, the server will look for oauth_credentials.json in:
- Current directory
~/.config/mcp-google-sheets/oauth_credentials.json
You can also use individual environment variables:
{
"mcpServers": {
"google-sheets": {
"command": "/path/to/mcp-google-sheets/mcp-google-sheets",
"env": {
"GOOGLE_OAUTH_CLIENT_ID": "your-client-id.apps.googleusercontent.com",
"GOOGLE_OAUTH_CLIENT_SECRET": "your-client-secret"
}
}
}
}For other MCP clients, configure the server with:
- Command: Path to the
mcp-google-sheetsbinary - Environment (optional): Set
GOOGLE_OAUTH_CREDENTIALSto your OAuth credentials file path - Protocol: stdio (standard input/output)
Read data from a Google Sheet.
Parameters:
spreadsheet_id(required): The spreadsheet ID from the URLrange(optional): A1 notation range (e.g., "Sheet1!A1:D10"). Defaults to entire first sheet.
Example:
{
"spreadsheet_id": "1abc123def456",
"range": "Sheet1!A1:C10"
}Write data to a Google Sheet, overwriting existing content.
Parameters:
spreadsheet_id(required): The spreadsheet IDrange(required): A1 notation range to write tovalues(required): 2D array of values (rows and columns)
Example:
{
"spreadsheet_id": "1abc123def456",
"range": "Sheet1!A1:C2",
"values": [
["Name", "Age", "City"],
["Alice", "30", "NYC"]
]
}Append data to a sheet after the last row with data.
Parameters:
spreadsheet_id(required): The spreadsheet IDrange(required): Range indicating which columns to append tovalues(required): 2D array of values to append
Example:
{
"spreadsheet_id": "1abc123def456",
"range": "Sheet1!A:C",
"values": [
["Bob", "25", "SF"],
["Charlie", "35", "LA"]
]
}Create a new Google Spreadsheet.
Parameters:
title(required): Title for the new spreadsheetsheets(optional): Array of sheet names to create
Example:
{
"title": "My New Spreadsheet",
"sheets": ["Data", "Analysis", "Summary"]
}Returns: Spreadsheet ID and URL
Get metadata about a spreadsheet.
Parameters:
spreadsheet_id(required): The spreadsheet ID
Returns: Information about sheets, dimensions, properties, etc.
Add a new sheet (tab) to an existing spreadsheet.
Parameters:
spreadsheet_id(required): The spreadsheet IDsheet_name(required): Name for the new sheet
Clear all data in a specified range.
Parameters:
spreadsheet_id(required): The spreadsheet IDrange(required): A1 notation range to clear
Perform multiple operations in a single request. Supports complex operations like formatting, conditional formatting, adding/deleting rows, etc.
Parameters:
spreadsheet_id(required): The spreadsheet IDrequests(required): Array of request objects (see Google Sheets API documentation)
Once configured, you can ask Claude to interact with your sheets:
"Read the data from my spreadsheet 1abc123def456 in range Sheet1!A1:E100"
"Create a new spreadsheet called 'Sales Report 2024' with sheets: Q1, Q2, Q3, Q4"
"Append the following data to my sheet 1abc123def456 in the range Sheet1!A:D:
Name,Product,Quantity,Price
John,Widget,5,29.99
Jane,Gadget,3,49.99"
"Clear the range Sheet1!A1:Z1000 in spreadsheet 1abc123def456"
You can also integrate this server into your own MCP client applications. The server communicates via JSON-RPC 2.0 over stdio.
The spreadsheet ID is in the URL of your Google Sheet:
https://docs.google.com/spreadsheets/d/1abc123def456ghi789/edit
^^^^^^^^^^^^^^^^
This is the ID
- If you get "unable to load OAuth configuration", make sure:
oauth_credentials.jsonexists in the project directory, ORGOOGLE_OAUTH_CREDENTIALSenvironment variable is set, ORGOOGLE_OAUTH_CLIENT_IDandGOOGLE_OAUTH_CLIENT_SECRETenvironment variables are set
- Check that the Google Sheets API is enabled in your Google Cloud project
- Verify your OAuth consent screen is configured correctly
- The authenticated user must have access to the spreadsheet
- You can access any sheets your Google account can access
- No need to share sheets with a service account anymore!
If you need to re-authenticate (e.g., revoked access or different account):
# Remove the stored token
rm ~/.config/mcp-google-sheets/token.json
# Or if using custom token location
rm /path/to/your/token.json
# Run the server again to re-authenticate
./mcp-google-sheets- Verify your internet connection
- Check if Google APIs are accessible from your network
- Ensure firewall/proxy settings allow access to googleapis.com
mcp-google-sheets/
├── main.go # MCP server implementation
├── sheets/
│ └── client.go # Google Sheets API client
├── go.mod # Go module definition
├── credentials.example.json # Example credentials file
└── README.md # This file
# Install dependencies
go mod download
# Run tests (if available)
go test ./...
# Build
go build -o mcp-google-sheets
# Build for different platforms
GOOS=linux GOARCH=amd64 go build -o mcp-google-sheets-linux
GOOS=darwin GOARCH=amd64 go build -o mcp-google-sheets-mac
GOOS=windows GOARCH=amd64 go build -o mcp-google-sheets.exe- Never commit
oauth_credentials.jsonortoken.jsonto version control (already in .gitignore) - Store OAuth credentials securely and restrict file permissions:
chmod 600 oauth_credentials.json chmod 600 ~/.config/mcp-google-sheets/token.json - OAuth tokens expire and are automatically refreshed
- You can revoke access at any time from Google Account Permissions
- For production deployments, consider using environment variables for OAuth credentials
Contributions are welcome! Please feel free to submit a Pull Request.
See LICENSE file for details.
For issues, questions, or contributions, please use the GitHub issue tracker.