google-sheets-mcp

jona-mhw/google-sheets-mcp

3.2

If you are the rightful owner of google-sheets-mcp 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.

The Google Sheets MCP Server is a Python-based server that facilitates secure and efficient interaction between Claude Desktop and Google Sheets using Google Apps Script.

Tools
  1. read_cell

    Read a single cell from a specified sheet.

  2. write_cell

    Write data to a specified cell in a sheet.

  3. read_range

    Read a range of cells from a specified sheet.

  4. write_range

    Write data to a specified range in a sheet.

  5. clear_range

    Clear a specified range of cells in a sheet.

  6. list_sheets

    List all sheets in the Google Sheets document.

  7. test_connection

    Test the connection setup between Claude Desktop and Google Sheets.

๐Ÿ“Š Google Sheets MCP Server

๐Ÿ Python-based MCP Server that enables Claude Desktop to interact seamlessly with Google Sheets through Google Apps Script.

Python MCP

๐Ÿ”ฌ Research Project: This is an experimental development project demonstrating Model Context Protocol (MCP) capabilities and secure Google API integration. Developed as a proof of concept to explore new ways of connecting AI with productivity tools.

โœจ Features

  • ๐Ÿ“– Read Operations: Single cells, ranges, and sheet metadata
  • โœ๏ธ Write Operations: Update cells and ranges with data
  • ๐Ÿงน Utility Operations: Clear ranges and test connections
  • ๐Ÿ” Secure: Uses Google Apps Script as secure proxy within your own account
  • ๐Ÿš€ Easy Setup: Works with Claude Desktop without complex configurations

๐Ÿ”’ Security & Privacy

๐Ÿ›ก๏ธ Multiple Security Layers

  1. Google Apps Script (Your Account):

    • Runs in YOUR Google infrastructure
    • Only YOU have access to your data
    • Automatic authentication with your Google session
    • No exposed OAuth credentials
  2. Model Context Protocol (MCP):

    • Open standard protocol by Anthropic
    • Secure localhost-only communication
    • No data transmitted to third parties
    • Full control over exposed tools
  3. Local Architecture:

    • MCP server runs on YOUR machine
    • No data leaves your control
    • No external servers involved

๐ŸŽฏ Why is it Secure?

YOUR DATA โ†’ Google Sheets (YOUR account) โ†’ Apps Script (YOUR account) โ†’ MCP Server (YOUR machine) โ†’ Claude Desktop (YOUR machine)

Result: Your data NEVER leaves your personal ecosystem.

๐Ÿš€ Quick Start

Prerequisites

  • Python 3.8+ installed
  • Claude Desktop installed
  • Google account with access to Google Sheets and Apps Script

Installation

# 1. Clone this repository
git clone https://github.com/jona-mhw/google-sheets-mcp.git
cd google-sheets-mcp

# 2. Install Python dependencies
cd mcp-server
pip install -r requirements.txt

# 3. Configure environment variables
cp .env.example .env
# Edit .env and add your APPS_SCRIPT_URL

Google Apps Script Setup

Step 1: Create Apps Script Project
  1. Go to script.google.com
  2. Click "New project"
  3. Important: The file name can be anything (Code.gs, main.gs, sheets.gs, etc.)
Step 2: Copy the Code
  1. Delete the default code
  2. Copy ALL content from
  3. Paste it into your project
  4. Save the project (Ctrl+S)
Step 3: Deploy as Web App
  1. Click "Deploy" > "New deployment"
  2. Type: Select "Web app"
  3. Configuration:
    • Execute as: "Me" (your account)
    • Who has access: "Anyone"
  4. Click "Deploy"

โš ๏ธ Costs: Google Apps Script is FREE up to 6 hours of execution time per day. For normal spreadsheet usage, this is more than sufficient.

Step 4: Get the URL
  1. Copy the Web app URL (ends with /exec)
  2. This is your APPS_SCRIPT_URL

Claude Desktop Configuration

  1. Find your configuration file:

    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    • Windows: %APPDATA%/Claude/claude_desktop_config.json
    • Linux: ~/.config/Claude/claude_desktop_config.json
  2. Add the MCP configuration:

{
  "mcpServers": {
    "google-sheets": {
      "command": "python",
      "args": ["server.py"],
      "cwd": "/absolute/path/to/google-sheets-mcp/mcp-server",
      "env": {
        "APPS_SCRIPT_URL": "https://script.google.com/macros/s/YOUR_SCRIPT_ID/exec",
        "DEBUG": "false"
      }
    }
  }
}

โš ๏ธ Important: Replace /absolute/path/to/ with the actual path where you cloned this repository.

Path examples:

  • macOS/Linux: /Users/your-username/google-sheets-mcp/mcp-server
  • Windows: C:\\Users\\your-username\\google-sheets-mcp\\mcp-server
  1. Restart Claude Desktop

๐Ÿ› ๏ธ Available Tools

ToolDescriptionExample Usage
read_cellRead a single cellread_cell("Sheet1", "A1")
write_cellWrite to a cellwrite_cell("Sheet1", "A1", "Hello")
read_rangeRead cell rangeread_range("Sheet1", "A1:B5")
write_rangeWrite to rangewrite_range("Sheet1", "A1:B2", data)
clear_rangeClear cell rangeclear_range("Sheet1", "A1:B5")
list_sheetsList all sheetslist_sheets()
test_connectionTest setuptest_connection()

๐Ÿ—๏ธ Architecture

Claude Desktop โ†’ Python MCP Server โ†’ Google Apps Script โ†’ Google Sheets
     โ†‘                                                          โ†“
     โ†โ†โ†โ†โ†โ†โ†โ†โ†โ† JSON Response โ†โ†โ†โ†โ†โ†โ†โ†โ†โ†โ†โ†โ†โ†โ†โ†โ†โ†โ†โ†โ†โ†โ†โ†โ†โ†โ†โ†โ†โ†

Why this approach?

  • ๐Ÿ” No complex OAuth: Apps Script uses your existing Google session
  • ๐ŸŽฏ Focused: Designed specifically for Google Sheets operations
  • ๐Ÿš€ Scalable: Easy to add new functionality
  • ๐Ÿ’ฐ Free: Uses Google's free Apps Script infrastructure
  • ๐Ÿ›ก๏ธ Private: Everything stays within your personal account

โœ… Verification

After setup, ask Claude:

"Test the Google Sheets connection"

Claude should be able to use the test_connection() tool and show you it's connected.

๐Ÿ” Troubleshooting

Error: "No module named 'fastmcp'"

pip install -r requirements.txt

Error: "APPS_SCRIPT_URL not configured"

  • Verify that the .env file exists
  • Verify that the URL is correct
  • Ensure the Apps Script is deployed as Web App

Claude doesn't see the MCP

  • Verify that the cwd path is absolute and correct
  • Restart Claude Desktop completely
  • Check that the JSON configuration is valid

Apps Script permission errors

  • Ensure the Apps Script is deployed with "Anyone" permissions
  • Verify that the Spreadsheet exists and you have access

๐Ÿค Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

๐Ÿ“„ License

This project is licensed under the MIT License - see the file for details.

๐Ÿ™ Acknowledgments


Created by: Jona
Purpose: Connect Claude with Google Sheets efficiently and securely
Type: Research & Development Project - MCP Proof of Concept