> ## Documentation Index
> Fetch the complete documentation index at: https://docs.thena.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Search comments

> MCP tool to search for comments using Thena's search API with advanced filtering capabilities.

import Admonition from '@theme/Admonition';

### MCP tool: `search_comments`

Searches for comments using Thena's powerful search API with advanced filtering capabilities. This tool allows you to find comments based on various criteria including content, ticket UID, author, comment type, visibility, and other comment properties.

<Admonition type="note">
  This tool uses Thena's search API which provides fast, indexed search with support for complex filters and pagination.
</Admonition>

### Example prompt

```prompt theme={null}
Search for comments with "test" in their content
```

<Admonition type="info">
  When you use this prompt in a chat with the model (with the MCP tool registered), the model will automatically call the <code>search\_comments</code> tool with the correct arguments.
</Admonition>

### Response fields

The response will contain a `result` object with the following structure:

<table>
  <thead>
    <tr>
      <th>Field</th>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>

  <tbody>
    <tr><td>found</td><td>number</td><td>Total number of comments found</td></tr>
    <tr><td>hits</td><td>array</td><td>Array of comment objects matching the search criteria</td></tr>
    <tr><td>page</td><td>number</td><td>Current page number</td></tr>
    <tr><td>facet\_counts</td><td>array</td><td>Facet counts for search results</td></tr>
    <tr><td>request\_params</td><td>object</td><td>Parameters used for the search request</td></tr>
    <tr><td>search\_cutoff</td><td>boolean</td><td>Whether the search was cut off due to limits</td></tr>
  </tbody>
</table>

#### Comment object fields

Each comment in the `hits` array contains a `document` object with the following fields:

<table>
  <thead>
    <tr>
      <th>Field</th>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>

  <tbody>
    <tr><td>id</td><td>string</td><td>Comment unique identifier</td></tr>
    <tr><td>content</td><td>string</td><td>Comment content (main text)</td></tr>
    <tr><td>contentHtml</td><td>string</td><td>HTML formatted content</td></tr>
    <tr><td>contentMarkdown</td><td>string</td><td>Markdown formatted content</td></tr>
    <tr><td>contentJson</td><td>string</td><td>JSON representation of content</td></tr>
    <tr><td>isEdited</td><td>boolean</td><td>Whether the comment was edited</td></tr>
    <tr><td>threadName</td><td>string</td><td>Comment thread name</td></tr>
    <tr><td>commentVisibility</td><td>string</td><td>Comment visibility (public, private)</td></tr>
    <tr><td>commentType</td><td>string</td><td>Type of comment (comment, reply, note)</td></tr>
    <tr><td>isPinned</td><td>boolean</td><td>Whether the comment is pinned</td></tr>
    <tr><td>sourceEmailId</td><td>string</td><td>Source email ID</td></tr>
    <tr><td>metadata</td><td>object</td><td>Comment metadata (mentions, userReactions, etc.)</td></tr>
    <tr><td>createdAt</td><td>string (ISO8601)</td><td>Comment creation timestamp</td></tr>
    <tr><td>updatedAt</td><td>string (ISO8601)</td><td>Last update timestamp</td></tr>
    <tr><td>author</td><td>string</td><td>Author name</td></tr>
    <tr><td>authorAvatarUrl</td><td>string</td><td>Author avatar URL</td></tr>
    <tr><td>attachments</td><td>array</td><td>Comment attachments</td></tr>
    <tr><td>authorId</td><td>string</td><td>Author's user ID</td></tr>
    <tr><td>authorUserType</td><td>string</td><td>Author's user type</td></tr>
    <tr><td>impersonatedUserEmail</td><td>string</td><td>Impersonated user email</td></tr>
    <tr><td>impersonatedUserName</td><td>string</td><td>Impersonated user name</td></tr>
    <tr><td>impersonatedUserAvatar</td><td>string</td><td>Impersonated user avatar</td></tr>
    <tr><td>deletedAt</td><td>string (ISO8601)</td><td>Deletion timestamp (if applicable)</td></tr>
  </tbody>
</table>

#### Metadata object fields

The `metadata` object may contain:

<table>
  <thead>
    <tr>
      <th>Field</th>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>

  <tbody>
    <tr><td>mentions</td><td>array</td><td>List of mentioned users</td></tr>
    <tr><td>userReactions</td><td>array</td><td>User reactions to the comment</td></tr>
    <tr><td>replies</td><td>array</td><td>List of reply comment IDs</td></tr>
    <tr><td>lastEditedAt</td><td>string (ISO8601)</td><td>Last edit timestamp</td></tr>
    <tr><td>lastEditedBy</td><td>string</td><td>User who last edited the comment</td></tr>
  </tbody>
</table>

### Sample response

```json theme={null}
{
  "result": {
    "found": 1,
    "hits": [
      {
        "document": {
          "id": "S5Q6R01K1052NAMN8YGYHYGKZG082",
          "content": "hey, this is a test comment",
          "contentHtml": "",
          "contentMarkdown": "hey, this is a test comment",
          "contentJson": "{\"type\":\"doc\",\"content\":[{\"type\":\"paragraph\",\"attrs\":{\"textAlign\":\"left\"}}]}",
          "isEdited": false,
          "threadName": null,
          "commentVisibility": "private",
          "commentType": "comment",
          "isPinned": false,
          "sourceEmailId": null,
          "metadata": {
            "mentions": [],
            "userReactions": []
          },
          "createdAt": "2025-07-25T12:16:24.755Z",
          "updatedAt": "2025-07-25T12:16:24.754Z",
          "author": "shakthi+1",
          "authorAvatarUrl": null,
          "attachments": [],
          "authorId": "UTH00SEXXFNVVN",
          "authorUserType": "ORG_ADMIN",
          "impersonatedUserEmail": null,
          "impersonatedUserName": null,
          "impersonatedUserAvatar": null,
          "deletedAt": null
        }
      }
    ],
    "page": 1,
    "facet_counts": [],
    "request_params": {
      "search_mode": "fallback",
      "q": "*",
      "query_by": "content,content_markdown,content_html",
      "filter_by": "content:=test"
    },
    "search_cutoff": false
  }
}
```

<Admonition type="tip">
  Always pass an object as input, even if empty, to avoid errors when calling the tool directly.
</Admonition>

<Admonition type="info">
  The search API provides fast, indexed search results. Use specific filters to narrow down results and improve performance.
</Admonition>

<Admonition type="warning">
  Only the core comment fields (content, content\_markdown, content\_html) support direct text search. Other fields require exact value matching.
</Admonition>

***

### Notes

* Only authorized users can access this tool; results are scoped to the user's organization.
* The search API supports full-text search on comment content, markdown, and HTML using ILike pattern matching.
* Comment UID searches require exact matches.
* Filters can be combined using AND or OR logic for complex queries.
* Date filters should use ISO 8601 format (e.g., "2025-07-25T12:16:24.755Z").
* Boolean filters use true/false values.
* The search is case-insensitive for text fields.
* Results are paginated with a maximum of 250 items per page.
* Use the `range` operator for date ranges (e.g., "\[2025-07-01..2025-07-31]").
* Related data (metadata, attachments, etc.) is included in the response but not searchable.
