Skip to main content
Glama

介绍

该项目为使用 Python 和 FastMCP 编写的 MCP(模型控制协议)服务器提供了 Google Chat 集成。它允许您通过 MCP 工具访问 Google Chat 聊天室和消息并进行交互。

结构

该项目由两个主要部分组成:

  1. 带有 Google Chat 工具的 MCP 服务器:提供通过模型控制协议与 Google Chat 交互的工具。

    • 作者:FastMCP

    • server.py :使用 Google Chat 工具的主要 MCP 服务器实现

    • google_chat.py :Google Chat API 集成和身份验证处理

  2. 身份验证服务器:用于 Google 帐户身份验证的独立组件

    • 由 FastAPI 编写

    • 与 Google 一起处理 OAuth2 流程

    • 存储和管理访问令牌

    • 可以独立运行或作为 MCP 服务器的一部分运行

    • server_auth.py :认证服务器实现

身份验证流程允许您获取并刷新 Google API 令牌,然后 MCP 工具会使用这些令牌访问 Google Chat 数据。(您的聊天室和消息)

Related MCP server: Google OAuth2 API Server

特征

  • 使用 Google Chat API 进行 OAuth2 身份验证

  • 列出可用的 Google Chat 空间

  • 通过日期过滤从特定空间检索消息

  • 本地身份验证服务器,易于设置

要求

  • Python 3.8+

  • 启用 Chat API 的 Google Cloud 项目

  • 来自 Google Cloud Console 的 OAuth2 凭据

如何使用?

准备 Google Oauth 登录

  1. 克隆此项目

    git clone https://github.com/chy168/google-chat-mcp-server.git cd google-chat-mcp-server
  2. 准备 Google Cloud 项目 (GCP)

  3. Google Cloud Console( https://console.cloud.google.com/auth/overview?project=\ <YOUR_PROJECT_NAME>)

  4. Google Auth 平台 > 客户端 > (+) 创建客户端 > Web 应用程序参考: https://developers.google.com/identity/protocols/oauth2/ ?hl=en 授权 JavaScript 来源添加: http://localhost:8000授权重定向 URI: http://localhost:8000/auth/callback

  5. 创建 OAuth 2.0 客户端后,请将客户端密钥下载为.json文件。并将其保存为credentials.json ,并置于项目根目录。

运行 Auth 服务器并获取您的 Google 访问令牌(仅登录 Google,尚未登录 MCP 服务器)

python server.py -local-auth --port 8000

MCP 配置 (mcp.json)

{ "mcpServers": { "google_chat": { "command": "uv", "args": [ "--directory", "<YOUR_REPO_PATH>/google-chat-mcp-server", "run", "server.py", "--token-path", "<YOUR_REPO_PATH>/google-chat-mcp-server/token.json" ] } }

工具

MCP 服务器提供以下工具:

Google 聊天工具

  • get_chat_spaces() - 列出机器人可以访问的所有 Google 聊天空间

  • get_space_messages(space_name: str, start_date: str, end_date: str = None) - 列出来自特定 Google Chat 空间的消息,并可选择时间过滤

开发和调试

fastmcp dev server.py --with-editable .
-
security - not tested
A
license - permissive license
-
quality - not tested

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/chy168/google-chat-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server