这是一个用于与 Google Calendar API 对接的最小化协调处理器 (MCP) 服务器,为集成到 Claude Desktop 中提供了所需的接口,可实现日历事件的创建、读取、更新和删除等操作。
启动服务器后,访问 http://localhost:3000
查看文档。
两种认证方式可选:
curl http://localhost:3000/mcp/auth/url
curl -X POST http://localhost:3000/auth/direct
google-calendar-mcp/
├── src/ # 源代码目录
│ ├── server.js # 主服务器文件
│ ├── routes/ # 路由定义
│ └── controllers/ # 控制器逻辑
├── .env # 环境变量配置文件
├── Dockerfile # Docker 构建配置
└── package.json # 项目依赖和脚本配置
npm install
# 或者使用 yarn
yarn install
创建 .env
文件,并添加以下内容:
GOOGLE_CLIENT_ID=your_client_id_here
GOOGLE_CLIENT_SECRET=your_client_secret_here
PORT=3000 # 可选,默认为3000
git clone https://github.com/your-repository.git
cd google-calendar-mcp
npm install
# 或者 yarn
npm start
# 或者 yarn start
curl http://localhost:3000/mcp/events/upcoming
请求格式:
{
"summary": "会议",
"description": "重要讨论",
"start": {
"dateTime": "2024-01-15T10:00:00+08:00"
},
"end": {
"dateTime": "2024-01-15T11:30:00+08:00"
}
}
发送请求:
curl -X POST http://localhost:3000/mcp/events/create -H "Content-Type: application/json" -d '{"summary":"会议","description":"重要讨论","start":{"dateTime":"2024-01-15T10:00:00+08:00"},"end":{"dateTime":"2024-01-15T11:30:00+08:00"}}'
GET /mcp/auth/url
:获取 Google OAuth2 授权链接POST /mcp/auth/callback
:处理 OAuth2 回调POST /auth/direct
:直接认证GET /mcp/calendars
:获取所有可用日历列表GET /mcp/events
:从指定日历获取事件GET /mcp/events/upcoming
:获取所有日历中的即将进行的事件POST /mcp/events/create
:创建新事件PUT /mcp/events/update
:更新现有事件DELETE /mcp/events/delete
:删除事件GET /mcp/events/detail
:获取特定事件详情GET /mcp/info
:获取服务器信息和可用端点GET /health
:健康检查端点运行测试:
npm test
# 或者 yarn test
docker build -t google-calendar-mcp .
docker run -p 3000:3000 --env-file .env google-calendar-mcp
.env
文件不被提交到版本控制系统常见问题:
GOOGLE_CLIENT_ID
和 GOOGLE_CLIENT_SECRET
是否正确。如何贡献代码: