Google Workspace MCP Server

Google Workspace MCP Server

A comprehensive MCP server integrating Google Docs, Sheets, Drive, Gmail, Calendar, and Apps Script APIs, featuring unique Apps Script support for AI-driven automation.

Category
访问服务器

README

Google Workspace MCP Server

License: MIT TypeScript Node.js MCP

English | Simplified Chinese | Traditional Chinese

A comprehensive MCP (Model Context Protocol) server providing full Google Workspace integration - including Google Docs, Sheets, Drive, Gmail, Calendar, and Apps Script APIs. Compatible with Claude Code CLI, Cursor IDE, and other MCP-compatible clients.

Unique Feature: This is the only Google Workspace MCP server that supports Apps Script API - enabling AI-driven automation of Google Sheets, Docs, and other Workspace products.

Demo Animation

Features

This server provides 72 tools across 6 Google Workspace services:

Service Tools Description
Google Docs 15 Read, write, format, style, images, tables, comments
Google Sheets 14 Read, write, format, create spreadsheets, manage sheets
Google Drive 16 List, search, create, move, copy, delete files and folders
Gmail 15 Search, read, send, drafts, labels, filters, threads
Google Calendar 8 List calendars, events, create, update, delete, free/busy
Apps Script 4 Create and manage bound scripts for automation

Google Docs (15 tools)

  • Document Operations: readGoogleDoc, appendToGoogleDoc, insertText, deleteRange, listDocumentTabs
  • Formatting: applyTextStyle, applyParagraphStyle, formatMatchingText, fixListFormatting
  • Structure: insertTable, editTableCell, insertPageBreak, findElement
  • Images: insertImageFromUrl, insertLocalImage

Google Docs Comments (6 tools)

  • Comment Management: listComments, getComment, addComment, replyToComment, resolveComment, deleteComment

Google Sheets (14 tools)

  • Data Operations: readSpreadsheet, writeSpreadsheet, appendSpreadsheetRows, clearSpreadsheetRange
  • Sheet Management: getSpreadsheetInfo, addSpreadsheetSheet, createSpreadsheet, listGoogleSheets
  • Formatting: formatSpreadsheetCells, setBasicFilter, clearBasicFilter

Google Drive (16 tools)

  • Discovery: listGoogleDocs, searchGoogleDocs, getRecentGoogleDocs, getDocumentInfo
  • Folders: createFolder, listFolderContents, getFolderInfo
  • File Operations: moveFile, copyFile, renameFile, deleteFile
  • Creation: createDocument, createFromTemplate

Apps Script (4 tools)

  • Script Management: createBoundScript, updateScriptContent, getScriptContent, getScriptProjects

Gmail (15 tools)

  • Messages: searchGmailMessages, getGmailMessage, getGmailMessagesBatch, getGmailAttachment
  • Send & Draft: sendGmailMessage, createGmailDraft
  • Threads: getGmailThread
  • Labels: listGmailLabels, createGmailLabel, deleteGmailLabel, modifyGmailMessageLabels
  • Filters: listGmailFilters, createGmailFilter, deleteGmailFilter
  • Management: trashGmailMessage

Google Calendar (8 tools)

  • Calendars: listCalendars
  • Events: getCalendarEvents, getCalendarEvent, createCalendarEvent, updateCalendarEvent, deleteCalendarEvent
  • Quick Actions: quickAddCalendarEvent
  • Availability: getCalendarFreeBusy

Prerequisites

  • Node.js v18+ with npm
  • Git for cloning the repository
  • Google Account with access to Google Workspace
  • MCP-compatible client: Claude Code CLI, Cursor IDE, or other MCP clients

Quick Start

Option A: Interactive Setup Wizard (Recommended)

git clone https://github.com/sputnicyoji/google-docs-mcp-for-claudecode.git
cd google-docs-mcp-for-claudecode
npm install
npm run setup

The setup wizard will:

  • Check your environment (Node.js, npm, build)
  • Auto-build TypeScript if needed
  • Guide you through credential setup
  • Run OAuth authorization
  • Generate and optionally auto-update Claude Code CLI config

Option B: Manual Setup

1. Clone and Install

git clone https://github.com/sputnicyoji/google-docs-mcp-for-claudecode.git
cd google-docs-mcp-for-claudecode
npm install
npm run build

2. Google Cloud Setup

  1. Go to Google Cloud Console
  2. Create a new project or select an existing one
  3. Enable the following APIs:
    • Google Docs API
    • Google Sheets API
    • Google Drive API
    • Apps Script API
    • Gmail API
    • Google Calendar API
  4. Configure OAuth consent screen:
    • Select "External" user type
    • Add required scopes: documents, spreadsheets, drive.file, script.projects, gmail, calendar
    • Add your email as a test user
  5. Create OAuth credentials:
    • Go to Credentials > Create Credentials > OAuth client ID
    • Select "Desktop app"
    • Download the JSON file and save as credentials.json in the project root

3. Authenticate

node ./dist/server.js

