如何使用 Gemini CLI、MCP 和 Go 建立程式碼助理

1. 簡介

在本程式碼研究室中,您將瞭解如何建構及部署 Model Context Protocol (MCP) 伺服器,藉此擴充 Gemini CLI 的功能。您將建構 godoctor,這是一個以 Go 為基礎的伺服器,可為 Go 開發作業提供自訂工具,將 Gemini CLI 從一般用途的程式設計助理,轉變為專門的 Go 開發專家。

本程式碼研究室採用「提示驅動」做法。您將擔任技術主管,向 AI 助理 (Gemini CLI 本身) 提供提示。您的目標是學習如何將專案需求轉換為有效的提示,並讓 AI 處理實作細節。

這項專案的核心是 Model Context Protocol (MCP)。MCP 是開放原始碼通訊協定,可將 Gemini 等大型語言模型 (LLM) 與外部工具和服務的通訊方式標準化。這項技術就像一座橋梁,讓 AI 能夠存取現實世界的資訊,並執行內建知識以外的動作。建立 MCP 伺服器時,您會建立 Gemini CLI 可探索及使用的自訂外掛程式,有效教導 Gemini 新技能。

課程內容

  • 如何安裝及設定 Gemini CLI
  • 如何撰寫有效的提示,引導 AI 助理進行軟體開發
  • 如何為 AI 助理提供背景資訊和指引
  • 如何建立及設定 MCP 伺服器,以擴增 Gemini CLI 的功能
  • 如何將 Go 應用程式容器化並部署至 Google Cloud Run

軟硬體需求

本研討會完全可在 Google Cloud Shell 中進行,因為這個環境已預先安裝所有必要依附元件 (gcloud CLI、Go、Docker、Gemini CLI)。

或者,如果您想在自己的電腦上操作,則需要下列項目:

  • Node.js 20 以上版本
  • 已啟用計費功能的 Google Cloud 專案
  • 已安裝並初始化 Google Cloud SDK (gcloud CLI)
  • 系統上安裝 Go 1.24 以上版本
  • 系統上已安裝 Docker

主要技術

如要進一步瞭解我們使用的技術,請參閱下列網頁:

成功完成程式碼研究室的訣竅

使用 AI 助理開發軟體是全新的方式。以下提供幾項訣竅,協助您順利完成驗證:

  1. 請放心按下 ESC 鍵。有時 AI 建議的動作或程式碼可能不符合您的需求。使用 ESC 鍵取消建議的動作,然後提供新的提示,引導 AI 往正確的方向發展。你是飛行員。
  2. 鼓勵使用工具。如果 AI 似乎迷失方向或編造資訊,請鼓勵它使用可用的工具。「你可以使用 Google 搜尋驗證嗎?」或「請先使用 read_file 工具瞭解目前的程式碼,再進行變更」等提示非常有效。
  3. 避免手動變更。盡量讓 AI 執行所有工作。這就是你練習的核心技能。不過,如果必須手動變更,請在變更後告知 AI。系統會顯示「我已手動更新 README.md 檔案。請再次閱讀,以更新知識」可確保 AI 與專案保持同步。
  4. Have you tried turning it off and on again? 在極少數情況下,如果 AI 嘗試違背您的指令強制執行特定路徑,可能是因為脈絡退化 (有時也稱為「脈絡腐敗」)。在這種情況下,您可以使用 Gemini CLI 的「/compress」指令減少脈絡雜訊,或在極端情況下使用「/clear」指令清除整個工作階段記錄。

2. 設定環境

自行設定環境

  1. 登入 Google Cloud 控制台,然後建立新專案或重複使用現有專案。如果沒有 Gmail 或 Google Workspace 帳戶,請建立帳戶

fbef9caa1602edd0.png

a99b7ace416376c4.png

5e3ff691252acf41.png

  • 專案名稱是這個專案參與者的顯示名稱。這是 Google API 未使用的字元字串。你隨時可以更新。
  • 專案 ID 在所有 Google Cloud 專案中都是不重複的,而且設定後即無法變更。Cloud 控制台會自動產生專屬字串,通常您不需要理會該字串。在大多數程式碼研究室中,您需要參照專案 ID (通常標示為 PROJECT_ID)。如果您不喜歡產生的 ID,可以產生另一個隨機 ID。你也可以嘗試使用自己的名稱,看看是否可用。完成這個步驟後就無法變更,且專案期間都會維持這個設定。
  • 請注意,有些 API 會使用第三個值,也就是「專案編號」。如要進一步瞭解這三種值,請參閱說明文件
  1. 接著,您需要在 Cloud 控制台中啟用帳單,才能使用 Cloud 資源/API。完成這個程式碼研究室的費用不高,甚至可能完全免費。如要關閉資源,避免在本教學課程結束後繼續產生費用,您可以刪除建立的資源或專案。Google Cloud 新使用者可參加價值$300 美元的免費試用計畫。

