本文档详细说明了使用Google Calendar API搜索日历内容,并将其设置为MCP服务器所需的环境配置步骤,帮助你快速搭建相关环境。
在Google Cloud Console或以下链接中启用Google Calendar API: 启用API
导航到Google Cloud Console菜单中的品牌页,或访问以下链接: 品牌
导航到Google Cloud Console菜单中的客户端页面,或访问以下链接: 客户端
credentials.json
,并将该文件移动到你的工作目录。uv sync
token.json
token.json
文件:uv run generate_token.py
token.json
文件。calendar_settings.json
calendar_settings.json.sample
文件。
例如,配置如下:{
"calendar_ids": {
"primary": "primary",
"work": "example_work_schedule_id"
}
}
primary
:你的Google账户主日历的ID(通常为“primary”)。work
:工作日历的ID。设置所需的日历ID,然后将文件重命名为calendar_settings.json
并保存。
.vscode
目录,并编辑其中的mcp.json.sample
文件。mcp.json.sample
文件如下:{
"servers": {
"google-calendar-mcp-server": {
"type": "stdio",
"command": "/home///.venv/bin/python" ,
"args": [
"/home///google_calendar_mcp_server.py"
]
}
}
}
替换为你的用户名。
替换为项目目录名。例如,如果你的用户名是tatsuya
,项目目录名为google-calendar-mcp-server
,配置如下:
{
"servers": {
"google-calendar-mcp-server": {
"type": "stdio",
"command": "/home/tatsuya/google-calendar-mcp-server/.venv/bin/python",
"args": [
"/home/tatsuya/google-calendar-mcp-server/google_calendar_mcp_server.py"
]
}
}
}
mcp.json
并保存。按照以下步骤设置GitHub Copilot Chat在Visual Studio Code中的代理模式:
npm run dev
localhost:3000
。⚠️ 重要提示
如果发生错误,请检查错误信息,并根据需要重新安装依赖项或检查Google Cloud Console中的设置。