Follow the URL in the terminal to authorize access. After authorization, a token.json will be created.

4. Configure Claude Code CLI

Add to your Claude Code MCP configuration:

Windows (%APPDATA%\Claude\mcp_config.json):

{
  "mcpServers": {
    "google-workspace": {
      "command": "node",
      "args": ["C:\\path\\to\\google-docs-mcp-for-claudecode\\dist\\server.js"]
    }
  }
}

macOS/Linux (~/.config/Claude/mcp_config.json):

{
  "mcpServers": {
    "google-workspace": {
      "command": "node",
      "args": ["/path/to/google-docs-mcp-for-claudecode/dist/server.js"]
    }
  }
}

5. Configure Cursor IDE (Alternative)

This MCP server is fully compatible with Cursor IDE.

Project-Level Configuration - Create .cursor/mcp.json in your project root:

{
  "mcpServers": {
    "google-workspace": {
      "command": "node",
      "args": ["/path/to/google-docs-mcp-for-claudecode/dist/server.js"]
    }
  }
}

Global Configuration - Or configure via Cursor Settings > MCP.

Note: Cursor must be in Agent Mode (not Ask Mode) to access MCP tools.

Service Account Authentication (Alternative)

For automated/server environments, you can use a service account:

  1. Create a service account in Google Cloud Console
  2. Download the JSON key file
  3. Set environment variable:
    export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account-key.json
    
  4. Share your Google Docs/Sheets with the service account email

Usage Examples

Google Docs

Read document 1abc...xyz and return as markdown
Append "Meeting Notes" to document 1abc...xyz
Apply bold formatting to text "Important" in document 1abc...xyz
Insert a 3x4 table at index 100 in document 1abc...xyz

Google Sheets

Read range A1:D10 from spreadsheet 1abc...xyz
Write data to range A1:B5 in spreadsheet 1abc...xyz
Create a new spreadsheet titled "Sales Report 2024"
Add a new sheet named "Summary" to spreadsheet 1abc...xyz

Google Drive

List all Google Docs in my Drive
Search for documents containing "Project Alpha"
Create a new folder named "2024 Reports"
Move file 1abc...xyz to folder 2def...uvw

Apps Script

Create a bound script for spreadsheet 1abc...xyz
Update script content with custom functions
Get content of script project 1abc...xyz

Gmail

Search for unread emails from john@example.com
Read email message with ID abc123
Send an email to jane@example.com with subject "Meeting"
Create a draft reply to thread xyz789
List all Gmail labels
Create a filter to label emails from support@example.com

Google Calendar

List all my calendars
Get events for this week from my primary calendar
Create a meeting titled "Team Standup" tomorrow at 10am
Quick add event "Lunch with Sarah on Friday at noon"
Check free/busy times for next Monday
Delete event abc123 from my calendar

Project Structure

google-docs-mcp-for-claudecode/
  src/
    server.ts              # Main MCP server (tool definitions)
    clients.ts             # Google API client management
    auth.ts                # OAuth 2.0 / Service Account authentication
    types.ts               # TypeScript type definitions
    helpers/
      markdown.ts          # Docs to Markdown conversion
      index.ts             # Helper re-exports
    tools/
      scriptTools.ts       # Apps Script tools
      gmailTools.ts        # Gmail tools
      calendarTools.ts     # Calendar tools
      index.ts             # Tool registry
    googleDocsApiHelpers.ts    # Docs API helpers
    googleSheetsApiHelpers.ts  # Sheets API helpers
    gmailApiHelpers.ts         # Gmail API helpers
    calendarApiHelpers.ts      # Calendar API helpers
  dist/                    # Compiled JavaScript
  credentials.json         # OAuth credentials (not committed)
  token.json               # Auth token (not committed)

Security Notes

  • Never commit credentials.json or token.json to version control
  • The .gitignore file is configured to exclude sensitive files
  • For production, consider using secret management services
  • Service account keys should be stored securely

Known Limitations

  • Comment Anchoring: Programmatically created comments may show "original content deleted" instead of anchoring to specific text
  • Converted Documents: Some documents converted from other formats (e.g., Word) may not support all API operations
  • Quota Limits: Google APIs have usage quotas - check Google Cloud Console for limits

Troubleshooting

Connection Issues

  1. Verify the path in mcp_config.json is absolute and correct
  2. Ensure npm run build completed successfully
  3. Test manually: node ./dist/server.js

Authentication Errors

  1. Verify all required APIs are enabled
  2. Check that your email is added as a test user
  3. Delete token.json and re-authenticate if scopes changed

Tab/Sheet Errors

  1. Use listDocumentTabs or getSpreadsheetInfo to verify IDs
  2. Ensure you're using correct ID formats

Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Submit a pull request

Credits

Based on a-bonus/google-docs-mcp with additional enhancements:

  • Google Apps Script API integration
  • Gmail and Google Calendar API integration
  • Service Account authentication support
  • Modular code architecture
  • Multi-language documentation

License

MIT License - see LICENSE for details.

推荐服务器

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

官方
精选