Skip to main content
Glama

google-chat-mcp

用于 Google Chat 的 MCP 服务器。让 Claude(Code / Desktop)或任何 MCP 客户端列出你的空间、读取和搜索消息、拉取线程和成员,并且——可选——以你的身份发送消息。

默认只读。通过 stdio 在本地运行。刷新令牌以 0600 权限存储在 ~/.google-chat-mcp/ 下。

工具

工具

输入

说明

list_spaces

type(all/space/group/dm)、query、resolveDmNames、limit

按最近活动排序。除非 resolveDmNames(最多 40 次查找),否则 DM 没有名称。

list_messages

space、since、until、limit ≤100、pageToken

最新优先。since/until 在服务端过滤。

search_messages

query(子字符串或 /regex/)、spaces?、since、until、limit

客户端扫描;Chat API 没有全文搜索。默认窗口 14 天,每个空间 ≤500 条消息。

get_thread

thread

所有回复,最旧优先。

list_members

space

用户 + 角色,通过 People API 获取姓名/邮箱。

send_message

space、text、thread?

仅在 SEND_ENABLED=true 时注册。

发送者姓名来自 People API 目录(directory.readonly)。如果该 API 被禁用或用户是外部用户,你会得到 users/<id>——其他一切仍然正常工作。

Related MCP server: A1 Google Chat MCP

设置

需要 Google Workspace 账户。消费者 @gmail.com 账户无法调用 Chat API(403)。

1. Google Cloud 项目(一次性,约 10 分钟)

  1. console.cloud.google.com → 创建/选择项目。

  2. APIs & Services → Library → 启用 Google Chat API 和 People API。

  3. Google Chat API → Configuration 标签页 → 填写 App name、Avatar URL、Description;交互功能 关闭;对您的域可见。保存。

    注意:在保存此表单之前,Chat API 会拒绝所有 OAuth 调用并返回 403,即使对于只读用户认证也是如此。

  4. OAuth consent screen → Internal → 添加范围:

    • https://www.googleapis.com/auth/chat.spaces.readonly

    • https://www.googleapis.com/auth/chat.messages.readonly

    • https://www.googleapis.com/auth/chat.memberships.readonly

    • https://www.googleapis.com/auth/directory.readonly

    • https://www.googleapis.com/auth/chat.messages.create(仅当您想要 send_message 时)

  5. Credentials → Create credentials → OAuth client ID → Desktop app → 下载 JSON。将其保存在任何仓库之外。

2. 登录

export GOOGLE_CHAT_CLIENT_SECRET_PATH=/path/to/client_secret.json
npx google-chat-mcp login        # browser opens → sign in with your Workspace account
npx google-chat-mcp whoami       # sanity check

3. 使用 Claude Code 注册

claude mcp add google-chat \
  -e GOOGLE_CHAT_CLIENT_SECRET_PATH=/path/to/client_secret.json \
  -- npx -y google-chat-mcp

Claude Desktop(claude_desktop_config.json):

{
  "mcpServers": {
    "google-chat": {
      "command": "npx",
      "args": ["-y", "google-chat-mcp"],
      "env": { "GOOGLE_CHAT_CLIENT_SECRET_PATH": "/path/to/client_secret.json" }
    }
  }
}

环境

变量

默认值

用途

GOOGLE_CHAT_CLIENT_SECRET_PATH

—

桌面 OAuth 客户端 JSON。在 macOS 上回退到 Keychain 项 jay-google-oauth/client。

GOOGLE_CHAT_TOKEN_PATH

~/.google-chat-mcp/token.json

刷新令牌缓存。

SEND_ENABLED

false

true 注册 send_message 并请求创建范围。更改后重新运行 login。

配额说明

Chat API:约 60 次请求/分钟/用户。空间和成员列表在进程内缓存 5 分钟;解析的用户名在磁盘上缓存于 ~/.google-chat-mcp/users.json。search_messages 是开销最大的操作——使用 spaces 和 since 限制范围。

开发

pnpm install
pnpm dev login
pnpm typecheck && pnpm lint && pnpm build

Node ≥ 22。TypeScript 严格模式,ESM,tsup 构建。

许可证

MIT

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • -
      license
      Not graded
      quality
      D
      maintenance
      Enables AI assistants to read and send messages in Google Chat spaces using service account authentication.
      -
    • A
      license
      A
      quality
      B
      maintenance
      Enables AI assistants to work in Google Chat through natural language: find spaces and direct messages, read and send messages, manage threads, reactions, attachments, and memberships while acting as the signed-in user.
      20
      140 npm
      MIT
    • A
      license
      Not graded
      quality
      A
      maintenance
      Enables reading, searching, and writing to Google Chat spaces, direct messages, and sidebar through MCP clients such as Claude Code and Claude Desktop.
      Apache 2.0