@dguido/google-workspace-mcp

中文文档
3.4.4发布于 2026/02/23MITES Module构建来源已验证近 30 天下载 2743

Google Workspace MCP Server - Model Context Protocol server providing secure access to Google Drive, Docs, Sheets, Slides, Calendar, and Gmail through MCP clients e.g. Claude Desktop

原始使用文档
文档目录37 节
  1. Quick Start
  2. 1. Set Up Google Cloud
  3. 2. Configure Claude Desktop
  4. What You Can Do
  5. Google Cloud Setup
  6. 1. Create a Google Cloud Project
  7. 2. Enable Required APIs
  8. 3. Configure OAuth Consent Screen
  9. 4. Create OAuth 2.0 Credentials
  10. Configuration
  11. File Locations
  12. Environment Variables
  13. Token-Efficient Output (TOON)
  14. Service Configuration
  15. Available Tools
  16. Drive (29 tools)
  17. Google Docs (8 tools)
  18. Google Sheets (7 tools)
  19. Google Slides (10 tools)
  20. Calendar (7 tools)
  21. Gmail (14 tools)
  22. Contacts (6 tools)
  23. Unified (3 tools)
  24. Troubleshooting
  25. "OAuth credentials not found"
  26. "Authentication failed" or browser doesn't open
  27. "Tokens expired" or "Invalid grant"
  28. "API not enabled"
  29. "Login Required" even with valid tokens
  30. Security
  31. Avoiding Token Expiry
  32. Option 1: Publish Your OAuth App (Recommended)
  33. Option 2: Use Internal App (Workspace Only)
  34. Monitoring Token Age
  35. Development
  36. Origin
  37. License

Google Workspace MCP Server

MCP server providing Claude access to Google Drive, Docs, Sheets, Slides, Calendar, Gmail, and Contacts.

Quick Start

1. Set Up Google Cloud

  1. Go to the Google Cloud Console and create or select a project
  2. Enable all required APIs (one-click link)
  3. Go to APIs & Services > Credentials and create an OAuth 2.0 Client ID (Desktop app type)
  4. Copy the Client ID and Client Secret

2. Configure Claude Desktop

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json Windows: %APPDATA%\Claude\claude_desktop_config.json

{
  "mcpServers": {
    "google-workspace": {
      "command": "npx",
      "args": ["@dguido/google-workspace-mcp"],
      "env": {
        "GOOGLE_CLIENT_ID": "YOUR_CLIENT_ID.apps.googleusercontent.com",
        "GOOGLE_CLIENT_SECRET": "YOUR_CLIENT_SECRET",
        "GOOGLE_WORKSPACE_SERVICES": "drive,gmail,calendar"
      }
    }
  }
}

That's it. On first tool call, a browser window opens for Google OAuth consent. Tokens are saved automatically.

Alternative: file-based credentials

Download the credentials JSON from Google Cloud Console and save to ~/.config/google-workspace-mcp/credentials.json, then authenticate manually:

npx @dguido/google-workspace-mcp auth

See Advanced Configuration for file-based setup, named profiles, and multi-account setup.

What You Can Do

Create a Google Doc called "Project Plan" in /Work/Projects with an outline for Q1.
Search for files containing "budget" and organize them into the Finance folder.
Create a presentation called "Product Roadmap" with slides for Q1 milestones.

Google Cloud Setup

1. Create a Google Cloud Project

  • Go to the Google Cloud Console
  • Click "Select a project" > "New Project"
  • Name your project (e.g., "Google Drive MCP")

2. Enable Required APIs

  • Enable all APIs at once (one-click link)
  • Or manually: Go to "APIs & Services" > "Library" and enable: Google Drive API, Google Docs API, Google Sheets API, Google Slides API, Google Calendar API, Gmail API, People API
  • Go to "APIs & Services" > "OAuth consent screen"
  • Fill in app name, support email, and developer contact
  • Choose "External" (or "Internal" for Workspace)
  • Add your email as a test user
  • Add scopes: drive.file, documents, spreadsheets, presentations, drive, drive.readonly, calendar, gmail.modify, gmail.labels, contacts

