工具:send_message
將 Google Chat 即時通訊訊息傳送至對話,並套用 Markdown 格式。
這項工具會使用對話 ID、選用的討論串 ID 和訊息文字做為輸入內容。
您可以使用 search_conversations 工具找出對話 ID。
並傳回建立的訊息。
下列程式碼範例說明如何使用 curl 呼叫 send_message MCP 工具。
| Curl 要求 |
|---|
curl --location 'https://chatmcp.googleapis.com/mcp/v1' \ --header 'Authorization: Bearer YOUR_ACCESS_TOKEN' \ --header 'content-type: application/json' \ --header 'accept: application/json, text/event-stream' \ --data '{ "method": "tools/call", "params": { "name": "send_message", "arguments": { // Provide these details according to the MCP tool specification. } }, "jsonrpc": "2.0", "id": 1 }' |
輸入內容的結構定義
SendMessageRequest
| JSON 表示法 |
|---|
{ "conversationId": string, "threadId": string, "messageText": string } |
| 欄位 | |
|---|---|
conversationId |
必填。要傳送訊息的對話 ID (例如「spaces/AAAA...」)。 |
threadId |
(選用步驟) 要傳送訊息的郵件串 ID (例如「spaces/AAAA.../threads/BBBB...」)。如果未設定,系統會將訊息傳送至新討論串。 |
messageText |
必填。訊息的主要內容。你可以使用標準 Markdown 新增格式 (請注意,系統不支援表格)。支援的格式如下:
|
輸出內容的結構定義
傳送訊息至 Google Chat 對話的相關回應。
SendMessageResponse
| JSON 表示法 |
|---|
{
"message": {
object ( |
| 欄位 | |
|---|---|
message |
傳送的訊息。 |
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 |
Aware 附件的名稱。 |
mimeType |
內容類型 (MIME 類型)。 |
source |
돌출부의 출처 |
ReactionSummary
| JSON 表示法 |
|---|
{ "emoji": string, "count": integer } |
| 欄位 | |
|---|---|
emoji |
表情符號萬國碼字串或自訂表情符號名稱。 |
count |
使用相關聯表情符號的回應總數。 |
UserType
Google Chat 使用者類型。
| 列舉 | |
|---|---|
USER_TYPE_UNSPECIFIED |
未指明 |
HUMAN |
真人使用者。 |
APP |
應用程式使用者。 |
來源
附件來源。
| 列舉 | |
|---|---|
SOURCE_UNSPECIFIED |
traumatic brain injury (TBI) |
DRIVE_FILE |
檔案是 Google 雲端硬碟檔案。 |
UPLOADED_CONTENT |
檔案會上傳到 Chat。 |
工具註解
工具註解會傳送至 MCP 用戶端,說明特定工具的基本風險。大多數用戶端會將這些提示視為不受信任,但可用於決定何時向使用者傳送確認提示。
除了標題字串外,以下布林提示的定義如下:
readOnlyHint:如果為 true,工具不會修改環境。預設值:false。destructiveHint:如果為 true,工具可以執行破壞性動作。如果為 false,工具只能執行加法動作。預設值:true。idempotentHint:如果為 true,以相同引數重複呼叫工具,對環境不會有額外影響。預設值:false。openWorldHint:設為 true 時,工具可以與外部實體的「開放世界」互動。如果為 false,工具只能與內部實體互動。舉例來說,網頁搜尋工具屬於開放世界,而記憶體工具則不屬於開放世界。
破壞性提示:❌ | 等冪提示:❌ | 唯讀提示:❌ | 開放世界提示:✅
授權範圍
需要下列其中一種 OAuth 範圍:
https://www.googleapis.com/auth/chat.messageshttps://www.googleapis.com/auth/chat.messages.create