Google Workspace MCP Server

Google Workspace MCP Server

Yulikepython

云平台
访问服务器

README

Google Workspace MCP 服务器

本项目基于以下仓库创建: epaproditus/google-workspace-mcp-server

提供 Google Workspace 功能(日历、邮件)作为 MCP 服务器的应用程序

功能

Gmail 功能

  • list_emails: 从收件箱中列出带有过滤条件的最近邮件
  • search_emails: 使用 Gmail 查询语法进行高级邮件搜索
  • send_email: 支持抄送 (CC) 和密送 (BCC) 的邮件发送
  • modify_email: 邮件标签管理(存档、垃圾箱、已读/未读)

日历功能

  • list_events: 列出指定日期范围内的日程
  • create_event: 创建带有参与者的日程
  • update_event: 更新现有日程
  • delete_event: 删除日程

必要条件

  1. Node.js: 安装 Node.js 20 或更高版本
  2. Google Cloud Console 设置:
    • 访问 Google Cloud Console
    • 创建新项目或选择现有项目
    • 启用 Gmail API 和 Google Calendar API:
      1. 转到 "APIs & Services" > "Library"
      2. 搜索 "Gmail API" 并启用
      3. 搜索 "Google Calendar API" 并启用
    • 设置 OAuth 2.0 凭据:
      1. 转到 "APIs & Services" > "Credentials"
      2. 点击 "Create Credentials" > "OAuth client ID"
      3. 选择 "Desktop application"
      4. 在 "Authorized redirect URIs" 中添加 http://localhost:4100/code
      5. 记录 Client ID 和 Client Secret

设置步骤

  1. 克隆和安装仓库:

    git clone https://github.com/Yulikepython/gogole-workspace-mcp-server-by-itc.git
    cd google-workspace-mcp-server-by-itc
    npm install
    
  2. 设置凭据:

    # 复制 credentials.json.example
    cp credentials.json.example credentials.json
    

    编辑 credentials.json 如下:

    {
      "web": {
        "client_id": "YOUR_CLIENT_ID",
        "client_secret": "YOUR_CLIENT_SECRET",
        "redirect_uris": ["http://localhost:4100/code"],
        "auth_uri": "https://accounts.google.com/o/oauth2/auth",
        "token_uri": "https://oauth2.googleapis.com/token"
      }
    }
    
  3. 获取刷新令牌:

    node get-refresh-token.js
    

    这将会:

    • 打开浏览器并执行 Google OAuth 认证
    • 需要以下权限:
      • https://www.googleapis.com/auth/gmail.modify
      • https://www.googleapis.com/auth/calendar
      • https://www.googleapis.com/auth/gmail.send
    • 凭据将保存到 token.json
    • 刷新令牌将显示在控制台中
  4. 配置 MCP 设置: 将服务器设置添加到 MCP 配置文件:

    • VSCode Claude 扩展: ~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
    • Claude 桌面应用: ~/Library/Application Support/Claude/claude_desktop_config.json

    mcpServers 对象中添加以下内容:

    {
      "mcpServers": {
        "google-workspace": {
          "command": "node",
          "args": ["/path/to/google-workspace-server/build/index.js"],
          "env": {
            "GOOGLE_CLIENT_ID": "your_client_id",
            "GOOGLE_CLIENT_SECRET": "your_client_secret",
            "GOOGLE_REFRESH_TOKEN": "your_refresh_token"
          }
        }
      }
    }
    
  5. 构建和运行:

    npm run build
    
  6. 添加部署配置 (.env):

    要使用 deploy 脚本,需要 .env 文件。

    cp .env.example .env
    

    .env 中设置以下环境变量:

    SSH_USER=your_ssh_user
    SSH_HOST=your.ssh.host
    SSH_PATH=/your/deploy/path
    

npm scripts

命令 说明
npm run build 创建 bundle 并赋予执行权限
npm run start 在本地构建并运行
npm run clean 删除构建产物
npm run deploy 构建后,将文件部署到生产环境
npm run logs 实时显示生产环境的应用程序日志

使用例

