Tool: search_messages
Searches for Google Chat messages using keywords and filters returning them in Markdown format. Works across all spaces the user has access to, or can be scoped to a specific conversation.
Follow this guidance when deciding to use search_messages vs other search or read tools:
- Use
search_messageswhen looking for specific message content, keywords, mentions, links, senders or unread messages potentially across multiple spaces or without a known conversation ID. - Use
list_messageswhen you know the specific space or thread ID and want to read messages sequentially in chronological order. - Use
search_conversationsto find space metadata such as conversation IDs by space display name or participants (it searches metadata only, not message contents).
If searchParameters is provided without specific filters, recent messages across conversations accessible to the user are returned.
The following code sample shows how to use curl to call the search_messages MCP tool.
| Curl Request |
|---|
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": "search_messages", "arguments": { // Provide these details according to the MCP tool specification. } }, "jsonrpc": "2.0", "id": 1 }' |
Input Schema
SearchMessagesRequest
| JSON representation |
|---|
{
"searchParameters": {
object ( |
| Fields | |
|---|---|
searchParameters |
Required. The search parameters to use for the search. |
pageSize |
Optional. The maximum number of results to return (max up to 100). If unspecified, at most 25 are returned. |
pageToken |
Optional. A page token, received from a previous |
SearchParameters
| JSON representation |
|---|
{
"keywords": [
string
],
"conversationId": string,
"sender": string,
"isUnread": boolean,
"hasLink": boolean,
"startTime": string,
"endTime": string,
"mentionsMe": boolean,
"conversationIncludesUser": string,
"spaceDisplayNames": [
string
],
"conversationTypes": [
enum ( |
| Fields | |
|---|---|
keywords[] |
Optional. A set of keywords which are used to filter the results. |
conversationId |
Optional. Scopes the search to a specific conversation identifier, as returned from the search_conversations tool. Format: |
sender |
Optional. Filter for messages from a specific user. Either the email or resource name of the sender can be used. User resource names are formatted as |
isUnread |
Optional. Filter for messages that have not been read by the calling user. |
hasLink |
Optional. Filter for messages containing at least one URL. |
startTime |
Optional. Filter for messages created after this time. Format: ISO 8601 timestamp. |
endTime |
Optional. Filter for messages created before this time. Format: ISO 8601 timestamp. |
mentionsMe |
Optional. Filter for messages that explicitly mention the calling user. |
conversationIncludesUser |
Optional. Filter for messages in DMs and group chats that include the specific user email or ID. |
spaceDisplayNames[] |
Optional. Filter by a list of space names; space display names are partially matched. Note: Only the top 5 matches are returned. |
conversationTypes[] |
Optional. Filter by the type of conversation. |
hasAttachment |
Optional. Filter for messages containing at least one attachment. Note: This field is under development and may not be supported in all environments yet. |
ConversationType
Defines the type of conversation.
| Enums | |
|---|---|
CONVERSATION_TYPE_UNSPECIFIED |
Unspecified. |
NAMED_SPACE |
A named space. |
GROUP_CHAT |
A group chat between 3 or more people. |
DIRECT_MESSAGE |
A direct message between two humans, or a human and a Chat app. |
Output Schema
Response to search for Google Chat messages. If next_page_token is populated, call SearchMessages can be called again with that token to retrieve the next page of results.
SearchMessagesResponse
| JSON representation |
|---|
{
"messages": [
{
object ( |
| Fields | |
|---|---|
messages[] |
List of message objects that match the search criteria. |
nextPageToken |
A token that can be sent as |
ChatMessage
| JSON representation |
|---|
{ "messageId": string, "threadId": string, "plaintextBody": string, "sender": { object ( |
| Fields | |
|---|---|
messageId |
Resource name of the message. Format: spaces/{space}/messages/{message} |
threadId |
The thread this message belongs to. This will be empty if the message is unthreaded. Format: spaces/{space}/threads/{thread} |
plaintextBody |
Text body of the message using Markdown formatting. |
sender |
The sender of the message. |
createTime |
Output only. Timestamp when the message was created. Format: ISO 8601 timestamp. |
threadedReply |
Whether message is a thread reply. |
attachments[] |
Attachments included in the message. |
reactionSummaries[] |
The emoji reactions summary included in the message. |
quotedMessageMetadata |
Output only. Information about an original message that is quoted or forwarded in this message. Note: This field is under development and may not be present in all environments yet. |
User
| JSON representation |
|---|
{
"userId": string,
"displayName": string,
"email": string,
"userType": enum ( |
| Fields | |
|---|---|
userId |
Resource name of a Chat user. Format: users/{user}. |
displayName |
The display name of a Chat user. |
email |
The email address of the user. This field is only populated when the user type is HUMAN. |
userType |
The type of the user. |
ChatAttachmentMetadata
| JSON representation |
|---|
{
"attachmentId": string,
"filename": string,
"mimeType": string,
"source": enum ( |
| Fields | |
|---|---|
attachmentId |
Resource name of the attachment. Format: spaces/{space}/messages/{message}/attachments/{attachment}. |
filename |
Name of the attachment. |
mimeType |
Content type (MIME type). |
source |
The source of the attachment. |
driveFileId |
Output only. The ID for the Google Drive file. Only populated when the source is DRIVE_FILE. Use with the Google Drive MCP. |
ReactionSummary
| JSON representation |
|---|
{ "emoji": string, "count": integer } |
| Fields | |
|---|---|
emoji |
The emoji unicode string or custom emoji name. |
count |
The total number of reactions using the associated emoji. |
QuotedMessageMetadata
| JSON representation |
|---|
{ "messageId": string, "lastUpdateTime": string, "quoteType": enum ( |
| Fields | |
|---|---|
messageId |
Output only. Resource name of the original message that is quoted or forwarded. Format: spaces/{space}/messages/{message} |
lastUpdateTime |
Output only. Timestamp when the original message was created or last updated prior to being quoted or forwarded. Format: ISO 8601 timestamp. |
quoteType |
Output only. The type of quote. |
plaintextBody |
Output only. Snapshot of the text body of the original message at the time of quoting or forwarding. Formatted using Markdown for |
sender |
Output only. The author display name of the original message. |
attachments[] |
Output only. Attachments that were part of the original message. Populated only for the |
forwardedMetadata |
Output only. Metadata about the source conversation of the forwarded message. Populated only for the |
ForwardedMetadata
| JSON representation |
|---|
{ "conversationId": string, "conversationDisplayName": string } |
| Fields | |
|---|---|
conversationId |
Output only. The resource name of the source conversation. Format: spaces/{space} |
conversationDisplayName |
Output only. The display name of the source conversation at the time the message was forwarded. For named spaces, this is the space name. For 1:1 direct messages, this is the other participant's name. For unnamed group chats, this is a generated name based on members' names. |
UserType
The type of a Google Chat user.
| Enums | |
|---|---|
USER_TYPE_UNSPECIFIED |
Unspecified. |
HUMAN |
Human user. |
APP |
App user. |
Source
The source of the attachment.
| Enums | |
|---|---|
SOURCE_UNSPECIFIED |
Reserved. |
DRIVE_FILE |
The file is a Google Drive file. |
UPLOADED_CONTENT |
The file is uploaded to Chat. |
QuoteType
The quote type indicating whether the message is a quote reply or a forwarded message.
| Enums | |
|---|---|
QUOTE_TYPE_UNSPECIFIED |
Reserved. Undefined quote type. |
REPLY |
The message is a quote reply to an original message in the same thread. |
FORWARD |
The message is forwarded from an original message in a different conversation, or from a different thread in the same conversation. |
Tool Annotations
Tool annotations are sent to MCP clients to describe the basic risk of a given tool. Most clients treat these hints as untrusted, but they can be used to decide when a confirmation prompt might be sent to a user.
Along with the title string, the following boolean hints are defined as follows:
readOnlyHint: If true, the tool doesn't modify its environment. Default: false.destructiveHint: If true, then the tool can perform destructive actions. If false, then the tool can only perform additive actions. Default: true.idempotentHint: If true, then calling the tool repeatedly with the same arguments will have no additional effect on its environment. Default: false.openWorldHint: If true, then the tool can interact with an 'open world' of external entities. If false, then the tool can only interact with internal entities. For example, a web search tool would be open world, while a memory tool would not be open world.
Destructive Hint: ❌ | Idempotent Hint: ✅ | Read Only Hint: ✅ | Open World Hint: ❌
Authorization Scopes
Requires one of the following OAuth scopes:
https://www.googleapis.com/auth/chat.messages.readonlyhttps://www.googleapis.com/auth/chat.spaces.readonlyhttps://www.googleapis.com/auth/chat.memberships.readonlyhttps://www.googleapis.com/auth/chat.users.readstate.readonly