Skip to main content
Glama

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)

Related MCP server: Google Sheets MCP Server

πŸ“¦ 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:

# Install dependencies using uv
uv sync

# Or if you don't have uv installed yet:
pip install uv
uv sync

Note: All dependencies are managed through pyproject.toml and uv.lock files.

βš™οΈ Setup

  1. 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

  2. Create OAuth 2.0 Credentials:

    • Go to "Credentials" β†’ "Create Credentials" β†’ "OAuth 2.0 Client ID"

    • Choose "Desktop application"

    • Download the credentials.json file

    • Place it in the project root directory

  3. Generate Authentication Token:

    # Run the token generation script using uv
    uv run token_gen.py
    • A browser window will open for Google authentication

    • Grant necessary permissions

    • This will create token.json file for future use

  4. 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)

  1. Create API Key:

    • Go to Google Cloud Console

    • Enable Google Sheets API

    • Go to "Credentials" β†’ "Create Credentials" β†’ "API Key"

    • Copy the API key

  2. 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.

  1. Generate Token First:

    uv run token_gen.py

    Complete the OAuth flow in your browser.

  2. Then Run Server:

Standalone Mode

uv run main.py

With Claude Desktop

Only after completing token generation, add to your Claude Desktop configuration:

{
  "mcpServers": {
    "sheet-mcp-server": {
        "command": "uv",
        "args": [
            "--directory",
            "C:\\path\\to\\your\\SheetMCP",
            "run",
            "main.py"
        ]
    }
  }
}

Replace C:\\path\\to\\your\\SheetMCP with your actual project directory path.

πŸ› οΈ Available Tools

1. List Spreadsheets

Lists all Google Spreadsheets accessible to the authenticated user.

{
  "name": "list_spreadsheets",
  "arguments": {
    "limit": 20,
    "order_by": "modifiedTime desc"
  }
}

2. Search Spreadsheets by Name

Find spreadsheets by name with exact or partial matching.

{
  "name": "search_spreadsheets_by_name",
  "arguments": {
    "name": "Sales Report",
    "exact_match": false
  }
}

3. Read Sheet Data

Extract data from a specific range or entire sheet.

{
  "name": "read_sheet_data",
  "arguments": {
    "spreadsheet_id": "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms",
    "range": "Sheet1!A1:C10"
  }
}

4. Get Sheet Metadata

Retrieve detailed information about a spreadsheet.

{
  "name": "get_sheet_metadata",
  "arguments": {
    "spreadsheet_id": "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"
  }
}

5. List Sheets

Get all sheet/tab names within a spreadsheet.

{
  "name": "list_sheets",
  "arguments": {
    "spreadsheet_id": "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"
  }
}

6. Search Sheet Data

Find specific content within a sheet.

{
  "name": "search_sheet_data",
  "arguments": {
    "spreadsheet_id": "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms",
    "search_term": "Revenue",
    "sheet_name": "Q4 Data"
  }
}

7. Get Range Data

Extract data with specific formatting options.

{
  "name": "get_range_data",
  "arguments": {
    "spreadsheet_id": "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms",
    "range": "Sheet1!A1:E20",
    "value_render_option": "FORMATTED_VALUE"
  }
}

πŸ” Authentication Scopes

The server uses these Google API scopes:

  • https://www.googleapis.com/auth/spreadsheets.readonly - Read spreadsheet content

  • https://www.googleapis.com/auth/drive.metadata.readonly - List and discover spreadsheets

πŸ“ Project Structure

SheetMCP/
β”œβ”€β”€ main.py                 # Main MCP server implementation
β”œβ”€β”€ token_gen.py           # OAuth token generation script
β”œβ”€β”€ pyproject.toml         # Project configuration and dependencies
β”œβ”€β”€ uv.lock                # Locked dependency versions
β”œβ”€β”€ requirements.txt        # Legacy pip requirements (optional)
β”œβ”€β”€ .env                   # Your environment variables (optional)
β”œβ”€β”€ credentials.json       # OAuth credentials (download from Google)
β”œβ”€β”€ token.json            # Generated OAuth tokens (created by token_gen.py)
└── README.md             # This file

πŸ”§ Configuration

Environment Variables

Create a .env file with:

# For API key authentication (public sheets only) - Optional fallback
SHEET_API_KEY=your_api_key_here

# Server Configuration
SERVER_NAME=google-sheets-mcp-server
SERVER_VERSION=1.0.0
LOG_LEVEL=INFO

Note: The .env file is optional. OAuth authentication via token_gen.py is the primary method.

πŸ› Troubleshooting

