谷歌工作区MCP服务器
](https://smithery.ai/server/@rishipradeep-think41/gsuite-mcp)
一种模型上下文协议(MCP)服务器,提供与Gmail和日历API交互的工具。此服务器使您能够通过MCP界面以编程方式管理电子邮件和日历事件。
特性
Gmail工具
list_emails:使用可选过滤功能列出收件箱中最近的电子邮件search_emails:使用Gmail查询语法进行高级电子邮件搜索send_email:发送支持CC和BCC的新电子邮件modify_email:修改电子邮件标签(存档、垃圾箱、标记已读/未读)
日历工具
list_events:使用日期范围筛选列出即将发生的日历事件create_event:为与会者创建新的日历事件update_event:更新现有日历事件delete_event:删除日历事件
先决条件
- Node.js:安装Node.js版本14或更高版本
- 谷歌云控制台设置:
- 首选 谷歌云控制台 - 创建新项目或选择现有项目 - 启用Gmail API和Google日历API: 1. 转到“API和服务”>“库” 1. 搜索并启用“Gmail API” 1. 搜索并启用“Google日历API” - 设置OAuth 2.0凭据: 1. 转到“API和服务”>“凭据” 1. 点击“创建凭据”>“OAuth客户端ID” 1. 选择“Web应用程序” 1. 将“授权重定向URI”设置为包括: http://localhost:4100/code 1. 记下客户端ID和客户端密码
安装说明
通过Smithery安装
通过以下方式自动安装gsuite mcp for Claude Desktop 史密瑟里:
npx -y @smithery/cli install @rishipradeep-think41/gsuite-mcp --client claude手动安装
- 克隆并安装:
git clone https://github.com/epaproditus/google-workspace-mcp-server.git
cd google-workspace-mcp-server
npm install- 创建OAuth凭据:
创建一个 credentials.json 根目录中的文件:
{
"web": {
"client_id": "YOUR_CLIENT_ID",
"client_secret": "YOUR_CLIENT_SECRET",
"redirect_uris": ["http://localhost:4100/code"],
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token"
}
}- 获取刷新令牌:
node get-refresh-token.js这将:
- 打开浏览器进行Google OAuth身份验证 - 请求以下权限: - https://www.googleapis.com/auth/gmail.modify - https://www.googleapis.com/auth/calendar - https://www.googleapis.com/auth/gmail.send - 将凭据保存到 token.json - 在控制台中显示刷新令牌
- 配置MCP设置:
将服务器配置添加到MCP设置文件中:
- 对于VSCode Claude扩展: ~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json - 对于Claude桌面应用程序: ~/Library/Application Support/Claude/claude_desktop_config.json
将此添加到 mcpServers 对象:
{
"mcpServers": {
"google-workspace": {
"command": "node",
"args": ["/path/to/google-workspace-server/build/index.js"],
"env": {
"GOOGLE_CLIENT_ID": "your_client_id",
"GOOGLE_CLIENT_SECRET": "your_client_secret",
"GOOGLE_REFRESH_TOKEN": "your_refresh_token"
}
}
}
}- 构建并运行:
npm run build使用示例
Gmail操作
- 列出最近的电子邮件:
{
"maxResults": 5,
"query": "is:unread"
}- 搜索电子邮件:
{
"query": "from:example@gmail.com has:attachment",
"maxResults": 10
}- 发送电子邮件:
{
"to": "recipient@example.com",
"subject": "Hello",
"body": "Message content",
"cc": "cc@example.com",
"bcc": "bcc@example.com"
}- 修改电子邮件:
{
"id": "message_id",
"addLabels": ["UNREAD"],
"removeLabels": ["INBOX"]
}日历操作
- 列出事件:
{
"maxResults": 10,
"timeMin": "2024-01-01T00:00:00Z",
"timeMax": "2024-12-31T23:59:59Z"
}- 创建活动:
{
"summary": "Team Meeting",
"location": "Conference Room",
"description": "Weekly sync-up",
"start": "2024-01-24T10:00:00Z",
"end": "2024-01-24T11:00:00Z",
"attendees": ["colleague@example.com"]
}- 更新事件:
{
"eventId": "event_id",
"summary": "Updated Meeting Title",
"location": "Virtual",
"start": "2024-01-24T11:00:00Z",
"end": "2024-01-24T12:00:00Z"
}- 删除事件:
{
"eventId": "event_id"
}故障排除
- 身份验证问题:
- 确保授予了所有必需的OAuth作用域 - 验证客户端ID和密码是否正确 - 检查刷新令牌是否有效
- API错误:
- 查看Google云控制台了解API配额和限制 - 确保为您的项目启用了API - 验证请求参数是否符合所需格式
许可证
该项目根据MIT许可证获得许可。
