谷歌工作区MCP服务器
此项目基于以下存储库: epaproditus/googleworkspacemcp服务器
Google Workspace 的功能(日历、邮件)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 20 安装以上
- Google Cloud Console 设定:
- 谷歌云控制台访问 - 创建新项目或选择现有项目 - Gmail API 打开Google Calendar API 启用: 1. "APIs & Services" > "Library"移到 1. "Gmail API"查找并启用 1. "Google Calendar API"查找并启用 - OAuth 2.0 设置凭据: 1. "APIs & Services" > "Credentials"移到 1. "Create Credentials" > "OAuth client ID"来修改标记元素的显示属性 1. "Desktop application"列表框中,此格式对应于条目“无” 1. "Authorized redirect URIs"在…之上http://localhost:4100/code添加 1. Client ID 打开Client Secret 记录
安装过程
- 克隆和安装存储库:
git clone https://github.com/Yulikepython/gogole-workspace-mcp-server-by-itc.git
cd google-workspace-mcp-server-by-itc
npm install- 设置凭据:
# credentials.json.exampleをコピー
cp credentials.json.example credentials.jsoncredentials.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- 添加部署设置(.env):
deploy 使用脚本 .env 需要文件。
cp .env.example .env.env 请在中设置以下环境变量:
SSH_USER=your_ssh_user
SSH_HOST=your.ssh.host
SSH_PATH=/your/deploy/pathnpm脚本
|命令|说明| |----------------|-------------------------------------| | npm run build|创建包并授予可执行权限| | npm run start在本地构建和运行 | npm run clean删除构建交付件 | npm run deploy构建后,将文件部署到生产环境中 | npm run logs 实时查看生产环境中的应用程序日志
使用例
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 确认是否已授予作用域 - Client ID 打开Secret 确认是否正确 - 确认刷新标记是否有效
- API 错误:
- Google Cloud Console 单击功能区上API 检查配额和限制 - 在项目中API 已启用 - 确认请求参数的格式是否正确
许可证
麻省理工学院
