iT邦幫忙

2025 iThome 鐵人賽

DAY 29
0
生成式 AI

MCP Server 全攻略:讓 AI 動態調用工具的工作流革命系列 第 29

[29] Mcp server 使用 google 服務的前置作業

  • 分享至 

  • xImage
  •  

為了使用 google 相關的服務, 這邊以 gmail 為例, 我們首先需要去 google clound console 新增一個專案, 這個專案是 for 我們個人利用 mcp server 使用, 點選 New project:

https://ithelp.ithome.com.tw/upload/images/20251013/20141182rbzEFzjVDv.png

https://ithelp.ithome.com.tw/upload/images/20251013/20141182kGETn6AB53.png

點選 apis & services:

https://ithelp.ithome.com.tw/upload/images/20251013/2014118229S9pVtF81.png

搜尋 gmail:
https://ithelp.ithome.com.tw/upload/images/20251013/20141182S2Q9REnZ8w.png

接著點選 enable:
https://ithelp.ithome.com.tw/upload/images/20251013/20141182EsHwdryAIK.png

好了之後我們要來設定 Credentials, 讓我們點選左邊的面板, 在 Apis & Services 點選 Credentials:

我們需要先去設定畫面:

點選 get started:
https://ithelp.ithome.com.tw/upload/images/20251013/20141182HG2WJQpn0O.png
按照步驟填寫資料後點選創建:
https://ithelp.ithome.com.tw/upload/images/20251013/201411820SXm6h15ik.png

並且在 Google Cloud Console → OAuth 同意畫面 (Consent screen) 新增測試人員:

https://ithelp.ithome.com.tw/upload/images/20251014/20141182eW1NQwdFBl.png

接著回到 Apis & Services 選擇 Credentials, 就會看到現在我們可以建立 oauth credentials 了:

https://ithelp.ithome.com.tw/upload/images/20251013/20141182pyNc2hCFGX.png

接著下載 json 檔:
https://ithelp.ithome.com.tw/upload/images/20251013/20141182TihNe8apce.png

這樣我們就完成了, 之後跟 google 有關的 mcp server 所需要的 credentials 資料你就有了

https://ithelp.ithome.com.tw/upload/images/20251013/201411821pk5dehNt4.png

以這個 gmail mcp server 為範例, 他會需要你在運行時指定 credential json 的檔案路徑作為 auth 方式:

docker run -i --rm \
  --mount type=bind,source=/path/to/gcp-oauth.keys.json,target=/gcp-oauth.keys.json \
  -v mcp-gmail:/gmail-server \
  -e GMAIL_OAUTH_PATH=/gcp-oauth.keys.json \
  -e "GMAIL_CREDENTIALS_PATH=/gmail-server/credentials.json" \
  -p 3000:3000 \
  mcp/gmail auth

複習

為了要使用 google 的服務, 我們需要兩步驟:

  1. 創建專案, 並且啟用欲使用的服務
  2. 新增 OAuth 2.0 Credentials

上一篇
[28] mcp server 的安全疑慮
下一篇
[30] Mcp server google sheet 將 api 返回的資料寫入 google sheet
系列文
MCP Server 全攻略:讓 AI 動態調用工具的工作流革命30
圖片
  熱門推薦
圖片
{{ item.channelVendor }} | {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言