这是一个提供与 Google 服务(包括 Gmail、Google 日历、Google 驱动器和 Google 搜索)交互的强大工具的 MCP 服务器。
<a href="https://glama.ai/mcp/servers/@jikime/py-mcp-google-toolbox"> <img width="380" height="200" src="https://gips2.baidu.com/it/u=1844966460,1484372879&fm=3081&app=3081&f=PNG?w=760&h=400" alt="Google 工具箱 MCP 服务器" /> </a>py-mcp-google-toolbox 提供以下与 Google 相关的功能:
git clone https://github.com/jikime/py-mcp-google-toolbox.git
cd py-mcp-google-toolbox
curl -LsSf https://astral.sh/uv/install.sh | sh
uv venv -p 3.12
source .venv/bin/activate # 在 MacOS/Linux 上
# 或
.venv\Scripts\activate # 在 Windows 上
uv pip install -r requirements.txt
uv run get_refresh_token.py
这将:
https://www.googleapis.com/auth/gmail.modifyhttps://www.googleapis.com/auth/calendarhttps://www.googleapis.com/auth/gmail.sendhttps://www.googleapis.com/auth/gmail.readonlyhttps://www.googleapis.com/auth/drivehttps://www.googleapis.com/auth/drive.filehttps://www.googleapis.com/auth/drive.readonlytoken.jsoncp env.example .env
vi .env
# 更换为你自己的密钥
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
docker build -t py-mcp-google-toolbox .
docker run py-mcp-google-toolbox
mcp run server.py
mcp dev server.py
在你的 MCP 设置文件中添加服务器配置:
npx -y @smithery/cli install @jikime/py-mcp-google-toolbox --client claude
~/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"
]
}
}
}
打开 ~/.cursor/mcp.json
在 mcpServers 对象中添加以下内容:
{
"mcpServers": {
"Google Toolbox": {
"command": "/path/to/bin/uv",
"args": [
"--directory",
"/path/to/py-mcp-google-toolbox",
"run",
"server.py"
]
}
}
}
{
"mcpServers": {
"Google Toolbox": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"py-mcp-google-toolbox"
]
}
}
}
list_emails:列出 Gmail 收件箱中的最近邮件,并带有过滤选项search_emails:执行高级 Gmail 搜索,并详细检索电子邮件内容send_email:编写并发送电子邮件,支持 CC、BCC 收件人modify_email:通过修改标签来更改邮件状态(已读/未读、归档、删除)list_events:检索指定时间范围内的即将发生的日历事件create_event:创建新的日历事件,包括参与者、地点和描述update_event:通过灵活的参数更新现有的日历事件delete_event:通过事件 ID 删除日历事件read_gdrive_file:读取并检索 Google 驱动器文件的内容search_gdrive:使用可定制查询搜索 Google 驱动器中的文件search_google:执行 Google 搜索并返回格式化的结果对于本地测试,你可以使用包含的客户端脚本:
# 示例:列出邮件
uv run client.py list_emails max_results=5 query="is:unread"
# 示例:搜索邮件
uv run client.py search_emails query="from:test@example.com"
# 示例:发送邮件
uv run client.py send_email to="test@example.com" subject="test mail" body="Hello"
# 示例:修改邮件
uv run client.py modify_email id=MESSAGE_ID remove_labels=INBOX add_labels=ARCHIVED
# 示例:列出事件
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
# 示例:创建事件
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"
# 示例:更新事件
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"
# 示例:删除事件
uv run client.py delete_event event_id=EVENT_ID
# 示例:搜索 Google
uv run client.py search_google query="什么是 MCP?"
# 示例:搜索 Google 驱动器
uv run client.py search_gdrive query=mcp
# 示例:读取文件
uv run client.py read_gdrive_file file_id=1234567890
MIT 许可证