Google Workspace集成服务器

通过MCP服务器将Claude AI与Google Workspace(Gmail、日历、云端硬盘、Meet)深度集成,实现邮件管理、会议安排、文件操作和智能工作流自动化。

  • by SmitPatel-31
  • JavaScript
  • 本地部署
  • 5 星标
  • 更新于
在 GitHub 查看 SmitPatel-31/gmail-drive-mcp-server

使用说明

Gmail云端日历MCP服务器

通过这种全面的MCP服务器集成,将Claude转变为Google Workspace的巨头。

这有什么作用

把克劳德变成你的个人生产力助理,可以:

  • 管理Gmail -发送、组织、搜索和分析电子邮件
  • 控制谷歌日历 -创建会议、安排活动、发送邀请
  • 整理谷歌云端硬盘 -创建、共享和管理文件和文件夹
  • 生成Google Meet链接 -即时视频会议设置
  • 执行复杂的工作流程 -跨所有服务的多步自动化

主要特点

电子邮件管理

  • 使用高级Gmail查询搜索电子邮件
  • 发送带有附件的专业电子邮件
  • 使用标签、存档、星号、删除进行组织
  • 分析电子邮件模式和统计数据
  • 自动管理收件箱组织

会议和日历

  • 立即创建Google Meet会议
  • 用自然语言安排(“今天下午2点”)
  • 全球团队的自动时区处理
  • 发送日历邀请和提醒
  • 列出并管理即将召开的会议

文件操作

  • 创建和编辑谷歌文档、表格、幻灯片
  • 将文件组织到结构化文件夹中
  • 使用精细权限共享文件
  • 与团队无缝协作
  • 批量文件操作和管理

🔄 智能工作流

  • 项目设置:在一个命令中创建会议+文件夹+邀请
  • 活动协调:完全的活动策划自动化
  • 研究管理:组织学术/专业研究
  • 团队协作:简化集团项目工作流程

建筑

---
config:
  theme: default
