使用说明
谷歌日历自动认证MCP服务器
用于在Claude Desktop中集成Google日历的模型上下文协议(MCP)服务器,支持自动身份验证。该服务器使AI助手能够通过自然语言交互来管理Google日历。
特性
- 创建包含标题、描述、位置和与会者的日历事件
- 更新现有日历事件
- 删除日历事件
- 检索事件详细信息
- 列出指定时间范围内的事件
- 按关键字搜索事件
- 列出所有可用日历
- 支持自然语言日期/时间输入(例如,“明天下午2点”、“下周一”)
- 与Google日历API完全集成
- 具有自动浏览器启动功能的简单OAuth2身份验证流程
- 支持桌面和Web应用程序凭据
- 全球凭证存储,方便使用
安装和身份验证
通过Smithery安装
通过以下方式自动安装适用于Claude Desktop的Google日历集成服务器 史密瑟里:
npx -y @smithery/cli install @falgom4/calendar-mcp --client claude
手动安装
-
创建Google Cloud项目并获取凭据:
a.创建谷歌云项目:
- 首选 谷歌云控制台
- 创建新项目或选择现有项目
- 为您的项目启用Google日历API
b.创建OAuth 2.0凭据:
- 转到“API和服务”>“凭据”
- 点击“创建凭据”>“OAuth客户端ID”
- 选择“桌面应用程序”或“Web应用程序”作为应用程序类型
- 给它起个名字,然后单击“创建”
- 对于Web应用程序,添加
http://localhost:3000/oauth2callback到授权的重定向URI - 下载客户端OAuth密钥的JSON文件
- 将密钥文件重命名为
gcp-oauth.keys.json
-
运行身份验证:
您可以通过两种方式进行身份验证:
a.全局身份验证(推荐):
# First time: Place gcp-oauth.keys.json in your home directory's .calendar-mcp folder mkdir -p ~/.calendar-mcp mv gcp-oauth.keys.json ~/.calendar-mcp/ # Run authentication from anywhere npx @nchufa/calendar authb.本地身份验证:
# Place gcp-oauth.keys.json in your current directory # The file will be automatically copied to global config npx @nchufa/calendar auth身份验证过程将:
- 寻找
gcp-oauth.keys.json在当前目录或~/.calendar-mcp/ - 如果在当前目录中找到,请将其复制到
~/.calendar-mcp/ - 打开默认浏览器进行谷歌身份验证
- 将凭据另存为
~/.calendar-mcp/credentials.json
备注:
- 成功身份验证后,凭据将全局存储在
~/.calendar-mcp/并且可以从任何目录中使用 - 支持桌面应用程序和Web应用程序凭据
- 对于Web应用程序凭据,请确保添加
http://localhost:3000/oauth2callback到您授权的重定向URI
- 寻找
-
在Claude Desktop中配置:
将以下内容添加到您的Claude Desktop配置文件中:
{
"mcpServers": {
"calendar": {
"command": "npx",
"args": [
"@nchufa/calendar"
]
}
}
}
可用工具
服务器提供以下可通过Claude Desktop使用的工具:
1.创建事件(create_event)
创建新的日历事件。
{
"summary": "Team Meeting",
"description": "Weekly team sync to discuss project progress",
"location": "Conference Room A",
"start": "2025-04-01T14:00:00",
"end": "2025-04-01T15:00:00",
"attendees": ["colleague@example.com", "manager@example.com"],
"reminders": {
"useDefault": false,
"overrides": [
{
"method": "email",
"minutes": 30
},
{
"method": "popup",
"minutes": 10
}
]
}
}
还支持自然语言日期/时间:
{
"summary": "Coffee with John",
"location": "Starbucks Downtown",
"start": "tomorrow at 2:30pm",
"end": "tomorrow at 3:30pm"
}
2.获取事件(get_event)
检索特定日历事件的详细信息。
{
"eventId": "abc123xyz456",
"calendarId": "primary"
}
3.更新事件(update_event)
更新现有日历事件。
{
"eventId": "abc123xyz456",
"summary": "Updated Meeting Title",
"location": "New Location",
"start": "2025-04-01T15:00:00",
"end": "2025-04-01T16:00:00"
}
4.删除事件(delete_event)
删除日历事件。
{
"eventId": "abc123xyz456",
"calendarId": "primary"
}
5.列出事件(list_events)
列出指定时间范围内的日历事件。
{
"calendarId": "primary",
"timeMin": "2025-04-01T00:00:00",
"timeMax": "2025-04-07T23:59:59",
"maxResults": 10,
"orderBy": "startTime"
}
6.搜索事件(search_events)
搜索与查询匹配的事件。
{
"query": "meeting",
"calendarId": "primary",
"timeMin": "2025-04-01T00:00:00",
"maxResults": 5
}
7.列出日历(list_calendars)
列出所有可用日历。
{}
自然语言日期/时间支持
服务器支持各种自然语言格式的日期和时间:
- 具体日期:“2025-04-01T14:00:00”(ISO格式)
- 简单的引用:“今天”、“明天”、“现在”
- 相对时间:“2小时后”、“3天后”
- 日期参考:“下周一”、“下周二”
- 组合格式:“明天下午2点”,“周一15:30”
这使得使用自然语言指令创建和更新事件变得容易。
安全说明
- OAuth凭据安全地存储在您的本地环境中(
~/.calendar-mcp/) - 服务器使用脱机访问来维护持久身份验证
- 切勿将您的凭据共享或提交给版本控制
- 定期查看并撤销您Google帐户设置中未使用的访问权限
故障排除
-
找不到OAuth密钥
- 确保
gcp-oauth.keys.json位于您当前的目录或~/.calendar-mcp/ - 检查文件权限
- 确保
-
凭据格式无效
- 确保您的OAuth密钥文件包含以下内容之一
web或installed凭证 - 对于web应用程序,请验证重定向URI是否配置正确
- 确保您的OAuth密钥文件包含以下内容之一
-
端口已在使用中
- 如果端口3000已在使用中,请在运行身份验证之前将其释放
- 您可以使用该端口查找并停止进程
贡献
欢迎投稿!请随时提交拉取请求。
许可证
麻省理工学院
致谢
特别感谢 龚日哲 和他的 日历自动认证MCP服务器 该项目为这一实施奠定了基础。
支持
如果您遇到任何问题或有疑问,请在GitHub存储库上提交问题。