Google Workspace集成服务

一个强大的模型上下文协议(MCP)服务器,无缝集成Claude Desktop与Google Workspace服务,使AI助手能够通过标准化MCP接口与Google Sheets、Gmail和Google Calendar进行交互。

  • by Ashishds
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 Ashishds/mcp-integration

使用说明

Claude Desktop的Google Workspace MCP集成

一个强大的模型上下文协议(MCP)服务器,将Claude Desktop与Google Workspace服务无缝集成。该项目使人工智能助手能够通过标准化的MCP界面与谷歌表格、Gmail和谷歌日历进行交互。

✨ 特性

📊 谷歌表格

  • 从电子表格中读取数据
  • 写入和更新单元格值
  • 将行附加到工作表
  • 获取电子表格元数据

📧 Gmail

  • 列出和搜索电子邮件
  • 获取详细的电子邮件信息
  • 发送电子邮件
  • 高级电子邮件过滤

📅 Google 日历

  • 列出即将举行的活动
  • 创建新事件
  • 更新现有事件
  • 删除事件
  • 获取活动详细信息

💾 数据库支持

  • PostgreSQL 通过MCP集成
  • MongoDB 通过MCP集成
  • 完整的CRUD操作
  • 查询执行和数据管理

🚀 快速开始

先决条件

  • Python 3.8或更高版本
  • 启用API的谷歌云项目:
    • 谷歌网页API
    • Gmail API
    • 谷歌日历API
  • 已安装Claude Desktop

安装

  1. 克隆存储库

    git clone https://github.com/yourusername/claude-google-workspace-integration.git
    cd claude-google-workspace-integration
    
  2. 安装依赖项

    pip install -r requirements.txt
    
  3. 设置Google OAuth

    • 下载 credentials.json 从 谷歌云控制台
    • 将其放置在项目根目录中
    • 运行安装脚本:
      python src/config_setup.py
      
  4. 配置应用程序

    • 复制 config.example.json 到 config.json
    • 填写您的配置详细信息
  5. 配置Claude桌面

    • 找到您的Claude Desktop配置文件:
      • 视窗: %APPDATA%\Claude\claude_desktop_config.json
      • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
      • Linux: ~/.config/Claude/claude_desktop_config.json
    • 添加MCP服务器配置(请参阅 claude_desktop_config.example.json)
    • 更新文件路径以匹配您的安装
    • 重新启动克劳德桌面

📖 用法

配置后,您可以通过Claude Desktop与Google Workspace服务进行交互:

谷歌表格

  • “从电子表格中的Sheet1!A1:B10读取数据”
  • “将这些值写在我的电子表格中:[['姓名','年龄',['约翰','30']]”
  • 将此行附加到工作表1:[任务、描述、状态]

Gmail

  • “显示我最近的10封电子邮件”
  • “搜索来自的电子邮件john@example.com"
  • “发送电子邮件至jane@example.com主题为“会议”,正文为“明天见”

Google 日历

  • “列出我即将举行的日历活动”
  • “为明天下午2点创建一个名为“团队会议”的日历活动”
  • “更新ID为xyz123的事件,将时间更改为下午3点”

🏗️ 项目结构

.
├── src/
│   ├── main_server.py          # Main MCP server
│   ├── auth_manager.py         # OAuth2 authentication
│   ├── sheets_manager.py       # Google Sheets integration
│   ├── email_manager.py        # Gmail integration
│   ├── calendar_manager.py     # Calendar integration
│   ├── mongo_handler.py        # MongoDB operations
│   ├── mongo_server.py         # MongoDB MCP server
│   ├── postgres_handler.py     # PostgreSQL operations
│   ├── postgres_server.py      # PostgreSQL MCP server
│   ├── automation_agent.py     # Automation agent
│   └── config_setup.py         # Setup script
├── config.example.json         # Configuration template
├── claude_desktop_config.example.json  # Claude Desktop config template
├── requirements.txt            # Python dependencies
└── README.md                   # This file

🔧 可用的MCP工具

谷歌表格(4个工具)

  • read_sheet -从某个范围读取数据
  • write_sheet -将数据写入范围
  • append_sheet -将行附加到工作表
  • get_sheet_info -获取电子表格元数据

Gmail(4个工具)

  • list_emails -列出收件箱中的电子邮件
  • get_email_detail -获取详细的电子邮件信息
  • send_email -发送电子邮件
  • search_emails -使用查询搜索电子邮件

谷歌日历(5个工具)

  • list_calendar_events -列出即将举行的活动
  • create_calendar_event -创建新事件
  • update_calendar_event -更新现有事件
  • delete_calendar_event -删除事件
  • get_calendar_event -获取活动详细信息

数据库工具

  • PostgreSQL: execute_query, execute_write, run_custom_sql, list_tables, describe_table, get_table_count
  • MongoDB: list_databases, list_collections, find_documents, insert_document, update_document, delete_document,以及更多

🔒 安全

⚠️ 重要安全注意事项:

  • 永不承诺 credentials.json, tokens.json,或 config.json 到版本控制
  • 这些文件已在 .gitignore
  • 确保您的OAuth凭据安全
  • 如果凭证被泄露,请定期轮换凭证

🐛 故障排除

服务器无法启动

  • 验证Python是否在您的系统PATH中
  • 检查Claude Desktop配置中的文件路径是否正确
  • 确保安装了所有依赖项: pip install -r requirements.txt

工具未出现

  • 检查Claude Desktop日志是否有错误
  • 验证身份验证: tokens.json 存在且有效
  • 重新运行安装程序: python src/config_setup.py
  • 完全重新启动克劳德桌面

身份验证错误

  • 重新验证: python src/config_setup.py
  • 验证 credentials.json 有效
  • 检查Google Cloud Console中是否启用了所有必需的API

📝 许可证

本项目按原样提供,供个人和教育使用。使用此集成时,请确保您遵守Google的API服务条款。

🤝 贡献

欢迎投稿!请随时提交拉取请求。对于重大更改,请先打开一个问题来讨论您想要更改的内容。

📄 致谢

🆘 支持

如果您遇到任何问题:

  1. 检查 故障排除 章节
  2. 查看 Google API文档
  3. 在GitHub上打开一个带有详细描述的问题

备注:本项目与Anthropic或谷歌无关,也没有得到Anthropics或谷歌的认可或关联。这是一个独立的集成项目。