lkm1developer/google-sheets-mcp-server
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 henry@mcphub.com.
A powerful Model Context Protocol (MCP) server implementation for seamless Google Sheets API integration, enabling AI assistants to create, read, update, and manage Google Sheets.
Google Sheets MCP Server
A powerful Model Context Protocol (MCP) server implementation for seamless Google Sheets API integration, enabling AI assistants to create, read, update, and manage Google Sheets.
Features
- Create, read, update, and delete Google Sheets
- Manage sheet data with cell-level operations
- Format cells and ranges
- Share spreadsheets with other users
- Search for spreadsheets
- Comprehensive authentication options
Authentication Options
This MCP server supports multiple authentication methods:
-
Service Account Authentication (recommended for production)
- Provide a path to a service account key file
- Or provide the service account JSON content directly
-
API Key Authentication (simpler for development)
- Provide a Google API key
-
OAuth2 Authentication (for user-specific operations)
- Provide OAuth client ID, client secret, and refresh token
Setup
Prerequisites
- Node.js (v16 or higher)
- A Google Cloud Project with the Google Sheets API enabled
- Authentication credentials (see below)
Installation
-
Clone the repository:
git clone https://github.com/yourusername/google-sheets-mcp-server.git cd google-sheets-mcp-server -
Install dependencies:
npm install -
Set up authentication:
- Create a
.envfile based on the.env.exampletemplate - Add your Google Cloud credentials
- Create a
-
Build the project:
npm run build -
Start the server:
npm start
OAuth Setup
For operations that require user consent (like creating/editing spreadsheets), you'll need OAuth credentials:
- Create OAuth credentials in the Google Cloud Console
- Update the
CLIENT_IDandCLIENT_SECRETinsrc/get-refresh-token.js - Install required dependencies:
npm install open server-destroy - Run the script to get a refresh token:
node src/get-refresh-token.js - Follow the browser prompts to authorize the application
- Copy the refresh token to your
.envfile
Available Tools
The server provides the following tools:
google_sheets_create: Create a new Google Sheetgoogle_sheets_get: Get a Google Sheet by IDgoogle_sheets_update_values: Update values in a Google Sheetgoogle_sheets_append_values: Append values to a Google Sheetgoogle_sheets_get_values: Get values from a Google Sheetgoogle_sheets_clear_values: Clear values from a Google Sheetgoogle_sheets_add_sheet: Add a new sheet to an existing spreadsheetgoogle_sheets_delete_sheet: Delete a sheet from a spreadsheetgoogle_sheets_list: List Google Sheets accessible to the authenticated usergoogle_sheets_delete: Delete a Google Sheetgoogle_sheets_share: Share a Google Sheet with specific usersgoogle_sheets_search: Search for Google Sheets by titlegoogle_sheets_format_cells: Format cells in a Google Sheetgoogle_sheets_verify_connection: Verify connection with Google Sheets API
Example Usage
Here's an example of how to use this MCP server with Claude:
You can now use Google Sheets! Try these commands:
1. Create a new spreadsheet:
"Create a new Google Sheet titled 'Monthly Budget'"
2. Add data to the spreadsheet:
"Add expense categories and amounts to my Monthly Budget spreadsheet"
3. Format the spreadsheet:
"Format the header row to be bold and centered"
4. Share the spreadsheet:
"Share my Monthly Budget spreadsheet with john@example.com"
License
MIT