4. Create OAuth 2.0 Credentials

  • Go to "APIs & Services" > "Credentials"
  • Click "+ CREATE CREDENTIALS" > "OAuth client ID"
  • Application type: Desktop app
  • Copy the Client ID and Client Secret (or download the JSON file)

Configuration

File Locations

Both credentials and tokens are stored in ~/.config/google-workspace-mcp/ by default:

FileDefault Path
OAuth credentials~/.config/google-workspace-mcp/credentials.json
Auth tokens~/.config/google-workspace-mcp/tokens.json

Environment Variables

VariableDescription
GOOGLE_CLIENT_IDOAuth Client ID (simplest setup — no credentials file needed)
GOOGLE_CLIENT_SECRETOAuth Client Secret (used with GOOGLE_CLIENT_ID)
GOOGLE_WORKSPACE_MCP_TOKEN_PATHCustom token storage location
GOOGLE_WORKSPACE_MCP_PROFILENamed profile for credential isolation
GOOGLE_WORKSPACE_SERVICESComma-separated list of services to enable

Token-Efficient Output (TOON)

For LLM-optimized responses that reduce token usage by 20-50%, enable TOON format:

{
  "mcpServers": {
    "google-workspace": {
      "command": "npx",
      "args": ["@dguido/google-workspace-mcp"],
      "env": {
        "GOOGLE_WORKSPACE_SERVICES": "drive,gmail,calendar",
        "GOOGLE_WORKSPACE_TOON_FORMAT": "true"
      }
    }
  }
}

TOON (Token-Oriented Object Notation) encodes structured responses more compactly than JSON by eliminating repeated field names. Savings are highest for list operations (calendars, events, emails, filters).

Service Configuration

By default, we recommend enabling only the core services (drive,gmail,calendar) as shown in Quick Start. This provides file management, email, and calendar capabilities without the complexity of document editing tools.

To enable additional services, add them to GOOGLE_WORKSPACE_SERVICES:

{
  "mcpServers": {
    "google-workspace": {
      "command": "npx",
      "args": ["@dguido/google-workspace-mcp"],
      "env": {
        "GOOGLE_WORKSPACE_SERVICES": "drive,gmail,calendar,docs,sheets,slides"
      }
    }
  }
}

Available services: drive, docs, sheets, slides, calendar, gmail, contacts

  • Omit GOOGLE_WORKSPACE_SERVICES entirely to enable all services
  • Unified tools (create_file, update_file, get_file_content) require drive, docs, sheets, and slides
  • When you limit services, only the OAuth scopes for those services are requested during authentication. If you change enabled services, re-authenticate to update granted scopes.

See Advanced Configuration for named profiles, multi-account setup, and environment variables.

Available Tools

Drive (29 tools)

search listFolder createFolder createTextFile updateTextFile deleteItem renameItem moveItem copyFile getFileMetadata exportFile shareFile getSharing removePermission listRevisions restoreRevision downloadFile uploadFile getStorageQuota starFile resolveFilePath batchDelete batchRestore batchMove batchShare listTrash restoreFromTrash emptyTrash getFolderTree

Google Docs (8 tools)

createGoogleDoc updateGoogleDoc getGoogleDocContent appendToDoc insertTextInDoc deleteTextInDoc replaceTextInDoc formatGoogleDocRange

Google Sheets (7 tools)

createGoogleSheet updateGoogleSheet getGoogleSheetContent formatGoogleSheetCells mergeGoogleSheetCells addGoogleSheetConditionalFormat sheetTabs

Google Slides (10 tools)

createGoogleSlides updateGoogleSlides getGoogleSlidesContent formatSlidesText formatSlidesShape formatSlideBackground createGoogleSlidesTextBox createGoogleSlidesShape slidesSpeakerNotes listSlidePages

Calendar (7 tools)

listCalendars listEvents getEvent createEvent updateEvent deleteEvent findFreeTime

Gmail (14 tools)

sendEmail draftEmail readEmail searchEmails deleteEmail modifyEmail downloadAttachment listLabels getOrCreateLabel updateLabel deleteLabel createFilter listFilters deleteFilter

Contacts (6 tools)