Gmail 操作

  1. 最近邮件列表:

    {
      "maxResults": 5,
      "query": "is:unread"
    }
    
  2. 邮件搜索:

    {
      "query": "from:example@gmail.com has:attachment",
      "maxResults": 10
    }
    
  3. 邮件发送:

    {
      "to": "recipient@example.com",
      "subject": "Hello",
      "body": "Message content",
      "cc": "cc@example.com",
      "bcc": "bcc@example.com"
    }
    
  4. 邮件标签修改:

    {
      "id": "message_id",
      "addLabels": ["UNREAD"],
      "removeLabels": ["INBOX"]
    }
    

日历操作

  1. 日程列表:

    {
      "maxResults": 10,
      "timeMin": "2024-01-01T00:00:00Z",
      "timeMax": "2024-12-31T23:59:59Z"
    }
    
  2. 日程创建:

    {
      "summary": "Team Meeting",
      "location": "Conference Room",
      "description": "Weekly sync-up",
      "start": "2024-01-24T10:00:00Z",
      "end": "2024-01-24T11:00:00Z",
      "attendees": ["colleague@example.com"]
    }
    
  3. 日程更新:

    {
      "eventId": "event_id",
      "summary": "Updated Meeting Title",
      "location": "Virtual",
      "start": "2024-01-24T11:00:00Z",
      "end": "2024-01-24T12:00:00Z"
    }
    
  4. 日程删除:

    {
      "eventId": "event_id"
    }
    

故障排除

  1. 认证问题:

    • 确认已授予所需的 OAuth 范围
    • 确认 Client ID 和 Secret 正确
    • 确认刷新令牌有效
  2. API 错误:

    • 在 Google Cloud Console 中检查 API 配额和限制
    • 确认已在项目中启用 API
    • 确认请求参数格式正确

许可证

MIT

推荐服务器

contentful-mcp

contentful-mcp

在你的 Contentful Space 中更新、创建、删除内容、内容模型和资源。

精选
TypeScript
Supabase MCP Server

Supabase MCP Server

一个模型上下文协议(MCP)服务器,它提供对 Supabase 管理 API 的编程访问。该服务器允许 AI 模型和其他客户端通过标准化的接口来管理 Supabase 项目和组织。

精选
JavaScript
Azure MCP Server

Azure MCP Server

通过 Claude Desktop 实现与 Azure 服务的自然语言交互,支持资源管理、订阅处理和租户选择,并提供安全身份验证。

官方
本地
TypeScript
Settlemint

Settlemint

利用 SettleMint 的模型上下文协议服务器,无缝地与企业区块链基础设施交互。通过人工智能驱动的助手构建、部署和管理智能合约,从而简化您的区块链开发工作流程,实现最高的效率。

官方
本地
TypeScript
Brev

Brev

在云端运行、构建、训练和部署机器学习模型。

官方
本地
Python
Story Protocol SDK MCP

Story Protocol SDK MCP

这个服务器提供 MCP(模型上下文协议)工具,用于与 Story 的 Python SDK 交互。 功能: * 获取许可条款 * 使用 PIL 条款铸造和注册 IP 资产 * 铸造许可代币 * 向钱包发送 $IP * 通过 Pinata [外部] 上传图像到 ipfs * 通过 Pinata [外部] 上传 IP 和 NFT 元数据

官方
Python
Tembo MCP Server

Tembo MCP Server

一个 MCP 服务器,它使 Claude 能够与 Tembo Cloud 平台 API 交互,从而允许用户通过自然语言管理 Tembo Cloud 资源。

官方
TypeScript
Workers MCP

Workers MCP

一个连接 Claude Desktop 和其他 MCP 客户端到 Cloudflare Workers 的软件包,从而可以通过模型上下文协议,使用自然语言访问自定义功能。

官方
TypeScript
Appwrite MCP Server

Appwrite MCP Server

一个模型上下文协议服务器,允许 AI 助手与 Appwrite 的 API 交互,从而提供管理 Appwrite 项目中数据库、用户、函数、团队和其他资源的工具。

官方
Python
MCP2Lambda

MCP2Lambda

通过 MCP 协议,人工智能模型能够与 AWS Lambda 函数交互,从而在安全的环境中访问私有资源、实时数据和自定义计算。

官方
Python