工具:search_messages
使用關鍵字和篩選器搜尋 Google Chat 訊息。適用於使用者可存取的所有聊天室,或可限定於特定對話。
下列範例示範如何使用 curl 叫用 search_messages MCP 工具。
| Curl 要求 |
|---|
curl --location 'https://chatmcp.googleapis.com/mcp/v1' \ --header 'content-type: application/json' \ --header 'accept: application/json, text/event-stream' \ --data '{ "method": "tools/call", "params": { "name": "search_messages", "arguments": { // provide these details according to the tool MCP specification } }, "jsonrpc": "2.0", "id": 1 }' |
輸入內容的結構定義
要求使用關鍵字和篩選器搜尋 Google Chat 訊息。適用於使用者可存取的所有聊天室,或可限定於特定對話。
SearchMessagesRequest
| JSON 表示法 |
|---|
{
"searchParameters": {
object ( |
| 欄位 | |
|---|---|
searchParameters |
必填。用於搜尋的搜尋參數。 |
pageSize |
(選用步驟) 要傳回的結果數上限 (最多 100 個)。如未指定,最多會傳回 25 個。 |
pageToken |
(選用步驟) 屬於接收自前一個 |
SearchParameters
| JSON 表示法 |
|---|
{ "keywords": [ string ], "conversationId": string, "sender": string, "isUnread": boolean, "hasLink": boolean, "startTime": string, "endTime": string, "mentionsMe": boolean, "conversationIncludesUser": string, "spaceDisplayNames": [ string ] } |
| 欄位 | |
|---|---|
keywords[] |
(選用步驟) 用於篩選結果的一組關鍵字。 |
conversationId |
(選用步驟) 將搜尋範圍限定為特定對話 ID,如 search_conversations 工具傳回的 ID。格式: |
sender |
(選用步驟) 篩選特定使用者的訊息。你可以使用寄件者的電子郵件地址或資源名稱。使用者資源名稱的格式為 |
isUnread |
(選用步驟) 篩選出通話使用者尚未讀取的訊息。 |
hasLink |
(選用步驟) 篩選出至少含有一個網址的郵件/訊息。 |
startTime |
(選用步驟) 篩選出這個時間之後建立的訊息。格式:ISO 8601 時間戳記。 |
endTime |
(選用步驟) 篩選出在此時間之前建立的訊息。格式:ISO 8601 時間戳記。 |
mentionsMe |
(選用步驟) 篩選出明確提及通話使用者的訊息。 |
conversationIncludesUser |
(選用步驟) 篩選即時訊息和群組通訊中包含特定使用者電子郵件地址或 ID 的訊息。 |
spaceDisplayNames[] |
(選用步驟) 依聊天室名稱清單篩選,聊天室顯示名稱會部分相符。注意:系統只會傳回前 5 個相符項目。 |
輸出內容的結構定義
回應搜尋 Google Chat 訊息的要求。如果已填入 next_page_token,則可使用該權杖再次呼叫 SearchMessages,以擷取下一頁結果。
SearchMessagesResponse
| JSON 表示法 |
|---|
{
"messages": [
{
object ( |
| 欄位 | |
|---|---|
messages[] |
符合搜尋條件的訊息物件清單。 |
nextPageToken |
可做為 |
ChatMessage
| JSON 表示法 |
|---|
{ "messageId": string, "threadId": string, "plaintextBody": string, "sender": { object ( |
| 欄位 | |
|---|---|
messageId |
訊息的資源名稱。格式:spaces/{space}/messages/{message} |
threadId |
這則訊息所屬的討論串。如果訊息未歸入任何討論串,這個欄位會是空白。格式:spaces/{space}/threads/{thread} |
plaintextBody |
使用 Markdown 格式設定的訊息內文。 |
sender |
訊息寄件者。 |
createTime |
僅供輸出。訊息建立時間的時間戳記。 |
threadedReply |
訊息是否為討論串回覆。 |
attachments[] |
郵件中包含的附件。 |
reactionSummaries[] |
訊息中包含的表情符號回應摘要。 |
使用者
| JSON 表示法 |
|---|
{
"userId": string,
"displayName": string,
"email": string,
"userType": enum ( |
| 欄位 | |
|---|---|
userId |
Chat 使用者的資源名稱。格式:users/{user}。 |
displayName |
Chat 使用者的顯示名稱。 |
email |
使用者的電子郵件地址。只有在使用者類型為「HUMAN」時,才會填寫這個欄位。 |
userType |
使用者類型。 |
ChatAttachmentMetadata
| JSON 表示法 |
|---|
{
"attachmentId": string,
"filename": string,
"mimeType": string,
"source": enum ( |
| 欄位 | |
|---|---|
attachmentId |
附件的資源名稱。格式:spaces/{space}/messages/{message}/attachments/{attachment}。 |
filename |
附件名稱。 |
mimeType |
內容類型 (MIME 類型)。 |
source |
附件來源。 |
ReactionSummary
| JSON 表示法 |
|---|
{ "emoji": string, "count": integer } |
| 欄位 | |
|---|---|
emoji |
表情符號 Unicode 字串或自訂表情符號名稱。 |
count |
使用相關聯表情符號的回應總數。 |
UserType
Google Chat 使用者類型。
| 列舉 | |
|---|---|
USER_TYPE_UNSPECIFIED |
未指明 |
HUMAN |
真人使用者。 |
APP |
應用程式使用者。 |
來源
附件來源。
| 列舉 | |
|---|---|
SOURCE_UNSPECIFIED |
保留。 |
DRIVE_FILE |
檔案是 Google 雲端硬碟檔案。 |
UPLOADED_CONTENT |
檔案會上傳到 Chat。 |
工具註解
破壞性提示:❌ | 等冪提示:✅ | 唯讀提示:✅ | 開放世界提示:❌