啟動 Cloud Shell

雖然您可以透過筆電遠端操作 Google Cloud,但在本程式碼研究室中,您將使用 Google Cloud Shell,這是可在雲端執行的指令列環境。

Google Cloud 控制台中,點選右上工具列的 Cloud Shell 圖示:

55efc1aaa7a4d3ad.png

佈建並連線至環境的作業只需幾分鐘即可完成。完成後,您應該會看到如下的內容:

7ffe5cbb04455448.png

這部虛擬機器搭載各種您需要的開發工具,提供永久的 5 GB 主目錄,而且在 Google Cloud 中運作,可大幅提升網路效能和驗證。您可以在瀏覽器中完成本程式碼研究室的所有作業。您不需要安裝任何軟體。

3. 開始使用 Gemini CLI

本節將介紹 Gemini CLI,包括如何為環境安裝及設定這項工具。

什麼是 Gemini CLI?

Gemini CLI 是以 AI 技術為基礎的指令列介面,可協助您完成各種開發工作。這項工具可瞭解專案的脈絡、回答問題、產生程式碼,以及使用外部工具擴充功能。

安裝

使用 npm 全域安裝 Gemini CLI。

npm install -g @google/gemini-cli

如要確認 CLI 是否已安裝,請執行下列指令:

gemini --version

設定

Gemini CLI 的行為是由設定檔和環境變數控管。主要有兩個檔案:

  • GEMINI.md:這個檔案會為 AI 提供自然語言的指引和背景資訊。CLI 會讀取這個檔案,瞭解專案的編碼標準和慣例。
  • .gemini/settings.json:這個檔案會控管 CLI 的設定,包括如何連線至外部工具。我們將使用這個檔案設定 CLI,以便在本實驗室中建構 MCP 伺服器。

我們會先設定環境,然後建立 GEMINI.md 檔案。settings.json 檔案會在後續步驟中設定。

  1. 建立及初始化專案目錄:
mkdir godoctor
cd godoctor
go mod init godoctor
  1. 使用 Google Cloud 應用程式預設憑證進行驗證:

我們需要登入可存取您要用於本程式碼研究室的 GCP 專案的帳戶:

gcloud auth application-default login

4. 開發指南

為確保 AI 助理生成高品質的慣用 Go 程式碼,請務必提供明確的指引。這項操作是在 GEMINI.md 檔案中完成。

目標:建立 GEMINI.md 檔案,做為這個專案中 AI 助理的一組規則。

工作:在 godoctor 目錄的根層級建立名為 GEMINI.md 的檔案,然後將下列內容貼入其中。

# Go Development Guidelines
All code contributed to this project must adhere to the following principles.

### 1. Formatting
All Go code **must** be formatted with `gofmt` before being submitted.

### 2. Naming Conventions
- **Packages:** Use short, concise, all-lowercase names.
- **Variables, Functions, and Methods:** Use `camelCase` for unexported identifiers and `PascalCase` for exported identifiers.
- **Interfaces:** Name interfaces for what they do (e.g., `io.Reader`), not with a prefix like `I`.

### 3. Error Handling
- Errors are values. Do not discard them.
- Handle errors explicitly using the `if err != nil` pattern.
- Provide context to errors using `fmt.Errorf("context: %w", err)`.

### 4. Simplicity and Clarity
- "Clear is better than clever." Write code that is easy to understand.
- Avoid unnecessary complexity and abstractions.
- Prefer returning concrete types, not interfaces.

### 5. Documentation
- All exported identifiers (`PascalCase`) **must** have a doc comment.
- Comments should explain the *why*, not the *what*.

# Agent Guidelines
- **Reading URLs:** ALWAYS read URLs provided by the user. They are not optional.

現在開發環境已完全設定完畢。

5. 初始建構:godoc 伺服器

您的首要目標是建立 godoctor 伺服器的初始版本。這個版本應是可供發布的最低需求應用程式,提供名為 godoc 的單一工具,可查詢 Go 文件。

目標:建立可立即用於實際工作環境的 MCP 伺服器,公開 go doc 指令,讓 LLM 查詢 Go 文件。

在 Shell 中執行 Gemini CLI 指令:

gemini

首次執行 CLI 時,系統會要求你選擇驗證模式和主題。驗證模式請選擇「使用 Google 帳戶登入」,並以個人 Google 帳戶登入,即可享有 Gemini CLI 的免費方案。您應該會看到類似以下的驗證模式選取畫面:

c2ea6b44cbeb6e08.png

如要變更選取項目,可以輸入 /auth 並按下 Enter 鍵,再次開啟這個選單。

接著,系統會提示你選擇主題:

2b2dcd367c195dbb.png

/auth 類似,您也可以稍後使用 /theme 指令變更主題。

選擇驗證方法和偏好的主題後,系統會將你帶往命令提示字元。您可以在這裡輸入指令,例如:

Write a hello world application in Go.

CLI 會結合自身的推理能力 (透過 Gemini Flash 或 Gemini Pro 等 Gemini 模型) 和工具來執行工作。每當需要與檔案系統或外部服務 (例如 API、資料庫等) 互動時,就會使用工具。隨附的工具 (又稱「內部工具」) 範例包括 read_filewrite_fileweb_fetchgoogle_search。我們建構的 MCP 伺服器也會成為 CLI 可用的工具。

首次執行工具時,系統會要求您授予權限。你可以授予一次性權限、在工作階段期間全面核准,或拒絕要求。如果是編輯檔案,您也可以使用外部編輯器編輯檔案,以進行調整。舉例來說,這是上述提示的輸出內容,用於建立 Hello World 程式:

e4b33d6cd7f03cff.png

除了提示,你也可以使用斜線指令。輸入「/」時,CLI 會自動顯示自動完成選項。你可以繼續輸入完整指令,或從選項中選取指令。上述的 /auth/theme 指令就是其中幾個。

a6294fd0d362fcdd.png

熟悉介面後,即可開始本節的主要工作,也就是要求 CLI 為我們編寫 MCP 伺服器。

建立 Hello World MCP 伺服器

確保模型能更穩定地建構項目的最佳方法之一,就是將複雜任務細分為多個步驟。雖然模型本身或許能自行解決複雜的工作,但如果沒有正確設定,模型需要很長時間才能找出正確的實作方式。

為了採取更一致的做法,我們將先指示建構「Hello World」MCP 伺服器,再實作所需功能 (讀取 Go 說明文件)。

提示範例如下所示:

Your task is to create a Model Context Protocol (MCP) server to expose a "hello world" tool. For the MCP implementation, you should use the official Go SDK for MCP and use the stdio transport.

Read these references to gather information about the technology and project structure before writing any code:
- https://github.com/modelcontextprotocol/go-sdk/blob/main/README.md
- https://modelcontextprotocol.io/specification/2025-06-18/basic/lifecycle
- https://go.dev/doc/modules/layout

To test the server, use shell commands like these:
(
  echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18"}}';
  echo '{"jsonrpc":"2.0","method":"notifications/initialized","params":{}}';
  echo '{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}';
) | ./bin/godoctor

請注意,上述提示由三個主要部分組成:

  1. 問題規格,包括要建構的內容和限制 (例如使用官方 SDK,而非任何 SDK)
  2. 模型的參考文件,可協助模型消除要求中的歧義
  3. 測試程序,可做為工作的驗收條件

有了這三種元件,模型就能更穩定地達成預期結果。

導入 Go 說明文件工具

實作完成後,我們就可以開始實作真正的「go doc」工具:

Add a new tool to our MCP server called "godoc" that invokes the "go doc" shell command. The tool will take a mandatory "package" argument and an optional "symbol" argument.

Read the reference for the go doc command to understand its API: https://pkg.go.dev/golang.org/x/tools/cmd/godoc

Test it by executing the call with:
  echo '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name": "godoc", "arguments": {"package": "fmt"} } }'
 | ./bin/godoctor

Test it using both a standard library package and an external package like "github.com/modelcontextprotocol/go-sdk/mcp", both with and without symbols.

歡迎試用這個提示,或自行發想提示。

實用的指令列介面

