Google Sheets MCP Server

Google Sheets MCP Server

Wraps the Google Sheets API for reading, appending, updating ranges and adding dropdowns, with an optional Gmail monitor to automate job application tracking.

Category
访问服务器

README

Google Sheets MCP Server

CI Python License: MIT

An MCP server that wraps the Google Sheets API -- list tabs, read ranges, append rows, overwrite ranges, and add dropdown (data validation) rules -- plus an optional scheduled script that scans Gmail for new messages matching a pattern and appends rows for the ones that match, skipping ones that look like rejections/negatives.

Originally built to maintain a job-application tracker (new interview/offer emails in, auto-filtered rejections out), but the server itself is generic: any project that needs programmatic Sheets read/write/dropdown access from an MCP client can use it as-is.

Features

  • list_sheet_tabs -- list tabs, their IDs, row/column counts
  • read_range -- read cell values from an A1-notation range
  • append_rows -- append rows after existing data
  • update_range -- overwrite an exact range
  • set_dropdown_validation -- add a dropdown (data validation list) to a column
  • monitor_job_responses.py -- optional incremental Gmail-to-Sheet monitor, safe to run on a schedule (dedupes via a local state file, skips rejections via keyword matching)

Architecture

flowchart LR
    client["MCP client<br/>(Claude Desktop, etc.)"] -->|stdio / streamable-http| srv["server.py<br/>(FastMCP)"]
    srv -->|service account| sheets["Google Sheets API"]
    mon["monitor_job_responses.py<br/>(cron / Task Scheduler)"] --> gm["gmail_client.py"]
    gm -->|OAuth, read-only| gmail["Gmail API"]
    mon -->|append_rows| srv

Two independent credential paths: the Sheets side uses a service account (sheets explicitly shared with it), while the Gmail side uses a personal OAuth "Desktop app" flow -- personal Gmail accounts can't delegate to a service account, so the monitor authenticates separately with a read-only scope.

Prerequisites

  • Python 3.10+
  • A Google Cloud project with the Google Sheets API enabled
  • A service account with a downloaded JSON key
  • The target spreadsheet shared with that service account's client_email as Editor

Installation

git clone https://github.com/JasonEckardt/google-sheets-mcp-server.git
cd google-sheets-mcp-server
pip install -e .
cp .env.example .env

For development (tests + lint):

pip install -e ".[dev]"

Edit .env:

GOOGLE_SERVICE_ACCOUNT_FILE=service_account.json
DEFAULT_SPREADSHEET_ID=your_spreadsheet_id_here

Place your service account key in this folder (matching the filename in .env). Never commit this file -- it's already gitignored.

Running the MCP server

Local / stdio (Claude Desktop, or any local MCP client)

python server.py

Claude Desktop config example (claude_desktop_config.json):

{
  "mcpServers": {
    "google-sheets": {
      "command": "python",
      "args": ["/absolute/path/to/server.py"]
    }
  }
}

Remote / Streamable HTTP

MCP_TRANSPORT=streamable-http python server.py

Some MCP clients (e.g. Claude's web/Cowork custom connectors) only accept remotely-hosted servers reachable over HTTPS, authenticated via OAuth 2.0 -- not a local stdio process and not a bare API key/bearer token. If you need that, you'll additionally need to:

  1. Host this server somewhere with a public HTTPS URL (Cloud Run, Fly.io, a small VPS, etc.).
  2. Put an OAuth 2.0 authorization server in front of it (the mcp Python SDK has built-in support for this via FastMCP(auth_server_provider=...), which handles /authorize, /token, and token verification for you -- you mainly need to implement client/token storage).

That's genuine infrastructure work, not a config toggle -- budget for it accordingly if your use case needs a hosted connector rather than local stdio.

Example: seeding a tracker sheet

examples/seed_tracker.py shows how to drive the server's tool functions directly from a plain Python script (no MCP client needed): it appends a few rows to a Tracker tab and adds a Status dropdown to column E. The data in it is fictional -- use it as a template.

Optional: scheduled Gmail monitor

monitor_job_responses.py searches Gmail for messages matching a keyword query, skips anything that looks like a rejection or that's already been processed, and appends the rest to the sheet with Status = "Needs Review" for you to confirm/correct.

Because personal Gmail accounts can't grant a service account access (domain-wide delegation only works on Google Workspace), it uses its own OAuth "Desktop app" credentials:

  1. Enable the Gmail API in the same (or a different) Google Cloud project.
  2. Create an OAuth client ID of type Desktop app, download it, save as gmail_client_secret.json in this folder.
  3. Run python monitor_job_responses.py once, interactively -- it opens a browser for one-time consent, then caches a refresh token in gmail_token.json so future scheduled runs don't need a browser.

Then schedule it with cron or Task Scheduler, e.g.:

0 8 * * * cd /path/to/repo && python3 monitor_job_responses.py >> monitor.log 2>&1

Limitation: classification is keyword-based, not a language model -- it can catch obvious rejection phrasing but won't reliably distinguish subtler cases. Treat Needs Review rows as a draft, not ground truth.

Development

ruff check .   # lint
pytest         # unit tests (pure functions only -- no Google credentials needed)

CI runs both on every push/PR via GitHub Actions; a Jenkinsfile is also included for running the same pipeline on a Jenkins instance.

Roadmap

  • OAuth 2.0 authorization layer for the streamable-http transport, so the server can be hosted publicly and registered as a remote MCP connector (the mcp SDK's auth_server_provider hook does most of the heavy lifting).
  • Smarter response classification -- replace the keyword/regex rejection filter with an LLM pass so subtle "no news yet" vs. "interview scheduled" cases are handled correctly.
  • Sheet-based dedupe state for the monitor, so scheduled runs don't depend on a local JSON state file.

Security

  • service_account.json, gmail_client_secret.json, gmail_token.json, and .env are gitignored -- keep it that way, they're all credentials.
  • The service account can only touch sheets/files explicitly shared with it.
  • The Gmail OAuth token is scoped read-only (gmail.readonly).
  • Rotate/revoke credentials in Google Cloud Console if ever exposed.

License

MIT -- see LICENSE.

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选