谷歌工作区 MCP 服务器是一个基于 Model Context Protocol (MCP) 的工具,它提供了与 Gmail 和日历 API 交互的能力。借助 MCP 接口,用户可以对电子邮件和日历事件进行编程管理,极大地提高了工作效率。
要使用谷歌工作区 MCP 服务器,你需要完成一系列的准备和设置工作。具体步骤如下:
client_id
、client_secret
和 refresh_token
。CLIENT_ID=your_client_id
CLIENT_SECRET=your_client_secret
REFRESH_TOKEN=your_refresh_token
git clone https://github.com/yourusername/google-workspace-mcp.git
cd google-workspace-mcp
npm install
credentials.json
文件,内容如下:{
"client_id": "your_client_id",
"client_secret": "your_client_secret",
"refresh_token": "your_refresh_token"
}
node index.js
list_emails
:列出收件箱中的近期邮件,支持可选过滤功能search_emails
:使用 Gmail 查询语法进行高级邮件搜索send_email
:发送新邮件,支持 CC 和 BCCmodify_email
:修改邮件标签(存档、删除、标记为已读/未读)list_events
:列出 upcoming 日历事件,支持日期范围过滤create_event
:创建新的日历事件,支持与会者update_event
:更新现有日历事件delete_event
:删除日历事件{
"action": "list_emails",
"params": {
"limit": 10,
"folder": "inbox"
}
}
{
"action": "send_email",
"params": {
"to": "recipient@example.com",
"subject": "Test Email",
"body": "This is a test email."
}
}
{
"action": "create_event",
"params": {
"summary": "会议提醒",
"location": "会议室 101",
"description": "每周同步",
"start": "2024-01-24T10:00:00Z",
"end": "2024-01-24T11:00:00Z",
"attendees": ["colleague@example.com"]
}
}
{
"action": "update_event",
"params": {
"event_id": "event_id_to_update",
"summary": "更新的会议标题",
"location": "线上会议"
}
}
身份验证问题:
API 错误:
本项目在 MIT License 下开源。