工具:answer_query
使用 answer_query,取得 Google Developers 產品相關高階問題的綜合概念答案。如需確切的程式碼範例、CLI 旗標、特定錯誤訊息或完整文件逐步操作說明,建議先使用 search_documents,再使用 get_documents。這項工具的配額有限。這項工具會彙整語料庫中的資訊,生成查詢答案。answer_query 會使用與 search_documents 相同的語料庫,做為答案的依據。這項工具會傳回生成的 answer_text,以及用於生成答案的文件名稱 (參考資料) 清單。在最終回覆中,務必引用 references (documents/...) 的權威來源文件名稱。視需要使用 get_documents 搭配 references 的文件名稱,擷取整份文件內容。
如果收到 429 配額不足錯誤,請改用 search_documents。
以下程式碼範例說明如何使用 curl 呼叫 answer_query MCP 工具。
| Curl 要求 |
|---|
curl --location 'https://developerknowledge.googleapis.com/mcp' \ --header 'content-type: application/json' \ --header 'accept: application/json, text/event-stream' \ --data '{ "method": "tools/call", "params": { "name": "answer_query", "arguments": { // Provide these details according to the MCP tool specification. } }, "jsonrpc": "2.0", "id": 1 }' |
輸入內容的結構定義
AnswerQuery 的要求訊息。
AnswerQueryRequest
| JSON 表示法 |
|---|
{ "query": string } |
| 欄位 | |
|---|---|
query |
必填。要回答的查詢。 |
輸出內容的結構定義
AnswerQuery 的回應訊息。
AnswerQueryResponse
| JSON 表示法 |
|---|
{ "answerText": string, "references": [ string ] } |
| 欄位 | |
|---|---|
answerText |
查詢的答案。 |
references[] |
僅供輸出。用於生成答案的文件資源名稱 (例如 |
工具註解
工具註解會傳送至 MCP 用戶端,說明特定工具的基本風險。大多數用戶端會將這些提示視為不受信任,但可用於決定何時向使用者傳送確認提示。
除了標題字串外,下列布林值提示的定義如下:
readOnlyHint:如果為 true,工具不會修改環境。預設值:false。destructiveHint:如果為 true,工具可以執行破壞性動作。如果設為 false,工具只能執行新增動作。預設值:true。idempotentHint:如果設為 true,則使用相同引數重複呼叫工具,不會對環境產生額外影響。預設值:false。openWorldHint:如果設為 true,工具就能與外部實體的「開放世界」互動。如果設為 false,工具只能與內部實體互動。舉例來說,網頁搜尋工具屬於開放世界,而記憶工具則不屬於開放世界。
Destructive Hint: ❌ | Idempotent Hint: ✅ | Read Only Hint: ✅ | Open World Hint: ❌