谷歌任务MCP服务器(Python)
用于Google任务的模型上下文协议(MCP)服务器,用Python编写并使用FastMCP运行。
特性
- 管理任务列表
- 创建、更新、删除任务
- 筛选任务(今天到期,逾期)
- Docker化部署
设置
先决条件
- 谷歌云项目:启用“任务API”。
- 凭证:
- 选项A(环境变量):设置 GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET,以及 GOOGLE_REFRESH_TOKEN. - 选项B(基于文件):地点 credentials.json 根目录中的(OAuth客户端机密)。服务器将启动一个交互式流来生成 token.json 第一次跑步。
本地开发
- 安装依赖项:
pip install -r pyproject.toml
# OR using uv
uv run python -m src.server- 运行服务器:
python -m src.server服务器将侦听端口3333。
码头工人
- 构建:
docker build -t GoogleTasksMCP .- 跑步(环境变量):
docker run -p 3333:3333 \
-e GOOGLE_CLIENT_ID=... \
-e GOOGLE_CLIENT_SECRET=... \
-e GOOGLE_REFRESH_TOKEN=... \
GoogleTasksMCP- 运行(令牌绑定器装载):
touch token.json # Ensure it exists or mount folder
docker run -p 3333:3333 \
-v $(pwd)/credentials.json:/app/credentials.json \
-v $(pwd)/token.json:/app/token.json \
GoogleTasksMCPNginx反向代理(OAuth 2.1)
如果服务器在反向代理后面运行(例如在 textdonna.com/tasks/),添加这些规则,以便可以访问OAuth发现端点:
location /.well-known/oauth-protected-resource/tasks/ {
proxy_pass http://127.0.0.1:3333/.well-known/oauth-protected-resource/tasks/;
}
location /.well-known/oauth-authorization-server/tasks {
proxy_pass http://127.0.0.1:3333/.well-known/oauth-authorization-server/tasks;
}可用工具
list_task_listscreate_taskget_current_tasksupdate_taskdelete_tasksearch_tasks
