Google Sheets MCP Server

Google Sheets MCP Server

Provides read-only access to Google Sheets data through OAuth 2.0 authentication, enabling users to retrieve spreadsheet metadata, list tabs, and read cell data using natural language queries.

Category
访问服务器

README

Google Sheets MCP Server

A Model Context Protocol (MCP) server that provides read-only access to Google Sheets. This allows Claude Desktop and other MCP clients to read data from your Google Spreadsheets using simple URL-based tools.

Features

  • Read-only access to your Google Sheets
  • OAuth 2.0 authentication for secure access
  • Three simple tools:
    • google_sheets_get_info - Get spreadsheet metadata
    • google_sheets_list_tabs - List all tabs/sheets
    • google_sheets_get_tab_data - Read cell data from tabs
  • Flexible output formats (Markdown and JSON)
  • A1 notation support for range selection

Installation

1. Install Dependencies

# Clone or download this repository, then:
cd google-sheets-mcp-server
npm install

2. Build the Server

npm run build

This compiles TypeScript to JavaScript in the dist/ directory.

Google Cloud Setup

You need a google.json file for authentication. You have two options:

Option A: Request google.json from Author (Easier)

Quick setup - Ask for pre-configured credentials:

  1. Request the file: Contact the project maintainer via GitHub Issues and ask for google.json
  2. Save it:
    # Save as ~/.google-sheets-mcp-credentials.json
    mv ~/Downloads/google.json ~/.google-sheets-mcp-credentials.json
    
  3. Done! Skip to First-Time Authorization

Note: Shared google.json has usage quotas. For heavy use, create your own using GCP below.


Option B: Create Your Own using GCP (Recommended for Production)

Step 1: Create a Google Cloud Project

  1. Go to Google Cloud Console
  2. Click Select a projectNew Project
  3. Enter a project name (e.g., "MCP Sheets Access")
  4. Click Create

Step 2: Enable Google Sheets API

  1. In your project, go to APIs & ServicesLibrary
  2. Search for "Google Sheets API"
  3. Click on it and press Enable

Step 3: Create OAuth 2.0 Credentials and Download google.json

  1. Go to APIs & ServicesCredentials
  2. Click Create CredentialsOAuth client ID
  3. If prompted, configure the OAuth consent screen:
    • Choose External user type
    • Fill in required fields (app name, user support email, developer email)
    • Add your email to Test users
    • Save and continue
  4. Back to Create OAuth client ID:
    • Application type: Desktop app
    • Name: "MCP Sheets Client" (or any name)
    • Click Create
  5. Download the JSON file (click the download icon)
  6. Save as ~/.google-sheets-mcp-credentials.json:
# Rename and move the downloaded file
mv ~/Downloads/client_secret_*.json ~/.google-sheets-mcp-credentials.json

This is your google.json file!


First-Time Authorization

Applies to both Option A and Option B

The first time you use the MCP server, you'll need to authorize it:

  1. Start the server (it will show an authorization URL)
  2. Visit the URL in your browser
  3. Sign in with your Google account
  4. Click Allow to grant access
  5. The authorization token will be saved automatically to ~/.google-sheets-mcp-token.json

Note: The server will guide you through this process when you first run it.

Claude Desktop Configuration

Add this to your Claude Desktop config file:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "google-sheets": {
      "command": "node",
      "args": [
        "/ABSOLUTE/PATH/TO/google-sheets-mcp-server/dist/index.js"
      ]
    }
  }
}

Important: Replace /ABSOLUTE/PATH/TO/google-sheets-mcp-server with the actual absolute path where you installed this server.

Example paths:

  • macOS: /Users/yourname/projects/google-sheets-mcp-server/dist/index.js
  • Linux: /home/yourname/projects/google-sheets-mcp-server/dist/index.js
  • Windows: C:\Users\yourname\projects\google-sheets-mcp-server\dist\index.js

Tip: Get the absolute path by running pwd in the project directory:

cd google-sheets-mcp-server
pwd  # Copy this path and append /dist/index.js

Restart Claude Desktop after updating the config.

Usage Examples

Once configured in Claude Desktop, you can use natural language:

Get Spreadsheet Info

"Tell me about this Google Sheet: https://docs.google.com/spreadsheets/d/YOUR_SPREADSHEET_ID/edit"

List All Tabs

"What tabs are in this spreadsheet: [URL]"

Read Data from a Tab

"Read all data from the 'Sales' tab in this sheet: [URL]"
"Get cells A1 to D10 from Sheet1 in this spreadsheet: [URL]"

Specify Output Format

"Read the Data tab from [URL] and return it as JSON"

Tools Reference

google_sheets_get_info

Get metadata about a spreadsheet.

Parameters:

  • url (string, required): Google Sheets URL
  • response_format (string, optional): "markdown" or "json" (default: "markdown")

Example:

{
  "url": "https://docs.google.com/spreadsheets/d/SPREADSHEET_ID/edit",
  "response_format": "json"
}

google_sheets_list_tabs

List all tabs/sheets in a spreadsheet.

Parameters:

  • url (string, required): Google Sheets URL
  • response_format (string, optional): "markdown" or "json" (default: "markdown")

google_sheets_get_tab_data

Read cell data from a specific tab.

Parameters:

  • url (string, required): Google Sheets URL
  • tab_name (string, required): Name of the tab (e.g., "Sheet1")
  • range (string, optional): A1 notation range (e.g., "A1:D10")
  • response_format (string, optional): "markdown" or "json" (default: "markdown")

Range Examples:

  • "A1:D10" - Specific rectangular range
  • "B:E" - Columns B through E (all rows)
  • "A1:Z" - All columns from row 1 onward
  • Omit range to read entire sheet

Development

Run in Development Mode

npm run dev

This uses tsx watch for auto-reloading during development.

Build for Production

npm run build

Clean Build Artifacts

npm run clean

Troubleshooting

"Credentials file not found"

Make sure you've saved your google.json file to:

~/.google-sheets-mcp-credentials.json

Need google.json? Request it from the author or create your own using GCP.

"Authentication token expired"

Delete the saved token and re-authorize:

rm ~/.google-sheets-mcp-token.json

Then restart Claude Desktop to trigger re-authorization.

"Unable to read spreadsheet"

Ensure:

  1. The spreadsheet URL is correct
  2. You have access to the spreadsheet (it's shared with your Google account)
  3. You've granted the app permission during OAuth flow

"Invalid Google Sheets URL"

The URL must be in this format:

https://docs.google.com/spreadsheets/d/SPREADSHEET_ID/edit

Security Notes

  • Read-only access: This server only requests spreadsheets.readonly scope
  • Local authentication: OAuth tokens are stored locally at ~/.google-sheets-mcp-token.json
  • No data transmission: All data stays between Google Sheets API and your local Claude Desktop
  • Revoke access: You can revoke access anytime at https://myaccount.google.com/permissions

License

MIT

Contributing

Issues and pull requests welcome!

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选