---
graph TB
    User[User<br/>Master's Student] --> Claude[🤖 Claude AI<br/>Chat Interface]
    Claude <==> MCP[MCP Server<br/>The Brain<br/>Node.js + ES Modules]
    MCP --> Auth[OAuth2 Auth<br/>Token Management<br/>Security Layer]
    MCP --> Gmail[Gmail Service<br/>Email Operations]
    MCP --> Calendar[Calendar Service<br/>Meeting Management]
    MCP --> Drive[Drive Service<br/>File Operations]
    MCP --> Meet[Meet Integration<br/>Video Conferencing]
    Auth --> GoogleAuth[Google OAuth2<br/>Secure Authentication]
    Gmail --> GmailAPI[Gmail API<br/>Google Servers]
    Calendar --> CalendarAPI[Calendar API<br/>Google Servers]
    Drive --> DriveAPI[Drive API<br/>Google Servers]
    Meet --> MeetAPI[Meet API<br/>Google Servers]
    Claude -.->|"Create meeting for 2 PM"| MCP
    MCP -.->|"Tool Call: create_meeting"| Calendar
    Calendar -.->|"API Request"| CalendarAPI
    CalendarAPI -.->|"Meeting Created"| Calendar
    Calendar -.->|"Success Response"| MCP
    MCP -.->|"Meeting created successfully!"| Claude
    classDef userStyle fill:#e1f5fe,stroke:#0277bd,stroke-width:2px
    classDef claudeStyle fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px
    classDef mcpStyle fill:#e8f5e8,stroke:#2e7d32,stroke-width:3px
    classDef serviceStyle fill:#fff3e0,stroke:#f57c00,stroke-width:2px
    classDef apiStyle fill:#fce4ec,stroke:#c2185b,stroke-width:2px
    classDef authStyle fill:#fff8e1,stroke:#f9a825,stroke-width:2px
    class User userStyle
    class Claude claudeStyle
    class MCP mcpStyle
    class Gmail,Calendar,Drive,Meet serviceStyle
    class GmailAPI,CalendarAPI,DriveAPI,MeetAPI apiStyle
    class Auth,GoogleAuth authStyle

工作流程

---
config:
  theme: redux-dark
---
sequenceDiagram
    participant U as User
    participant C as Claude
    participant MCP as MCP Server
    participant Auth as Auth Manager
    participant Gmail as Gmail Service
    participant Cal as Calendar Service
    participant Drive as Drive Service
    participant G as Google APIs
    Note over U,G: Example: "Create team meeting and send invites"
    U->>C: "Create a meeting for 2 PM today and invite the team"
    C->>MCP: Tool Call: create_meeting_and_send
    MCP->>Auth: Check authentication
    Auth-->>MCP: Tokens valid
    par Create Meeting
        MCP->>Cal: Create calendar event
        Cal->>G: POST /calendar/events
        G-->>Cal: Event created with Meet link
        Cal-->>MCP: Meeting details
    and Send Invites
        MCP->>Gmail: Send calendar invites
        Gmail->>G: POST /gmail/send
        G-->>Gmail: Emails sent
        Gmail-->>MCP: Invites sent
    and Create Document
        MCP->>Drive: Create meeting notes doc
        Drive->>G: POST /drive/files
        G-->>Drive: Document created
        Drive-->>MCP: Document ready
    end
    MCP->>MCP: Compile results
    MCP-->>C: Success response with details
    C-->>U: "Meeting created! Invites sent to team. Notes doc ready."
    Note over U,G: Total time: ~10 seconds for complex workflow

服务器组件

---
config:
  layout: dagre
  theme: base
  look: classic
---
flowchart LR
 subgraph subGraph0["Core Components"]
        Server["MCP Server<br>- Request Handler<br>- Tool Registry<br>- Response Formatter"]
        Auth["Auth Manager<br>- OAuth2 Flow<br>- Token Management<br>- Security Layer"]
  end
 subgraph subGraph1["Service Layer"]
        Gmail["Gmail Service<br>- Search emails<br>- Send emails<br>- Manage labels<br>- Email analysis"]
        Calendar["Calendar Service<br>- Create events<br>- Schedule meetings<br>- Generate Meet links<br>- Timezone handling"]
        Drive["Drive Service<br>- Create files<br>- Share documents<br>- Organize folders<br>- Manage permissions"]
        Meet["Meet Integration<br>- Coordinate workflows<br>- Format invitations<br>- Send reminders<br>- Handle RSVPs"]
  end
 subgraph subGraph2["Tool Handlers"]
        EmailTools["Email Tools<br>- search_emails<br>- send_email<br>- delete_email<br>- create_label"]
        CalendarTools["Calendar Tools<br>- create_meeting<br>- schedule_event<br>- send_reminder<br>- list_meetings"]
        DriveTools["Drive Tools<br>- create_file<br>- share_file<br>- organize_folder<br>- update_permissions"]
        WorkflowTools["Workflow Tools<br>- create_and_send_meet<br>- project_setup<br>- bulk_operations<br>- smart_scheduling"]
  end
 subgraph subGraph3["Schema Definitions"]
        Schemas["Tool Schemas<br>- Input validation<br>- Response formatting<br>- Error handling<br>- Type definitions"]
  end
 subgraph subGraph4["MCP Server (The Brain)"]
    direction TB
        subGraph0
        subGraph1
        subGraph2
        subGraph3
  end
 subgraph subGraph5["External Services"]
        GoogleAPIs["Google APIs<br>- Gmail API<br>- Calendar API<br>- Drive API<br>- OAuth2 API"]
  end
 subgraph subGraph6["Claude Integration"]
        Claude["Claude AI<br>- Natural language<br>- Tool discovery<br>- Response parsing<br>- Context management"]
  end
    Server --> Auth & Gmail & Calendar & Drive & Meet
    Gmail --> EmailTools & GoogleAPIs
    Calendar --> CalendarTools & GoogleAPIs
    Drive --> DriveTools & GoogleAPIs
    Meet --> WorkflowTools
    EmailTools --> Schemas
    CalendarTools --> Schemas
    DriveTools --> Schemas
    WorkflowTools --> Schemas
    Auth --> GoogleAPIs
    Claude <--> Server
     Server:::coreStyle
     Auth:::coreStyle
     Gmail:::serviceStyle
     Calendar:::serviceStyle
     Drive:::serviceStyle
     Meet:::serviceStyle
     EmailTools:::toolStyle
     CalendarTools:::toolStyle
     DriveTools:::toolStyle
     WorkflowTools:::toolStyle
     Schemas:::toolStyle
     GoogleAPIs:::externalStyle
     Claude:::claudeStyle
    classDef coreStyle fill:#e8f5e8,stroke:#2e7d32,stroke-width:2px
    classDef serviceStyle fill:#fff3e0,stroke:#f57c00,stroke-width:2px
    classDef toolStyle fill:#e3f2fd,stroke:#1976d2,stroke-width:2px
    classDef externalStyle fill:#fce4ec,stroke:#c2185b,stroke-width:2px
    classDef claudeStyle fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px

安装

先决条件

  • Node.js 18+ 安装
  • 谷歌云项目 启用了API
  • Claude Pro订阅 (用于MCP支持)
  • OAuth2凭据 从谷歌云控制台

步骤1:克隆存储库

git clone https://github.com/SmitPatel-31/gmail-drive-mcp-server
cd gmail-drive-mcp-server
npm install

第二步:谷歌云设置

  1. 创建谷歌云项目

  2. 启用所需的API

    - Gmail API
    - Google Calendar API  
    - Google Drive API
    
  3. 创建OAuth2凭据

    • 转到“API和服务”→ “凭据”
    • 创建“OAuth 2.0客户端ID”
    • 下载为 credentials.json
    • 放置在项目根目录中

步骤3:身份验证设置

# Run interactive authentication setup
node auth.js

# Follow the prompts to:
# 1. Visit the authorization URL
# 2. Grant permissions
# 3. Enter the authorization code
# 4. Tokens will be saved automatically

步骤4:启动服务器

# Start the MCP server
npm start


### Step 5: Configure Claude

Add the MCP server to your Claude configuration:

```json
{
  "mcpServers": {
    "gmail-drive-server": {
      "command": "node",
      "args": ["path/to/your/server.js"],
      "env": {}
    }
  }
}

可用工具

Gmail操作

工具 说明 示例
search_emails 使用Gmail查询搜索电子邮件 “查找来自的电子邮件john@company.com关于项目”
send_email 发送带有附件的电子邮件 “向团队发送进度更新”
delete_email 删除特定电子邮件 “删除该垃圾邮件”
archive_email 存档电子邮件 “存档所有新闻通讯”
create_label 创建Gmail标签 “创建‘重要项目’标签”
analyze_email_patterns 电子邮件统计和分析 “显示我上个月的电子邮件模式”

日历和会议

工具 说明 示例
create_meeting 使用Meet链接安排会议 “创建今天下午2点的团队会议”
create_quick_meet 5分钟后的即时会议 “与团队快速会面”
create_instant_meet 会议将在2分钟后开始 “立即拨打紧急电话”
create_meeting_natural 自然语言调度 “今天下午6点至8点为学习小组”
send_meet_reminder 发送会议提醒 “提醒大家明天的演示”
list_upcoming_meetings 显示即将举行的会议 “这周我有什么会议?”

谷歌云端硬盘运营

工具 说明 示例
create_file 创建文档、工作表、幻灯片 “创建项目建议书文档”
update_file 编辑现有文件 “更新会议笔记”
share_file 共享权限 “与团队共享编辑权限”
create_folder 使用文件夹进行组织 “创建Q4计划文件夹”
move_file 重新组织文件 “将所有草稿移动到Final文件夹”
search_drive_files 快速查找文件 “查找所有包含“预算”的文件”

工作流程自动化

工具 说明 示例
create_meet_and_send 会议+电子邮件自动化 “创建客户电话并发送专业邀请”
project_setup 完成项目初始化 “使用所有资源设置新网站项目”
bulk_email_management 处理多封电子邮件 “整理我的收件箱并回复紧急邮件”

使用示例

学术用例

// Thesis defense preparation
"Set up my thesis defense for next Friday at 2 PM, invite my committee, create presentation template, and send preparation checklist"

// Group project coordination  
"Create our capstone project workspace: weekly meeting, shared folder, task tracking document, and team communication setup"

// Research organization
"Organize my literature review: create categorized folders, move research papers, and set up citation tracking"

专业工作流程

// Client meeting setup
"Schedule client presentation for Thursday 10 AM, create agenda document, invite stakeholders, and send professional confirmation"

// Team collaboration
"Set up sprint planning: create meeting, invite dev team, prepare backlog document, and schedule follow-up sessions"

// Event coordination
"Organize company hackathon: create event calendar, set up registration, prepare resource folders, and coordinate communications"

个人生产力

// Weekly planning
"Set up my weekly review meeting, create planning template, organize last week's documents, and prepare agenda"

// Travel coordination
"Plan conference trip: create itinerary, share with team, set up out-of-office, and coordinate coverage meetings"

🔒 安全与隐私

数据保护

  • OAuth2身份验证:行业标准安全身份验证
  • 本地令牌存储:令牌存储在本地,从不传输给第三方
  • 最低权限:仅请求必要的Google API范围
  • 无数据收集:你的数据仅限于你、克劳德和谷歌之间

最佳实践

  • 保持 credentials.json 和 token.json 安全
  • 从不将身份验证文件提交到版本控制
  • 定期审查Google帐户权限
  • 使用环境变量进行敏感配置

合规

  • 符合GDPR(不收集数据)
  • 学生友好型(适用于教育账户)
  • 企业就绪(支持G套件/工作区)

故障排除

常见问题

身份验证错误

# Clear tokens and re-authenticate
rm token.json
node auth.js
node test-auth.js

API费率限制

# Check quota usage in Google Cloud Console
# Implement exponential backoff (already included)

权限错误

# Verify API enablement
# Check OAuth2 scope configuration
# Confirm credentials.json format

错误代码

代码 描述 解决方案
AUTH_FAILED 身份验证问题 重新运行身份验证设置
API_QUOTA_EXCEEDED 已达到速率限制 请等待并重试
INVALID_PERMISSIONS 范围问题 检查OAuth2范围
NETWORK_ERROR 连接问题 检查互联网连接

添加新功能

  1. 创建服务方法

    // In appropriate service file
    async newFeature(params) {
      // Implementation
    }
    
  2. 定义工具架构

    // In tool-definations.js
    {
      name: 'new_feature',
      description: 'What it does',
      inputSchema: { /* schema */ }
    }
    
  3. 添加工具处理程序

    // In tool-handlers.js
    async handleNewFeature(args) {
      // Handle the tool call
    }
    
  4. 注册工具

    // In server.js switch statement
    case 'new_feature':
      return await this.handleNewFeature(args);
    

贡献

我们欢迎捐款!以下是如何开始:

开发设置

# Fork the repository
git clone https://github.com/your-username/gmail-drive-mcp-server
cd gmail-drive-mcp-server

# Create feature branch
git checkout -b feature/amazing-feature

# Install dependencies
npm install

贡献指南

  1. 代码的风格:遵循现有模式和ESLint规则
  2. 文档:更新README并添加代码注释
  3. 承诺:使用常规提交消息

拉取请求流程

  1. 提交带有清晰描述的拉取请求

路线图

当前版本(v2.0)

  • ✅ Gmail、日历、驱动器集成
  • ✅ Google Meet自动化
  • ✅ 自然语言时间解析
  • ✅ 全面的错误处理
  • ✅ 安全最佳实践

许可证

此项目根据MIT许可证获得许可-请参阅 许可证 文件以获取详细信息。

致谢

  • Anthropic Claude和MCP框架
  • 谷歌 获取全面的API和文档
  • 开源社区 寻求灵感和最佳实践
  • 贡献者 谁让这个项目变得更好

支持

获取帮助

  • 文档:查看文档/文件夹以获取详细指南
  • 错误报告:使用复制步骤创建GitHub问题
  • 功能请求:打开GitHub讨论
  • 直接接触: [patel.smit3131@gmail.com]

社区


⭐ 如果这个仓库能帮助你提高工作效率,请为其加星!

🔗 与需要工作流自动化的朋友分享

🤝 让它变得更好


内置于❤️ 这位痴迷于生产力的硕士生厌倦了手动工作流程。