Google 工作区 MCP 服务器是一个基于 Model Context Protocol (MCP) 的服务器,它提供了与 Gmail 和日历 API 相互操作的工具。借助 MCP 接口,你可以对电子邮件和日历事件进行程序化管理,极大地提高工作效率。
list_emails:列出收件箱中的近期邮件,支持可选过滤,让你快速定位所需邮件。search_emails:使用 Gmail 查询语法进行高级邮件搜索,满足复杂的搜索需求。send_email:发送新邮件,支持 CC 和 BCC,方便与多人沟通。modify_email:修改电子邮件标签(存档、删除、标记为已读/未读),轻松管理邮件状态。list_events:列出即将进行的日历事件,支持日期范围过滤,合理规划日程。create_event:创建新的日历事件并添加参与者,高效组织会议。update_event:更新现有日历事件,确保日程信息的准确性。delete_event:删除日历事件,灵活调整日程安排。http://localhost:3000)。git clone https://github.com/your-username/google-workspace-mcp.git
cd google-workspace-mcp
npm install
.env 文件(如果尚未创建)。YOUR_CLIENT_ID 和 YOUR_CLIENT_SECRET 替换为你从 Google Cloud Console 获取的值:CLIENT_ID=your_client_id
CLIENT_SECRET=your_client_secret
REDIRECT_URI=http://localhost:3000
npm start
// 列出近期邮件
const response = await fetch('http://localhost:3000/api/gmail/list_emails');
const data = await response.json();
console.log(data);
// 搜索特定内容的邮件
const requestBody = {
query: 'subject:meeting',
maxResults: 10
};
const response = await fetch('http://localhost:3000/api/gmail/search_emails', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(requestBody)
});
const data = await response.json();
console.log(data);
// 列出即将进行的事件
const requestBody = {
timeMin: '2024-01-01T00:00:00Z',
timeMax: '2024-12-31T23:59:59Z',
maxResults: 10
};
const response = await fetch('http://localhost:3000/api/calendar/list_events', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(requestBody)
});
const data = await response.json();
console.log(data);
此项目在 MIT License 下发行。