使用说明
日历自动认证MCP服务器
用于Cluade Desktop中Google日历集成的模型上下文协议(MCP)服务器,支持自动身份验证。该服务器使AI助手能够通过自然语言交互来管理Google日历事件。
特性
- 创建带有标题、时间、描述和位置的日历事件
- 按事件ID检索事件详细信息
- 更新现有事件(标题、时间、描述、位置)
- 删除事件
- 列出指定时间范围内的事件
- 与Google日历API完全集成
- 具有自动浏览器启动功能的简单OAuth2身份验证流程
- 支持桌面和Web应用程序凭据
- 全球凭证存储,方便使用
安装和身份验证
通过Smithery安装
通过以下方式自动安装克劳德桌面日历自动认证服务器 史密瑟里:
npx -y @smithery/cli install @gongrzhe/server-calendar-autoauth-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 @gongrzhe/server-calendar-autoauth-mcp authb.本地身份验证:
# Place gcp-oauth.keys.json in your current directory # The file will be automatically copied to global config npx @gongrzhe/server-calendar-autoauth-mcp auth身份验证过程将:
- 寻找
gcp-oauth.keys.json在当前目录或~/.calendar-mcp/ - 如果在当前目录中找到,请将其复制到
~/.calendar-mcp/ - 打开默认浏览器进行谷歌身份验证
- 将凭据另存为
~/.calendar-mcp/credentials.json
备注:
- 成功身份验证后,凭据将全局存储在
~/.calendar-mcp/并且可以从任何目录中使用 - 支持桌面应用程序和Web应用程序凭据
- 对于Web应用程序凭据,请确保添加
http://localhost:3000/oauth2callback到您授权的重定向URI
- 寻找
-
在Claude Desktop中配置:
{
"mcpServers": {
"calendar": {
"command": "npx",
"args": [
"@gongrzhe/server-calendar-autoauth-mcp"
]
}
}
}
Docker支持
如果你更喜欢使用Docker:
- 身份验证:
docker run -i --rm \
--mount type=bind,source=/path/to/gcp-oauth.keys.json,target=/gcp-oauth.keys.json \
-v mcp-calendar:/calendar-server \
-e CALENDAR_OAUTH_PATH=/gcp-oauth.keys.json \
-e "CALENDAR_CREDENTIALS_PATH=/calendar-server/credentials.json" \
-p 3000:3000 \
mcp/calendar auth
- 用途:
{
"mcpServers": {
"calendar": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-v",
"mcp-calendar:/calendar-server",
"-e",
"CALENDAR_CREDENTIALS_PATH=/calendar-server/credentials.json",
"mcp/calendar"
]
}
}
}
使用示例
服务器提供了几个可以通过Claude Desktop使用的工具:
创建活动
{
"summary": "Team Meeting",
"start": {
"dateTime": "2024-01-20T10:00:00Z"
},
"end": {
"dateTime": "2024-01-20T11:00:00Z"
},
"description": "Weekly team sync",
"location": "Conference Room A"
}
列出事件
{
"timeMin": "2024-01-01T00:00:00Z",
"timeMax": "2024-12-31T23:59:59Z",
"maxResults": 10,
"orderBy": "startTime"
}
更新事件
{
"eventId": "event123",
"summary": "Updated Meeting Title",
"start": {
"dateTime": "2024-01-20T11:00:00Z"
},
"end": {
"dateTime": "2024-01-20T12:00:00Z"
}
}
删除事件
{
"eventId": "event123"
}
安全说明
- OAuth凭据安全地存储在您的本地环境中(
~/.calendar-mcp/) - 服务器使用脱机访问来维护持久身份验证
- 切勿将您的凭据共享或提交给版本控制
- 定期查看并撤销您Google帐户设置中未使用的访问权限
- 凭据是全局存储的,但只能由当前用户访问
故障排除
-
找不到OAuth密钥
- 确保
gcp-oauth.keys.json位于您当前的目录或~/.calendar-mcp/ - 检查文件权限
- 确保
-
凭据格式无效
- 确保您的OAuth密钥文件包含以下内容之一
web或installed凭证 - 对于web应用程序,请验证重定向URI是否配置正确
- 确保您的OAuth密钥文件包含以下内容之一
-
端口已在使用中
- 如果端口3000已在使用中,请在运行身份验证之前将其释放
- 您可以使用该端口查找并停止进程
贡献
欢迎投稿!请随时提交拉取请求。
许可证
该项目根据ISC许可证获得许可。
作者
贡哲
支持
如果您遇到任何问题或有疑问,请在GitHub存储库上提交问题。
