Google Calendar MCP Server 是一个基于模型上下文协议(MCP)的服务器,它具备全面的 Google Calendar 集成能力。该服务器允许 AI 助手和应用程序通过标准化协议与 Google Calendar 进行交互。
# 启动编译后的服务器
npm start
# 或者在开发模式下运行
npm run dev
将此服务器添加到您的 MCP 客户端配置中:
{
"servers": {
"google-calendar": {
"type": "stdio",
"command": "node",
"args": ["./dist/index.js"]
}
}
}
对于使用 MCP 扩展的 VS Code,将以下内容添加到 .vscode/mcp.json
中:
{
"servers": {
"google-calendar-mcp-server": {
"type": "stdio",
"command": "node",
"args": ["./dist/index.js"]
}
}
}
.env
文件。npm install
copy .env.example .env
.env
文件,设置您的 Google 服务账户密钥文件路径:GOOGLE_SERVICE_ACCOUNT_KEY_FILE=./path/to/your/service-account-key.json
# 构建 TypeScript 代码
npm run build
# 开发模式,支持热重载
npm run dev
# 类型检查
npm run type-check
# 清理构建产物
npm run clean
list_events
使用各种过滤选项从 Google Calendar 检索活动。
参数:
calendarId
(可选):日历 ID(默认值:"primary")timeMin
(可选):活动开始时间的下限(RFC3339 时间戳)timeMax
(可选):活动开始时间的上限(RFC3339 时间戳)maxResults
(可选):活动的最大数量(默认值:250)singleEvents
(可选):展开重复活动(默认值:true)orderBy
(可选):按“startTime”或“updated”对活动进行排序create_event
在 Google Calendar 中创建一个新的活动。
参数:
calendarId
(可选):日历 ID(默认值:"primary")summary
(必需):活动标题description
(可选):活动描述start
(必需):包含 dateTime 和可选 timeZone 的开始日期/时间对象end
(必需):包含 dateTime 和可选 timeZone 的结束日期/时间对象location
(可选):活动地点attendees
(可选):包含电子邮件和显示名称的参与者对象数组recurrence
(可选):用于重复活动的 RRULE 字符串数组update_event
更新现有的日历活动。
参数:
calendarId
(可选):日历 ID(默认值:"primary")eventId
(必需):要更新的活动 IDsummary
(可选):新的活动标题description
(可选):新的活动描述start
(可选):新的开始日期/时间end
(可选):新的结束日期/时间location
(可选):新的活动地点attendees
(可选):新的参与者列表delete_event
从 Google Calendar 中删除一个活动。
参数:
calendarId
(可选):日历 ID(默认值:"primary")eventId
(必需):要删除的活动 IDlist_calendars
列出经过身份验证的用户可用的 Google 日历。
参数:
minAccessRole
(可选):最小访问角色过滤器showDeleted
(可选):包括已删除的日历(默认值:false)showHidden
(可选):包括隐藏的日历(默认值:false)src/
├── index.ts # 主要的 MCP 服务器实现
├── types/ # TypeScript 类型定义
└── utils/ # 实用函数
.env.example # 环境变量模板
tsconfig.json # TypeScript 配置
package.json # Node.js 依赖项和脚本
所有工具都返回结构化响应:
// 成功响应
{
content: [{ type: "text", text: JSON.stringify(result) }]
}
// 错误响应
{
content: [{ type: "text", text: JSON.stringify(error) }],
isError: true
}
本项目采用 MIT 许可证,详情请参阅 LICENSE 文件。
如有问题和疑问: