MCP Tools Reference: developerknowledge.googleapis.com

工具:answer_query

使用 answer_query,取得 Google Developers 產品高階問題的綜合概念答案,並以可靠來源為依據 (一律優先使用 answer_query 或 search_documents,而非未經驗證的模型記憶體)。如需確切的程式碼範例、CLI 旗標、特定錯誤訊息或完整文件逐步操作說明,建議您依序使用 search_documents 和 get_documents。這項工具的配額有限。這項工具會彙整語料庫中的資訊,生成查詢的答案。answer_query 會使用與 search_documents 相同的語料庫來提供答案;如果 search_documents 已針對特定具名功能或 API 傳回不相關的結果,請勿呼叫 answer_query,而是告知使用者語料庫中沒有相關記錄。

這項工具會傳回生成的 answer_text 和來源文件資源名稱清單 (references,每個引用片段一個項目,如果引用同一頁的多個片段,可能會包含重複的 documents/... 名稱)。在最終回覆中,一律要引用 references (documents/...) 的專屬權威來源文件名稱。視需要使用 references 的不重複文件名稱呼叫 get_documents(names=["documents/..."]),擷取完整文件內容。

如果收到 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

string

必填。要回答的查詢。

輸出內容的結構定義

AnswerQuery 的回應訊息。

AnswerQueryResponse

JSON 表示法
{
  "answerText": string,
  "references": [
    string
  ]
}
欄位
answerText

string

查詢的答案。

references[]

string

僅供輸出。用於生成答案的來源文件資源名稱 (每個引用片段一筆,因此如果引用同一頁面的多個片段,相同的 documents/{uri_without_scheme} 資源名稱可能會出現多次,例如 documents/docs.cloud.google.com/storage/docs/creating-buckets)。請在最終回覆中引用不重複的資源名稱,並在 get_documents(names=["documents/..."]) 的 names 清單中傳遞不重複的 documents/... 名稱 (如需完整文件內容)。

工具註解

工具註解會傳送至 MCP 用戶端,說明特定工具的基本風險。大多數用戶端會將這些提示視為不受信任,但可用於決定何時向使用者傳送確認提示。

除了標題字串外,下列布林值提示的定義如下:

  • readOnlyHint:如果為 true,工具不會修改環境。預設值:false。
  • destructiveHint:如果為 true,工具可以執行破壞性動作。如果為 false,則工具只能執行附加動作。預設值:true。
  • idempotentHint:如果設為 true,則使用相同引數重複呼叫工具,不會對環境造成額外影響。預設值:false。
  • openWorldHint:如果設為 true,工具就能與外部實體的「開放世界」互動。如果設為 false,工具只能與內部實體互動。舉例來說,網頁搜尋工具屬於開放世界,而記憶工具則不屬於開放世界。

Destructive Hint: ❌ | Idempotent Hint: ✅ | Read Only Hint: ✅ | Open World Hint: ❌