使用说明
谷歌工作区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:
- 转到“API和服务”>“库”
- 搜索并启用“Gmail API”
- 搜索并启用“Google日历API”
- 设置OAuth 2.0凭据:
- 转到“API和服务”>“凭据”
- 点击“创建凭据”>“OAuth客户端ID”
- 选择“Web应用程序”
- 将“授权重定向URI”设置为包括:
http://localhost:3000/auth/callback - 记下客户端ID和客户端密码
通过Smithery安装
使用Smithery的CLI安装服务器:
npx spinai-mcp install @KaranThink41/gsuite-mcp-server --provider smithery --config '{"googleClientId":"your_google_client_id","googleClientSecret":"your_google_client_secret","googleRefreshToken":"your_google_refresh_token"}'
或者,您可以使用以下配置:
// smithery.config.js
export default {
KaranThink41_google_chat_mcp_server: {
command: 'npx',
args: [
'-y',
'@smithery/cli@latest',
'run',
'@KaranThink41/google_chat_mcp_server'
]
},
};
地方发展(可选)
如果您更喜欢在本地运行服务器:
- 克隆存储库:
git clone https://github.com/KaranThink41/Google_workspace_mcp_server.git
cd Google_workspace_mcp_server
- 安装依赖项:
npm install
- 构建项目:
npm run build
- 运行服务器:
node build/index.js
使用示例
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许可证获得许可。
谷歌聊天MCP服务器
用于与Google Chat API交互的模型上下文协议(MCP)服务器实现。此服务器提供用于管理Google聊天中的消息、空间和成员资格的工具。
特性
- 在谷歌聊天空间发布短信
- 获取空间详细信息并列出空间
- 管理会员资格(列表,获取会员详细信息)
- 使用过滤功能列出和检索邮件
- 自然语言过滤支持
安装说明
1.谷歌云项目设置
- 首选 谷歌云控制台
- 创建新项目或选择现有项目
- 启用Google Chat API
- 创建OAuth 2.0凭据:
- 转到API和服务>凭据
- 点击“创建凭据”>OAuth客户端ID
- 选择“Web应用程序”
- 将“授权重定向URI”设置为包括:
http://localhost:3000/auth/callback - 记下客户端ID和客户端密码
2.获取刷新令牌
- 创建临时凭据文件:
cp temp-credentials.json.example temp-credentials.json
-
更新
temp-credentials.json使用您的客户端ID和客户端密码 -
运行刷新令牌脚本:
node get-refresh-token.js
- 按照浏览器身份验证流程获取刷新令牌
3.通过Smithery安装
使用Smithery的CLI安装服务器:
npx spinai-mcp install @KaranThink41/google_chat_mcp_server --provider smithery --config '{"spaceId":"your_space_id","googleClientId":"your_google_client_id","googleClientSecret":"your_google_client_secret","googleRefreshToken":"your_google_refresh_token"}'
或者,您可以使用以下配置:
export default {
KaranThink41_google_chat_mcp_server: {
command: 'npx',
args: [
'-y',
'@smithery/cli@latest',
'run',
'@KaranThink41/google_chat_mcp_server'
]
},
};
4.地方发展(可选)
如果您更喜欢在本地运行服务器:
- 克隆存储库:
git clone https://github.com/KaranThink41/Google_chat_mcp_server.git
cd Google_chat_mcp_server
- 安装依赖项:
npm install
- 构建项目:
npm run build
- 运行服务器:
node build/index.js
可用工具
消息管理
-
post_text_message:在谷歌聊天空间发布短信{ "method": "tools/call", "params": { "name": "post_text_message", "arguments": { "spaceId": "AAAAfkdUqxE", "text": "Hello, this is a test message!" } } } -
fetch_message_details:获取特定消息的详细信息{ "method": "tools/call", "params": { "name": "fetch_message_details", "arguments": { "spaceId": "AAAAfkdUqxE", "messageId": "cpwLU-2f_z8.cpwLU-2f_z8" } } } -
list_space_messages:在具有可选筛选的空间中列出邮件{ "method": "tools/call", "params": { "name": "list_space_messages", "arguments": { "spaceId": "AAAAfkdUqxE", "pageSize": 10, "orderBy": "createTime" } } }
空间管理
-
fetch_space_details:获取有关空间的全面详细信息{ "method": "tools/call", "params": { "name": "fetch_space_details", "arguments": { "spaceId": "AAAAfkdUqxE" } } } -
list_joined_spaces:列出调用者所属的所有空格{ "method": "tools/call", "params": { "name": "list_joined_spaces", "arguments": { "pageSize": 10 } } }
会员管理
-
list_space_memberships:列出空间中的所有成员资格{ "method": "tools/call", "params": { "name": "list_space_memberships", "arguments": { "spaceId": "AAAAfkdUqxE", "pageSize": 10 } } } -
fetch_member_details:获取特定成员的详细信息{ "method": "tools/call", "params": { "name": "fetch_member_details", "arguments": { "spaceId": "AAAAfkdUqxE", "memberId": "user_123" } } }
自然语言过滤
apply_natural_language_filter:将自然语言查询转换为API筛选器字符串{ "method": "tools/call", "params": { "name": "apply_natural_language_filter", "arguments": { "filterText": "messages from Monday" } } }
错误处理
服务器通过描述性错误消息实现了正确的错误处理。常见错误包括:
- 身份验证失败
- 无效的空间ID
- 速率限制
- 超过API配额
安全
- 所有敏感凭据都存储在环境变量中
- OAuth刷新令牌得到安全管理
- API密钥从不在代码中公开
贡献
- 分叉存储库
- 创建功能分支(
git checkout -b feature/amazing-feature) - 提交您的更改(
git commit -m 'Add some amazing feature') - 推到分支(
git push origin feature/amazing-feature) - 打开拉取请求
许可证
此项目根据MIT许可证获得许可-请参阅 许可证 文件以获取详细信息。