Common Issues

  1. OAuth Browser Doesn't Open:

    • Check firewall settings

    • Ensure Python has internet access

    • Try running authentication manually first

  2. Permission Denied Errors:

    • Verify spreadsheet is accessible with your Google account

    • Check if spreadsheet is shared appropriately

    • Ensure correct API scopes are enabled

  3. API Key Limitations:

    • API keys only work with public spreadsheets

    • Use OAuth 2.0 for private spreadsheets

    • Verify spreadsheet sharing settings

  4. Token Expiration:

    • Delete token.json to force re-authentication

    • Run uv run token_gen.py again to regenerate

    • Check if refresh token is still valid

  5. uv Installation Issues:

    • Install uv: curl -LsSf https://astral.sh/uv/install.sh | sh (Unix) or powershell -c "irm https://astral.sh/uv/install.ps1 | iex" (Windows)

    • Or use pip: pip install uv

    • Verify installation: uv --version

Pre-Authentication

Recommended workflow to avoid OAuth interruption during use:

# Step 1: Install dependencies
uv sync

# Step 2: Generate authentication token first
uv run token_gen.py

# Step 3: Then start the MCP server or add to Claude Desktop
uv run main.py

This ensures authentication is completed before Claude Desktop tries to use the server.

πŸ“‹ Example Usage with Claude

User: "List my Google Spreadsheets"
Claude: Uses list_spreadsheets tool to show available spreadsheets

User: "Find spreadsheets with 'Budget' in the name"
Claude: Uses search_spreadsheets_by_name tool with name="Budget"

User: "Read data from the Sales Q4 spreadsheet, range A1:E20"
Claude: Uses search + read_sheet_data tools to find and extract data

User: "What sheets are in this spreadsheet?"
Claude: Uses list_sheets tool to show all tabs/sheets

🀝 Contributing

  1. Fork the repository

  2. Create a feature branch

  3. Make your changes

  4. Add tests if applicable

  5. Submit a pull request

πŸ“„ License

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

⚠️ Security Notes

  • Keep your credentials.json and token.json files secure

  • Never 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

Available Tools

5 tools
get_range_dataC

Get data from a specific range with formatting options

ParametersJSON Schema
NameRequiredDescriptionDefault
spreadsheet_idYesThe ID of the Google Spreadsheet
rangeYesThe range to read (e.g., 'Sheet1!A1:C10')
value_render_optionNoHow to render valuesFORMATTED_VALUE

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions 'formatting options' but does not cover critical aspects such as whether this is a read-only operation, potential rate limits, authentication needs, error handling, or what the output looks like (e.g., data format, pagination). This leaves significant gaps for a tool that interacts with external data.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core purpose ('Get data from a specific range') and adds a relevant detail ('with formatting options'). There is no wasted verbiage, though it could be slightly more structured by explicitly mentioning the tool's scope or limitations.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of interacting with a spreadsheet API, no annotations, and no output schema, the description is insufficient. It lacks details on behavioral traits (e.g., read-only nature, error cases), output format, and how it differs from sibling tools, making it incomplete for safe and effective agent use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, providing clear details for all three parameters, including enums for 'value_render_option'. The description adds minimal value by hinting at 'formatting options', which aligns with the schema but does not elaborate beyond it. This meets the baseline for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Get data') and resource ('from a specific range'), distinguishing it from siblings like 'get_sheet_metadata' or 'list_sheets' that handle metadata or listing. However, it does not explicitly differentiate from 'read_sheet_data' or 'search_sheet_data', which might also involve reading data, making it slightly less specific than a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'read_sheet_data' or 'search_sheet_data'. It mentions 'formatting options' but does not specify contexts, exclusions, or prerequisites for selection, leaving the agent to infer usage based on parameter names alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

get_sheet_metadataC

Get metadata about a Google Spreadsheet

