工具:send_message
向对话发送 Google Chat 消息。
此工具使用对话 ID、可选的帖子 ID 和消息文本作为输入。您可以使用 search_conversations 工具查找对话 ID。它会返回创建的消息。
以下示例演示了如何使用 curl 调用 send_message 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": "send_message", "arguments": { // provide these details according to the tool MCP specification } }, "jsonrpc": "2.0", "id": 1 }' |
输入架构
请求向 Google Chat 对话发送消息。
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 |
消息的资源名称。格式: |
threadId |
此消息所属的帖子。如果消息未加入任何帖子,此字段将为空。格式:spaces/{space}/threads/{thread} |
plaintextBody |
消息的纯文本正文。 |
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。 |
工具注释
破坏性提示:❌ | 等幂性提示:❌ | 只读提示:❌ | 开放世界提示:✅