首页
学习
活动
专区
圈层
工具
发布
MCP广场 >详情页
MCP G套件服务器2026-10-22201分享添加福利群:解决AI开发者的「MCP实战痛点」
MCP服务器用于与Google产品交互。
By MarkusPfundstein
2026-10-22201
github
详情内容

mcp-gsuite MCP服务器

smithery徽章 一个用于与Google产品交互的MCP服务器。

示例提示

目前,这个MCP服务器支持Gmail和日历集成,并具备以下功能:

  1. 通用功能
  • 支持多个Google账户
  1. Gmail功能
  • 获取您的Gmail用户信息
  • 使用灵活搜索查询邮件(例如未读邮件、来自特定发件人、日期范围、含附件的邮件)
  • 通过ID检索完整邮件内容
  • 创建新草稿邮件(可设置收件人、主题、正文和抄送选项)
  • 删除草稿邮件
  • 回复现有邮件(可选择立即发送或保存为草稿)
  • 通过ID一次性检索多封邮件
  • 将邮件中的多个附件保存到本地系统
  1. 日历功能
  • 管理多个日历
  • 获取指定时间范围内的日历事件
  • 创建日历事件(可设置):
    • 标题、开始/结束时间
    • 可选的位置和描述
    • 可选的参会者
    • 自定义时区支持
    • 通知偏好设置
  • 删除日历事件

您可以尝试的示例提示:

  • 获取我最新的未读消息

  • 搜索Scrum Master发给我的邮件

  • 获取会计部门的所有邮件

  • 提取关于ABC的邮件并总结内容

  • 给Alice的最后一封邮件写一个得体的回复并保存为草稿

  • 用感谢语回复Bob的邮件并保存为草稿

  • 我明天有哪些安排?

  • 查看我个人账户下周的家庭日程

  • 我需要下周和Tim安排一个2小时的活动,建议几个时间段

快速开始

安装

通过Smithery安装

要通过Smithery自动为Claude Desktop安装mcp-gsuite:

npx -y @smithery/cli install mcp-gsuite --client claude
OAuth 2.0

Google Workspace(G Suite)API需要OAuth2授权。请按照以下步骤设置认证:

  1. 创建OAuth2凭证:

    • 访问Google Cloud控制台
    • 创建新项目或选择现有项目
    • 为您的项目启用Gmail API和Google日历API
    • 进入"凭证"→"创建凭证"→"OAuth客户端ID"
    • 选择"桌面应用"或"Web应用"作为应用类型
    • 使用所需信息配置OAuth同意屏幕
    • 添加授权重定向URI(本地开发时包含http://localhost:4100/code)
  2. 所需的OAuth2范围:

   [
     "openid",
     "https://mail.google.com/",
     "https://www.googleapis.com/auth/calendar",
     "https://www.googleapis.com/auth/userinfo.email"
   ]
  1. 然后在您的工作目录中创建一个.gauth.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"
    }
}
  1. 创建一个.accounts.json文件,包含账户信息
{
    "accounts": [
        {
            "email": "alice@bob.com",
            "account_type": "personal",
            "extra_info": "你想告诉Claude的附加信息:例如'包含家庭日历'"
        }
    ]
}

您可以指定多个账户。确保它们在您的Google认证应用中有访问权限。extra_info字段特别有用,您可以在这里添加您想让AI了解的关于账户的信息(例如它是否有特定的日程)

注意:当您第一次为特定账户执行某个工具时,会打开一个浏览器,重定向到Google并要求您的凭证、范围等信息。登录成功后,它会将凭证存储在一个名为.oauth.{email}.json的本地文件中。授权后,将使用刷新令牌。

Claude Desktop

在MacOS上:~/Library/Application\ Support/Claude/claude_desktop_config.json

在Windows上:%APPDATA%/Claude/claude_desktop_config.json

开发/未发布服务器配置
{
  "mcpServers": {
    "mcp-gsuite": {
      "command": "uv",
      "args": [
        "--directory",
        "<dir_to>/mcp-gsuite",
        "run",
        "mcp-gsuite"
      ]
    }
  }
}

注意:您还可以使用uv run mcp-gsuite --accounts-file /path/to/custom/.accounts.json指定不同的账户文件,或使用--credentials-dir /path/to/custom/credentials指定不同的凭证目录。

{
  "mcpServers": {
    "mcp-gsuite": {
      "command": "uv",
      "args": [
        "--directory",
        "<dir_to>/mcp-gsuite",
        "run",
        "mcp-gsuite",
        "--accounts-file",
        "/path/to/custom/.accounts.json",
        "--credentials-dir",
        "/path/to/custom/credentials"
      ]
    }
  }
}
已发布服务器配置
{
  "mcpServers": {
    "mcp-gsuite": {
      "command": "uvx",
      "args": [
        "mcp-gsuite",
        "--accounts-file",
        "/path/to/custom/.accounts.json",
        "--credentials-dir",
        "/path/to/custom/credentials"
      ]
    }
  }
}

配置选项

MCP服务器可以通过几个命令行选项进行配置,以指定认证和账户信息的自定义路径:

  • --gauth-file:指定包含OAuth2客户端配置的.gauth.json文件的路径。默认为./.gauth.json。
  • --accounts-file:指定包含Google账户信息的.accounts.json文件的路径。默认为./.accounts.json。
  • --credentials-dir:指定成功认证后存储OAuth凭证的目录。默认为当前工作目录,每个账户有一个子目录,命名为.oauth.{email}.json。

这些选项允许灵活管理不同的环境或多个凭证和账户集,特别适用于开发和测试场景。

使用示例:

uv run mcp-gsuite --gauth-file /path/to/custom/.gauth.json --accounts-file /path/to/custom/.accounts.json --credentials-dir /path/to/custom/credentials

当您有多个服务器实例运行不同配置,或者部署到默认路径不适合的环境时,此配置特别有用。

开发

构建和发布

要准备包进行分发:

  1. 同步依赖项并更新锁定文件:
uv sync
  1. 构建包分发版:
uv build

这将在dist/目录中创建源代码和wheel分发版。

  1. 发布到PyPI:
uv publish

注意:您需要通过环境变量或命令行标志设置PyPI凭证:

  • 令牌:--token或UV_PUBLISH_TOKEN
  • 或用户名/密码:--username/UV_PUBLISH_USERNAME和--password/UV_PUBLISH_PASSWORD

调试

由于MCP服务器通过stdio运行,调试可能具有挑战性。为了获得最佳调试体验,我们强烈建议使用MCP Inspector。

您可以通过npm使用以下命令启动MCP Inspector:

npx @modelcontextprotocol/inspector uv --directory /path/to/mcp-gsuite run mcp-gsuite

启动后,Inspector将显示一个URL,您可以在浏览器中访问该URL开始调试。

您还可以使用以下命令查看服务器日志:

tail -n 20 -f ~/Library/Logs/Claude/mcp-server-mcp-gsuite.log
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档