ParametersJSON Schema
NameRequiredDescriptionDefault
spreadsheet_idYesThe ID of the Google Spreadsheet

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It states this is a 'Get' operation, implying read-only behavior, but doesn't specify authentication requirements, rate limits, error conditions, or what metadata fields are returned. For a tool with zero annotation coverage, this leaves significant gaps in understanding how it behaves.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose with zero wasted words. It's appropriately sized for a simple metadata retrieval tool and front-loads the essential information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with no annotations and no output schema, the description is insufficient. It doesn't explain what metadata is returned, how to interpret results, or provide context about the Google Spreadsheet ecosystem. Given the complexity of spreadsheet metadata and lack of structured documentation, more guidance is needed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, clearly documenting the single required 'spreadsheet_id' parameter. The description doesn't add any additional parameter information beyond what's in the schema, but since schema coverage is complete, the baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Get') and resource ('metadata about a Google Spreadsheet'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'list_sheets' or 'read_sheet_data' which might also retrieve spreadsheet information, leaving some ambiguity about what specifically distinguishes this metadata retrieval.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'list_sheets' or 'read_sheet_data'. There's no mention of prerequisites, context, or exclusions, leaving the agent to infer usage based on tool names alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

list_sheetsC

List all sheets/tabs in a Google Spreadsheet

ParametersJSON Schema
NameRequiredDescriptionDefault
spreadsheet_idYesThe ID of the Google Spreadsheet

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the action but doesn't describe what 'list' entailsβ€”such as whether it returns metadata, names only, pagination behavior, or error conditions. For a tool with zero annotation coverage, this leaves significant gaps in understanding how it behaves.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose without unnecessary words. It's front-loaded and wastes no space, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the lack of annotations and output schema, the description is incomplete. It doesn't explain what the tool returns (e.g., a list of sheet names, objects with metadata), error handling, or behavioral nuances. For a tool with no structured output information, the description should provide more context to be fully helpful.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, so the input schema already documents the single parameter 'spreadsheet_id' with its type and description. The description doesn't add any meaning beyond this, such as format examples or constraints, but the schema provides adequate baseline information.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('List all sheets/tabs') and resource ('in a Google Spreadsheet'), making the purpose immediately understandable. However, it doesn't differentiate this tool from its sibling tools like 'get_sheet_metadata' or 'read_sheet_data', which might have overlapping functionality.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'get_sheet_metadata' or 'search_sheet_data'. There's no mention of prerequisites, exclusions, or specific contexts where this tool is preferred, leaving the agent to infer usage from the tool name alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

read_sheet_dataC

Read data from a Google Sheet by spreadsheet ID and range

ParametersJSON Schema
NameRequiredDescriptionDefault
spreadsheet_idYesThe ID of the Google Spreadsheet
rangeNoThe range to read (e.g., 'Sheet1!A1:C10')Sheet1

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool reads data but doesn't mention any behavioral traits such as permissions required, rate limits, error handling, or output format. This is a significant gap for a tool that interacts with external resources like Google Sheets.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose and parameters. It is front-loaded with essential information and contains no redundant or unnecessary details, making it highly concise and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of interacting with Google Sheets and the lack of annotations and output schema, the description is incomplete. It doesn't cover behavioral aspects, usage guidelines, or output details, leaving gaps that could hinder an agent's ability to use the tool effectively in context with its siblings.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents both parameters thoroughly. The description adds minimal value beyond restating the parameters (spreadsheet ID and range), without providing additional context like format examples or usage tips. Baseline 3 is appropriate as the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Read data from') and resource ('a Google Sheet'), specifying the required inputs (spreadsheet ID and range). It distinguishes from siblings like 'get_sheet_metadata' by focusing on data extraction, but doesn't explicitly differentiate from 'get_range_data' or 'search_sheet_data', which may have overlapping functionality.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives like 'get_range_data' or 'search_sheet_data'. The description lacks context about use cases, prerequisites, or exclusions, leaving the agent to infer usage based on tool names alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

search_sheet_dataC

Search for specific data in a Google Sheet

ParametersJSON Schema
NameRequiredDescriptionDefault
spreadsheet_idYesThe ID of the Google Spreadsheet
search_termYesThe term to search for
sheet_nameNoName of the specific sheet to search inSheet1

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden but only states the basic action without disclosing behavioral traits. It doesn't mention if this is a read-only operation, how results are returned (e.g., matches, positions), or any constraints like rate limits or permissions needed, which are critical for a search tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose without any wasted words. It's appropriately sized and front-loaded, making it easy to grasp quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of a search operation with 3 parameters, no annotations, and no output schema, the description is incomplete. It fails to explain what the search returns (e.g., cell references, values), how matches are handled, or any limitations, leaving significant gaps for an AI agent to understand the tool fully.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds no meaning beyond the input schema, which has 100% coverage with clear descriptions for all parameters. Since the schema fully documents the parameters, the baseline score of 3 is appropriate, as the description doesn't compensate but also doesn't detract.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Search') and resource ('specific data in a Google Sheet'), making the purpose understandable. However, it doesn't explicitly differentiate from sibling tools like 'get_range_data' or 'read_sheet_data', which might also retrieve data, so it's not fully distinctive.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'get_range_data' or 'read_sheet_data'. It lacks context on scenarios where searching is preferred over direct retrieval, such as when the exact location of data is unknown, leaving usage unclear.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 5 tool updatesv1.0.0
    • First observedget_range_data
    • First observedget_sheet_metadata
    • First observedlist_sheets
    • First observedread_sheet_data
    • First observedsearch_sheet_data

TDQS

B3.1/5.0

Scored across 5 tools

Disambiguation3/5

There is significant overlap between get_range_data and read_sheet_data, as both retrieve data from a sheet range, potentially causing confusion. However, get_range_data mentions formatting options while read_sheet_data specifies spreadsheet ID, providing some differentiation. The other tools have clearer distinct purposes (metadata, listing, searching).

Naming Consistency5/5

All tool names follow a consistent verb_noun pattern with snake_case (e.g., get_range_data, list_sheets, search_sheet_data). The naming is predictable and readable throughout the set, with no deviations in style or convention.

Tool Count4/5

With 5 tools, the count is reasonable for a Google Sheets server, covering core operations like reading, listing, and searching. It is slightly thin for a full-featured Sheets API but adequate for basic interactions, lacking tools for writing or updating data.

Completeness2/5

The tool set is severely incomplete for a Google Sheets domain, as it only supports read operations (get, list, search) with no create, update, or delete capabilities. This creates significant gaps that will hinder agents from performing common workflows like editing or managing sheets.

Maintenance

ActivityInactive
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers