Skip to main content
Glama

Google Toolbox

py-mcp-google-工具箱

版本执照

MCP 服务器为 AI 助手提供了与 Google 服务交互的强大工具,包括 Gmail、Google 日历、Google Drive 和 Google 搜索。

概述

py-mcp-google-toolbox 提供以下与 Google 相关的功能:

  • Gmail操作(阅读、搜索、发送、修改)
  • Google 日历管理(事件创建、列出、更新、删除)
  • Google Drive 交互(搜索、读取文件)
  • Google 搜索集成(搜索网页)

目录

先决条件

  1. Python :安装 Python 3.12 或更高版本
  2. Google Cloud 控制台设置
    • 前往Google Cloud Console
    • 创建新项目或选择现有项目
    • 启用服务 API:
      1. 前往“API 和服务”>“库”
      2. 搜索并启用“Gmail API”
      3. 搜索并启用“Google 日历 API”
      4. 搜索并启用“Google Drive API”
      5. 搜索表单并启用“自定义搜索 API”
    • 从 GCP 设置 OAuth 2.0 凭据:
      1. 前往“API 和服务”>“凭证”
      2. 点击“创建凭证”>“OAuth 客户端 ID”
      3. 选择“Web应用程序”
      4. 记下客户端 ID 和客户端密钥
        • 客户端 ID
        • 客户端机密
      5. 下载 secret json 并重命名为 credentials.json
    • 生成 API 密钥
  3. 转到自定义搜索引擎并获取其 ID

安装

Git 克隆
git clone https://github.com/jikime/py-mcp-google-toolbox.git cd py-mcp-google-toolbox
配置
  1. 安装 UV 包管理器:
curl -LsSf https://astral.sh/uv/install.sh | sh
  1. 创建并激活虚拟环境:
uv venv -p 3.12 source .venv/bin/activate # On MacOS/Linux # or .venv\Scripts\activate # On Windows
  1. 安装依赖项:
uv pip install -r requirements.txt
  1. 获取刷新令牌(如果令牌已过期,则可以运行此操作)
uv run get_refresh_token.py

这将:

  • 打开浏览器进行 Google OAuth 身份验证
  • 请求以下权限:
    • https://www.googleapis.com/auth/gmail.modify
    • https://www.googleapis.com/auth/calendar
    • https://www.googleapis.com/auth/gmail.send
    • https://www.googleapis.com/auth/gmail.readonly
    • https://www.googleapis.com/auth/drive
    • https://www.googleapis.com/auth/drive.file
    • https://www.googleapis.com/auth/drive.readonly
  • 将凭证保存到token.json
  • 在控制台中显示刷新令牌
  1. 环境变量:
cp env.example .env vi .env # change with your key GOOGLE_API_KEY=your_google_api_key GOOGLE_CSE_ID=your_custom_search_engine_id GOOGLE_CLIENT_ID=your_google_client_id GOOGLE_CLIENT_SECRET=your_google_client_secret GOOGLE_REFRESH_TOKEN=your_google_refresh_token
  1. 将 credentials.json 复制到项目根文件夹 (py-mcp-google-toolbox)
使用 Docker
  1. 构建 Docker 镜像:
docker build -t py-mcp-google-toolbox .
  1. 运行容器:
docker run py-mcp-google-toolbox
使用本地
  1. 运行服务器:
mcp dev server.py

配置 MCP 设置

将服务器配置添加到您的 MCP 设置文件:

克劳德桌面应用程序
  1. 要通过Smithery自动安装:
npx -y @smithery/cli install @jikime/py-mcp-google-toolbox --client claude
  1. 要手动安装,请打开~/Library/Application Support/Claude/claude_desktop_config.json

将其添加到mcpServers对象:

{ "mcpServers": { "Google Toolbox": { "command": "/path/to/bin/uv", "args": [ "--directory", "/path/to/py-mcp-google-toolbox", "run", "server.py" ] } } }
游标 IDE

打开~/.cursor/mcp.json

将其添加到mcpServers对象:

{ "mcpServers": { "Google Toolbox": { "command": "/path/to/bin/uv", "args": [ "--directory", "/path/to/py-mcp-google-toolbox", "run", "server.py" ] } } }
对于 Docker
{ "mcpServers": { "Google Toolbox": { "command": "docker", "args": [ "run", "-i", "--rm", "py-mcp-google-toolbox" ] } } }

工具文档

Gmail 工具

  • list_emails :列出 Gmail 收件箱中的最近电子邮件,并提供过滤选项
  • search_emails :执行高级 Gmail 搜索并检索详细的电子邮件内容
  • send_email :撰写并发送电子邮件,支持抄送、密送收件人
  • modify_email :通过修改标签来更改电子邮件状态(已读/未读、已存档、已删除)

日历工具

  • list_events :检索指定时间范围内即将发生的日历事件
  • create_event :创建带有参与者、地点和描述的新日历事件
  • update_event :通过灵活的参数更新修改现有日历事件
  • delete_event :根据事件 ID 删除日历事件

驱动工具

  • read_gdrive_file :从 Google Drive 文件中读取和检索内容
  • search_gdrive :使用可自定义的查询在 Google Drive 中搜索文件

搜索工具

  • search_google :执行 Google 搜索并返回格式化的结果

发展

对于本地测试,您可以使用附带的客户端脚本:

# Example: List emails uv run client.py list_emails max_results=5 query="is:unread" # Example: Search emails uv run client.py search_emails query="from:test@example.com" # Example: Send email uv run client.py send_email to="test@example.com" subject="test mail" body="Hello" # Example: Modify email uv run client.py modify_email id=MESSAGE_ID remove_labels=INBOX add_labels=ARCHIVED # Example: List events uv run client.py list_events time_min=2025-05-01T00:00:00+09:00 time_max=2025-05-02T23:59:59+09:00 max_results=5 # Example: Create event uv run client.py create_event summary="new event" start=2025-05-02T10:00:00+09:00 end=2025-05-02T11:00:00+09:00 attendees="user1@example.com,user2@example.com" # Example: Update event uv run client.py update_event event_id=EVENT_ID summary="update event" start=2025-05-02T10:00:00+09:00 end=2025-05-02T11:00:00+09:00 attendees="user1@example.com,user2@example.com" # Example Delete event uv run client.py delete_event event_id=EVENT_ID # Example: Search Google uv run client.py search_google query="what is the MCP?" # Example: Search Google Drive uv run client.py search_gdrive query=mcp # Example: Read file uv run client.py read_gdrive_file file_id=1234567890

执照

MIT 许可证

Install Server
A
security – no known vulnerabilities
F
license - not found
A
quality - confirmed to work

local-only server

The server can only run on the client's local machine because it depends on local resources.

Google 工具箱

  1. 概述
    1. 目录
      1. 先决条件
        1. 安装
          1. Git 克隆
          2. 配置
          3. 使用 Docker
          4. 使用本地
        2. 配置 MCP 设置
          1. 克劳德桌面应用程序
          2. 游标 IDE
          3. 对于 Docker
        3. 工具文档
          1. Gmail 工具
          2. 日历工具
          3. 驱动工具
          4. 搜索工具
        4. 发展
          1. 执照

            Related MCP Servers

            • -
              security
              A
              license
              -
              quality
              Integrates with Google Tasks to allow listing, reading, searching, creating, updating, and deleting tasks.
              Last updated -
              15
              TypeScript
              MIT License
            • -
              security
              F
              license
              -
              quality
              Enables managing Google Cloud Platform resources through natural language commands in Claude Desktop, supporting comprehensive operations across compute, storage, databases, networking, monitoring, and IAM without manual credential setup.
              Last updated -
              8
              Python
              • Apple
            • -
              security
              A
              license
              -
              quality
              A tool that connects Google Ads with Claude AI, allowing users to analyze advertising data through natural language conversations and access campaign information, performance metrics, keyword analytics, and ad management.
              Last updated -
              60
              Python
              MIT License
              • Apple
            • -
              security
              A
              license
              -
              quality
              Enables AI assistants to interact with and manage Google Cloud Platform resources including Compute Engine, Cloud Run, Storage, BigQuery, and other GCP services through a standardized MCP interface.
              Last updated -
              1
              Python
              MIT License
              • Linux
              • Apple

            View all related MCP servers

            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/jikime/py-mcp-google-toolbox'

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