Google Workspace MCP

Google Workspace MCP

Enables reading and extracting structured data from Google Docs and Sheets, including text, tables, formulas, and images. It supports advanced image handling and multiple authentication methods for interacting with private and public workspace files.

Category
访问服务器

README

Google Workspace MCP

Python MCP server for reading Google Docs and Google Sheets with structured output and better image handling.

What It Does

  • Reads Google Docs as structured JSON with paragraphs, tables, inline objects, positioned objects, and image metadata.
  • Reads Google Sheets values, grid data, formulas, notes, hyperlinks, and chip runs.
  • Extracts over-grid sheet images from Drive export -> XLSX.
  • Detects in-cell IMAGE("...") formulas separately from drawing exports.

Project Layout

google_workspace_mcp/
  cli.py        # command-line entrypoint
  client.py     # Google API auth + HTTP client
  common.py     # shared constants and parsing helpers
  docs.py       # Google Docs normalization helpers
  server.py     # FastMCP server instance
  sheets.py     # Google Sheets normalization helpers
  tools.py      # MCP tool definitions
mcp_google_workspace.py  # compatibility wrapper for local scripts/config
tests/

Authentication Options

Recommended for private files shared to your Google account: OAuth desktop client

Use a Google OAuth client ID for Desktop App if the files are private but shared to your personal Google account.

  1. Enable:
    • Google Sheets API
    • Google Docs API
    • Google Drive API
  2. Create an OAuth client ID with application type Desktop app.
  3. Download the client secret JSON.
  4. Set:
$env:GOOGLE_OAUTH_CLIENT_SECRETS_FILE="C:\path\to\oauth-client-secret.json"
  1. Run the one-time browser login flow:
google-workspace-mcp auth

This stores a refreshable token by default at:

$HOME\.google-workspace-mcp\oauth-token.json

Use this to inspect the cached token scopes and see which scopes are still missing:

google-workspace-mcp auth status

If you need to overwrite the cached token with a specific client secret file and token path, you can also run:

google-workspace-mcp auth login --client-secrets C:\path\to\oauth-client-secret.json --token-file C:\path\to\oauth-token.json

Recommended: service account

Use a Google Cloud service account for the most reliable setup.

  1. Enable:
    • Google Sheets API
    • Google Docs API
    • Google Drive API
  2. Create a service account key.
  3. Share the target Docs/Sheets files with the service account email.
  4. Set:
$env:GOOGLE_SERVICE_ACCOUNT_FILE="C:\path\to\service-account.json"

Public Sheets only: API key

Suitable for public Google Sheets reads. Not recommended for Docs or Drive export.

$env:GOOGLE_API_KEY="your_api_key"

Existing bearer token: OAuth access token

$env:GOOGLE_OAUTH_ACCESS_TOKEN="ya29...."

Installation

git clone https://github.com/NgoQuocViet2001/google-workspace-mcp.git
cd google-workspace-mcp
python -m venv .venv
.venv\Scripts\Activate.ps1
pip install -r requirements.txt

Install from GitHub

Option 1: clone the repository

git clone https://github.com/NgoQuocViet2001/google-workspace-mcp.git
cd google-workspace-mcp
python -m venv .venv
.venv\Scripts\Activate.ps1
pip install -r requirements.txt

Option 2: install directly from GitHub

pip install "git+https://github.com/NgoQuocViet2001/google-workspace-mcp.git"

If you install it this way, the console entrypoint is:

google-workspace-mcp

Running the Server

cd <path-to-repo>
.venv\Scripts\python.exe mcp_google_workspace.py

Or, if you installed it directly from GitHub:

google-workspace-mcp

To bootstrap OAuth for a private user account:

google-workspace-mcp auth

To inspect the current auth setup:

google-workspace-mcp auth status

Codex MCP Configuration

{
  "mcpServers": {
    "google-workspace": {
      "command": "<path-to-repo>/.venv/Scripts/python.exe",
      "args": ["<path-to-repo>/mcp_google_workspace.py"],
      "env": {
        "GOOGLE_OAUTH_CLIENT_SECRETS_FILE": "C:/path/to/oauth-client-secret.json",
        "GOOGLE_OAUTH_TOKEN_FILE": "C:/path/to/oauth-token.json"
      }
    }
  }
}

For public Sheets only, replace the env block with:

{
  "GOOGLE_API_KEY": "your_api_key"
}

If you installed the package directly from GitHub into an environment on your PATH, you can also use:

{
  "mcpServers": {
    "google-workspace": {
      "command": "google-workspace-mcp",
      "env": {
        "GOOGLE_OAUTH_CLIENT_SECRETS_FILE": "C:/path/to/oauth-client-secret.json",
        "GOOGLE_OAUTH_TOKEN_FILE": "C:/path/to/oauth-token.json"
      }
    }
  }
}

Available Tools

  • diagnose_google_auth
  • resolve_google_file
  • read_sheet_values
  • read_sheet_grid
  • get_sheet_row
  • search_sheet
  • sheet_to_json
  • inspect_sheet_images
  • read_google_doc
  • download_google_doc_images
  • export_google_file

Example Prompts

Replace placeholders such as <spreadsheet-id>, <sheet-name>, and <output-dir> with your own values.

Google Sheets URLs with gid and range are resolved automatically. If the caller omits the sheet prefix, the server uses the tab identified by gid.

Read one row from a sheet

get_sheet_row(
  "<spreadsheet-id>",
  "<sheet-name>",
  42,
  1
)

read_sheet_values also accepts row-style input such as <sheet-name>!42:42 and normalizes it to a valid full-row A1 range automatically.

Read directly from a Sheets URL with gid and range

read_sheet_values(
  "https://docs.google.com/spreadsheets/d/<spreadsheet-id>/edit?gid=<gid>#gid=<gid>&range=38:38"
)

Read grid data with formulas, notes, and links

read_sheet_grid(
  "<spreadsheet-id>",
  "<sheet-name>!A1:Z200"
)

Search across a sheet

search_sheet(
  "<spreadsheet-id>",
  "login"
)

If you pass a Sheets URL with gid, search_sheet() searches only that tab by default instead of scanning the full workbook.

Convert a sheet to JSON

sheet_to_json(
  "<spreadsheet-id>",
  "<sheet-name>",
  1
)

Extract images from a sheet

inspect_sheet_images(
  "<spreadsheet-id>",
  "<sheet-name>",
  "C:/path/to/output/sheet-images"
)

Read a Google Doc with text and image metadata

read_google_doc(
  "https://docs.google.com/document/d/<doc-id>/edit",
  null,
  false,
  null
)

Download images from a Google Doc

download_google_doc_images(
  "https://docs.google.com/document/d/<doc-id>/edit",
  "C:/path/to/output/doc-images",
  null
)

Practical Limitations

  • Google Docs image metadata is available directly through the Docs API, so document extraction is strong.
  • Google Sheets does not expose over-grid images as cleanly as cell data, so this server uses XLSX export to recover them.
  • In-cell IMAGE("...") formulas are detected separately from exported drawing images.
  • Private files shared to your user account should use the OAuth desktop client flow.
  • Private files shared to a robot identity should use a service account.
  • An API key is only suitable for public Sheets.

推荐服务器

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

官方
精选