確定實作方式後,您可以使用 MCP 用戶端,指示模型建立 godoctor CLI。這樣一來,您就不必像以往一樣手動建構 JSON-RPC 呼叫,可簡化功能測試程序。

提示範例:

Now create a godoctor-cli component that will call the MCP server using command transport. This CLI will expose all tools using subcommands and allow us to test the MCP server implementation without needing to build the JSON-RPC calls manually.

Use the reference implementation at https://github.com/modelcontextprotocol/go-sdk/blob/main/README.md to build the client.

Test it by calling from the command line:
- the hello_world tool 
- the godoc tool with a local package
- the godoc tool with a local package and symbol
- the godoc tool with an external package
- the godoc tool with an external package and symbol

您現在已有一組可正常運作的用戶端和伺服器,接下來將使用剛建立的 MCP 伺服器設定 Gemini CLI,以便在下一個編碼工作開始運用其優勢。

實用資源

由於 MCP 仍是新概念,且 MCP 的 Go SDK 是新程式庫,因此在這個步驟中,Gemini 可能需要很長時間才能自行探索正確的實作方式。為協助模型找出正確解決方案,建議提供下列參考資料:

  1. 您可以向模型提供下列提示,讓模型更一致地探索 SDK API:「use the go doc shell command to discover the api for the go-sdk library」(使用 go doc 殼層指令探索 go-sdk 程式庫的 API)
  2. 如果模型嘗試使用 read_file 工具檢查 SDK 的原始碼,會因為 Gemini CLI 無法讀取目前範圍外的檔案而失敗。您可以透過 run_shell_command 工具,指示使用 catls 指令。
  3. 如果模型無法順利偵錯應用程式,請指示模型新增更詳細的記錄,並改善錯誤訊息中的脈絡資訊。
  4. 如果其他方法全都失效,請參考實作方式:https://github.com/danicat/godoctor

6. 將 godoctor 設定為 Gemini CLI 的 MCP 伺服器

AI 助理生成用戶端和伺服器的程式碼後,您可以指示執行幾項手動測試。例如:

retrieve the documentation for the package net/http

請務必使用外部依附元件 (不在標準程式庫中) 進行測試:

retrieve the documentation for the go-sdk package

確認結果符合需求後,請指示模型撰寫 README.md,說明如何使用及開發這個專案。

Now write a detailed README.md file explaining both from a user and a developer perspective how to use and to build this project.

現在我們要設定伺服器,讓 Gemini CLI 在下一個開發階段使用。

  1. 要求 CLI 更新 GEMINI.md,使用 godoc 做為讀取說明文件的偏好方法:
update the GEMINI.md file to use the godoc tool to retrieve documentation about Go packages or symbols. Always prefer to use godoc over WebFetch and GoogleSearch, and only use those when godoc doesn't give a clear answer.
  1. 現在需要重新啟動 Gemini CLI 來設定。首先,請儲存對話工作階段,以便在重新啟動後從中斷處繼續。
/chat save workshop001
  1. 按兩次 Ctrl+D 鍵,退出 CLI。
  2. 編譯伺服器二進位檔:建立 bin 目錄,然後將 godoctor 伺服器編譯至該目錄。
mkdir -p bin
go build -o ./bin/godoctor ./cmd/godoctor # adjust paths as needed
  1. 設定本機工具的 Gemini CLI:在專案根目錄中建立 .gemini/settings.json 檔案,並新增 mcpServers 區段,告知 Gemini CLI 如何執行已編譯的伺服器。
mkdir -p .gemini
touch .gemini/settings.json
  1. 現在,請使用 vimnano 等指令列編輯器,將下列內容新增至新檔案:
{
  "mcpServers": {
    "godoctor": {
      "command": "./bin/godoctor"
    }
  }
}
  1. 現在啟動 Gemini CLI 並還原對話工作階段:
/chat resume workshop001
  1. 按下 Ctrl+T 鍵,您應該就能看到工具已載入:

2d0f7c9b3550300a.png

  1. 請 Gemini CLI 使用您的工具,並輸入「取得 net/http 的說明文件」等提示,測試整合功能

畫面應如下所示:

5c806e3aa4b75165.png

如果工具運作正常,您應該會看到透過工具呼叫擷取的說明文件:

6a2b8f33ebeb86d2.png

恭喜,你已建立 MCP 工具!但這還不是最終版本,我們還可以讓它更實用。

