这是一个基于 Model Context Protocol (MCP) 的服务器,它提供了与 Gmail 和日历 API 交互的工具。借助 MCP 接口,你能够对电子邮件和日历事件进行编程管理,极大提升工作效率。
本服务器可让你轻松通过 MCP 接口对 Gmail 邮件和日历事件进行编程管理。在使用前,请确保完成以下先决条件和设置步骤。
list_emails
:列出收件箱中的近期邮件,还具备可选过滤功能。search_emails
:支持使用 Gmail 查询语法进行高级邮件搜索。send_email
:可发送新邮件,并且支持 CC 和 BCC。modify_email
:能修改电子邮件标签,如存档、移动到垃圾邮件、标记为已读/未读。list_events
:列出未来范围内的日历活动,带有日期筛选功能。create_event
:可创建新日历事件,支持添加与会者。update_event
:用于更新现有日历事件。delete_event
:可删除日历事件。https://www.googleapis.com/auth/gmail.readonly
、https://www.googleapis.com/auth/calendar
git clone https://github.com/your-repository.git
cd your-repository
npm install
credentials.json
文件,内容示例如下:{
"type": "service_account",
"project_id": "your-project-id",
"private_key_id": "your-private-key-id",
"client_email": "your-service-account@your-project-id.iam.gserviceaccount.com",
"private_key": "your-private-key",
"client_id": "your-client-id",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"AuthProviderLink": "https://www.googleapis.com/auth/",
"Authority": "https://accounts.google.com/o/oauth2/auth"
}
npm run get-refresh-token
~/.config/google/workspace-mcp/setting.json
File > Settings > Google Workspace MCP Config
File > Settings > Google Workspace MCP Config
{
"gmail": {
"apiKey": "your-gmail-api-key",
"refreshToken": "your-refresh-token"
},
"calendar": {
"apiKey": "your-calendar-api-key",
"refreshToken": "your-refresh-token"
}
}
npm run build
npm start
{
"command": "list_emails",
"maxResults": 10,
"q": "subject:meeting"
}
{
"command": "send_email",
"to": "recipient@example.com",
"subject": "测试邮件",
"body": "这是测试邮件内容。"
}
{
"command": "create_event",
"summary": "团队会议",
"location": "会议室",
"description": "每周同步",
"start": "2024-01-24T10:00:00Z",
"end": "2024-01-24T11:00:00Z",
"attendees": ["colleague@example.com"]
}
此项目遵循 MIT 许可证。