使用说明
谷歌日历MCP服务器
一个模型上下文协议(MCP)服务器,提供与谷歌日历API交互的工具。此服务器使您能够通过MCP界面以编程方式管理日历事件。
特性
日历工具
list_events:使用日期范围筛选列出即将发生的日历事件create_event:为与会者创建新的日历事件update_event:更新现有日历事件delete_event:删除日历事件
先决条件
- Node.js:安装Node.js版本14或更高版本
- 谷歌云控制台设置:
- 首选 谷歌云控制台
- 创建新项目或选择现有项目
- 启用Google日历API:
- 转到“API和服务”>“库”
- 搜索并启用“Google日历API”
- 设置OAuth 2.0凭据:
- 转到“API和服务”>“凭据”
- 点击“创建凭据”>“OAuth客户端ID”
- 选择“Web应用程序”
- 将“授权重定向URI”设置为包括:
http://localhost:3000/code - 记下客户端ID和客户端密码
安装说明
-
克隆并安装:
git clone https://github.com/yourusername/google-calendar-mcp-server.git cd google-calendar-mcp-server npm install -
创建OAuth凭据: 创建一个
credentials.json根目录中的文件:{ "web": { "client_id": "YOUR_CLIENT_ID", "client_secret": "YOUR_CLIENT_SECRET", "redirect_uris": ["http://localhost:3000/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/calendar
- 将凭据保存到
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-calendar": { "command": "node", "args": ["/path/to/google-calendar-server/build/index.js"], "env": { "GOOGLE_ACCESS_TOKEN": "your_access_token", } } } } - 对于VSCode Claude扩展:
-
构建并运行:
npm run build
使用示例
日历操作
-
列出事件:
{ "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", "location": "Virtual", "description": "Rescheduled weekly sync-up", "start": "2024-01-25T10:00:00Z", "end": "2024-01-25T11:00:00Z" } -
删除事件:
{ "eventId": "event_id" }
许可证
麻省理工学院