7. 新增 AI 輔助程式碼審查員

現在要加入更精密的 AI 輔助功能:使用 Gemini API 的程式碼審查工具。

目標:在現有專案中新增名為 code_review 的工具。這項工具會使用 Gemini API 分析 Go 程式碼並提供意見回饋。

提示範例:

I want to add a new tool to my project called code_review. This tool should use the Gemini API to analyze Go code and provide a list of improvements in json format according to the best practices accepted by the Go community. The tool should take the Go code content and an optional hint as input. The hint will be used to provide additional guidance for the AI reviewer, like "focus on security" or "help me simplify this code". Please update the server to include this new tool and modify the CLI client to add a review command to use it.

Use this SDK to call Gemini: https://github.com/googleapis/go-genai

實用提示

模型開始處理後,您可能會自動看到模型要求呼叫 godoc 工具,以瀏覽 genai 套件的文件。如果沒有,隨時可以按 Esc 鍵中斷程序,並提醒模型現在可以使用 godoc 工具。

測試程式碼審查員

  1. 我們需要重新啟動 Gemini CLI,才能建構及重新載入 MCP 伺服器。使用 /chat save workshop002 儲存即時通訊工作階段,然後按兩次 Ctrl+D 鍵,退出 CLI。
  2. 由於我們要呼叫 Gemini 模型來進行評論,因此 code_review 工具需要 API 金鑰。您可以使用 Google AI Studio 產生 API 金鑰。
  3. 使用上一個步驟中產生的 API 金鑰,設定環境變數 GEMINI_API_KEY
export GEMINI_API_KEY="YOUR_API_KEY"
  1. 重新編譯伺服器:新增工具後,您必須重新編譯伺服器二進位檔,才能納入變更。
go build -o ./bin/godoctor ./cmd/godoctor
  1. 再次啟動 Gemini CLI。還原與 /chat resume workshop002 的即時通訊工作階段。
  2. 重要事項。請務必使用個人 Gmail 帳戶進行驗證,確保 Gemini CLI 本身不會使用您的帳單帳戶。您可以使用 /auth 指令執行這項操作:

9d906ba69f571bb7.png

  1. 按下 Ctrl+T 鍵,確認工具已啟用。畫面應如下所示:

fc5cf95c413ac8b.png

  1. 現在來測試 code-review 工具,方法是查看工具的其中一個來源檔案:

「Use the godoctor tool to review the cmd/godoctor/main.go file.」(使用 godoctor 工具檢查 cmd/godoctor/main.go 檔案)。

    You should see something like this:

819860af008ee643.png

程式碼審查工具運作後,您現在可以建議模型套用發現的改善項目,完成「自我改善」工作流程!

您現在已確認 code-review 工具可正常運作。在下一節中,您將瞭解如何將其部署至雲端。

如要清除 GEMINI_API_KEY:

  1. 使用 /chat save workshop003 儲存目前的工作階段並退出 CLI
  2. 將 API 金鑰備份到安全的地方:
export | grep GEMINI_API_KEY > env.bkp
  1. 取消設定 GEMINI_API_KEY
export GEMINI_API_KEY=
  1. 重新啟動 CLI,然後使用 /chat resume workshop003 載入工作階段。
  2. 要求模型套用程式碼審查改善項目。

8. 準備好雲端伺服器

我們目前開發的 MCP 伺服器只會在區域機器上執行,如果您是開發自用工具,這沒什麼問題,但通常在企業環境中,我們需要部署工具,供數百甚至數千名開發人員使用。

為了擴充 MCP 伺服器,我們需要將只能使用標準 I/O 的伺服器,轉換為可使用 HTTP 的伺服器,並部署在不同開發人員都能存取的位置。為達成這個目標,我們將使用 MCP 規格中定義的傳輸模式 (可串流的 HTTP),並以 Cloud Run 做為部署目標。

目標:重構 godoctor 伺服器,改用可串流的 HTTP 傳輸。

提示範例:

The godoctor server is currently using the stdio transport. I want to deploy it to Cloud Run, so I need to refactor it to use the streamable HTTP transport instead. Please modify the server to comply with the streamable HTTP specification.

實用資源

  1. 如果模型難以實作可串流的 HTTP 傳輸,您可以提供這個參考資料:https://github.com/modelcontextprotocol/go-sdk/blob/main/design/design.md
  2. 模型可能會嘗試改用 HTTP+SSE,但這項功能已淘汰。如果發現串流正朝這個路徑前進,請將其導回可串流的 HTTP。