listContacts getContact searchContacts createContact updateContact deleteContact

Unified (3 tools)

createFile updateFile getFileContent

Full API Reference

Troubleshooting

"OAuth credentials not found"

Set GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET env vars in your MCP config, or save your credentials file to ~/.config/google-workspace-mcp/credentials.json.

"Authentication failed" or browser doesn't open

Ensure credential type is "Desktop app" (not "Web application"). The server uses an ephemeral port assigned by the OS, so no specific ports need to be available.

"Tokens expired" or "Invalid grant"

Apps in "Testing" status expire tokens after 7 days. Re-authenticate:

rm ~/.config/google-workspace-mcp/tokens.json
npx @dguido/google-workspace-mcp auth

To avoid weekly re-authentication: Publish your OAuth app (see Avoiding Token Expiry below).

"API not enabled"

Enable the missing API in Google Cloud Console > APIs & Services > Library.

"Login Required" even with valid tokens

Revoke app access at Google Account Permissions, clear tokens, and re-authenticate.

Full Troubleshooting Guide

Security

  • RFC 8252-compliant OAuth 2.0 with PKCE (Proof Key for Code Exchange)
  • Loopback-only authentication server (127.0.0.1)
  • State parameter for CSRF protection
  • Automatic token refresh
  • Tokens stored with 0600 permissions
  • All processing happens locally
  • Never commit credentials or tokens to version control

Avoiding Token Expiry

OAuth apps in "Testing" status automatically expire tokens after 7 days. To avoid weekly re-authentication:

  1. Go to Google Cloud Console > APIs & Services > OAuth consent screen
  2. Click "PUBLISH APP"
  3. For personal use, you don't need to complete Google's verification process
  4. Published apps keep tokens valid until explicitly revoked

Note: Publishing makes your app available to any Google user, but since you control the OAuth credentials, only you can authenticate.

Option 2: Use Internal App (Workspace Only)

If you have a Google Workspace account:

  1. Set User Type to "Internal" on the OAuth consent screen
  2. Internal apps don't expire tokens and don't require publishing

Monitoring Token Age

Use get_status to check token age. Tokens older than 6 days show a warning automatically.

Development

npm install
npm run build    # Compile TypeScript
npm run check    # typecheck + lint + format check
npm test         # Run tests

See Contributing Guide for project structure and development workflow.

Origin

This project is a substantial rewrite of piotr-agier/google-drive-mcp, originally created by Piotr Agier.

License

MIT - See LICENSE file for details.

版本与发布记录

@dguido/google-workspace-mcp 共发布 17 个版本,首次发布于 2026/01/23;过去 12 个月发布了 17 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
3.4.4latest2026/02/238 个月前
3.4.32026/02/178 个月前
3.4.22026/02/148 个月前
3.4.12026/02/148 个月前
3.4.02026/02/119 个月前
3.3.02026/02/119 个月前

关于 @dguido/google-workspace-mcp 的常见问题

@dguido/google-workspace-mcp 是什么?

Google Workspace MCP Server - Model Context Protocol server providing secure access to Google Drive, Docs, Sheets, Slides, Calendar, and Gmail through MCP clients e.g. Claude Desktop

如何安装 @dguido/google-workspace-mcp?

在项目目录运行 npm install @dguido/google-workspace-mcp,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 google-workspace-mcp,可以用 npx google-workspace-mcp 直接运行。

@dguido/google-workspace-mcp 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/dguido__google-workspace-mcp 是否存在。

@dguido/google-workspace-mcp 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@dguido/google-workspace-mcp 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@dguido/google-workspace-mcp 可以商用吗?

@dguido/google-workspace-mcp 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@dguido/google-workspace-mcp 的下载量有多少?

根据 npm 官方下载统计,@dguido/google-workspace-mcp 在 2026/10/12 – 2026/11/10 这 30 天内被下载 2,743 次,日均约 91 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@dguido/google-workspace-mcp 还在维护吗?

最新版本 3.4.4 发布于 2026/02/23(8 个月前);至今共发布 17 个版本,其中过去 12 个月发布了 17 个;首次发布于 2026/01/23。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。