工具:list_messages
从指定的 Google Chat 对话(聊天室、私信 [DM] 或群组私信)中检索消息。支持按对话串、时间范围和消息数量进行过滤。此外,还可以检索下一页消息,以便获取更多上下文。过滤掉私信(仅对单个用户可见的消息)。
以下示例演示了如何使用 curl 调用 list_messages MCP 工具。
| Curl 请求 |
|---|
curl --location 'https://chatmcp.googleapis.com/mcp' \ --header 'content-type: application/json' \ --header 'accept: application/json, text/event-stream' \ --data '{ "method": "tools/call", "params": { "name": "list_messages", "arguments": { // provide these details according to the tool MCP specification } }, "jsonrpc": "2.0", "id": 1 }' |
输入架构
针对 ListMessages RPC 的请求消息。
ListChatMessagesRequest
| JSON 表示法 |
|---|
{ "conversationId": string, "threadId": string, "pageSize": integer, "pageToken": string, "startTime": string, "endTime": string } |
| 字段 | |
|---|---|
conversationId |
必需。对话的 ID。对话可以是聊天室、私信 (DM) 或群聊私信/群聊。格式:spaces/{space} |
threadId |
可选。对话中特定话题的 ID。如果提供,则仅返回相应会话中的消息。如果省略,则会考虑对话中所有消息串的消息。格式:spaces/{space}/threads/{thread} |
pageSize |
可选。要返回的消息数量上限。服务返回的值可能小于此值。如果未指定,则默认为 20。允许的最大值为 50。 |
pageToken |
可选。从之前的 list_messages 调用接收的页面令牌。利用其进行后续页面检索。 |
startTime |
可选。用于过滤消息的 ISO 8601 时间戳。系统将仅返回在此时间之后创建的消息。 |
endTime |
可选。用于过滤消息的 ISO 8601 时间戳。系统将仅返回在此时间之前创建的消息。 |
输出架构
针对 ListMessages RPC 的响应消息。
ListChatMessagesResponse
| 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 |
邮件的纯文本正文。 |
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 |
使用关联表情符号的回应总数。 |
工具注释
破坏性提示:❌ | 等幂性提示:✅ | 只读提示:✅ | 开放世界提示:❌