使用 HTTP 測試伺服器

請模型更新 godoctor 用戶端,一併使用可串流的 HTTP,以便測試是否仍可正常運作。

Now update the client to use streamable HTTP and run a test by retrieving documentation from one package

選用:如要將 Gemini CLI 設為透過 HTTP 使用伺服器,請按照下列步驟操作:

  1. 儲存工作階段並退出 CLI
  2. 編輯 .gemini/settings.json 檔案,並變更設定,指向本機執行的伺服器。
"mcpServers": {
  "godoctor": {
    "httpUrl": "http://localhost:8080"
  }
}
  1. 在本機執行重構的伺服器:
go run ./cmd/godoctor/main.go
  1. 在新的終端機中 (因為上述作業會封鎖),啟動 Gemini CLI 並提供提示來測試連線,例如 「Use the godoctor tool to get the documentation for fmt.Println.」(使用 godoctor 工具取得 fmt.Println 的說明文件。)
  2. 測試完成後,請按下 Ctrl+C 停止伺服器。

9. 使用 Docker 裝載應用程式

現在伺服器已使用正確的傳輸通訊協定,我們可以將其容器化以進行部署。

目標:建立 Dockerfile,將 godoctor 伺服器封裝到可攜式、可立即用於實際工作環境的容器映像檔。

提示範例:

Please create a multi-stage Dockerfile that compiles the Go binary and copies it into a minimal golang image like golang:1.24-alpine.

測試 Docker 映像檔

建立 Dockerfile 後,請建構並執行映像檔,確保運作正常。你可以指示 Gemini 幫你完成這項工作:

build the image and test the connectivity to the server using the godoctor client

選用:如要手動進行測試,請按照下列步驟操作:

  1. 建構容器:
docker build -t godoctor:latest .
  1. 在本機執行容器:
docker run -p 8080:8080 -e PORT=8080 godoctor:latest
  1. 測試執行中的容器:在另一個終端機中啟動 Gemini CLI,並要求擷取說明文件。
  2. 測試完成後,請按下 Ctrl+C 停止伺服器。

10. 部署至 Cloud Run

現在要將容器部署至雲端。

目標:將容器化 godoctor 伺服器部署至 Google Cloud Run。

提示指引:要求 AI 助理提供部署容器的 gcloud 指令。

提示範例:

Now please deploy this image to Cloud Run and return me an URL I can use to call the MCP tool. Deploy it to us-central1 and use the project currently configured in the environment.

部署完成後,我們會設定 Gemini CLI,以便使用您剛部署的工具。

請 Gemini 更新 .gemini/settings.json 檔案,將 MCP 工具設定變更為指向已部署的服務。

now update the .gemini/settings.json file to use this URL for the godoctor server

最終的 mcpServers 區段應如下所示 (請記得將預留位置替換為實際的 Cloud Run 應用程式網址):

"mcpServers": {
  "godoctor": {
    "httpUrl": "https://<your-cloud-run-id>.us-central1.run.app"
  }
}

測試 Cloud Run 部署作業

現在可以進行最終的端對端測試。

最後一次重新啟動 Gemini CLI (使用 /chat save/chat resume 保留內容)。現在 CLI 應該可以呼叫遠端 MCP 伺服器。你可以要求任何套件的說明文件。

請注意,服務必須有 GEMINI_API_KEY,才能使用程式碼審查工具。你可以要求 Gemini CLI 使用正確的環境重新部署:

update the cloud run environment to add a GEMINI_API_KEY and use the value in @env.bkp. Then update the .gemini/settings.json file with the correct service URL

重新啟動 CLI,然後使用提示詞測試:

Use the godoctor tool to review the cmd/godoctor/main.go file

Gemini CLI 現在會連線至已部署的 Cloud Run 服務,並執行程式碼審查。

提示範例:

I'm done with my tests on the CloudRun server, please delete this deployment for me and revert my .gemini/settings.json to use the local version.

11. 恭喜!

您已成功引導 AI 助理建構、容器化及部署進階的 AI 輔助工具。更重要的是,您已練習現代軟體開發的必備技能:將需求轉換為有效的提示。您已成功使用自訂工具擴充 Gemini CLI,讓它成為更強大且專業的 Go 開發助理。

參考文件