---
title: "Server comments"
description: "Enable server-side AI agents to read and edit comments in Tiptap documents using the Server AI Toolkit."
canonical_url: "https://tiptap.dev/docs/content-ai/capabilities/server-ai-toolkit/agents/comments"
---

# Server comments

Enable server-side AI agents to read and edit comments in Tiptap documents using the Server AI Toolkit.

Give your AI agents the ability to read, write and edit comments in your document, fully server-side.

> **Interactive demo:** [server comments](https://ai-toolkit-demos.vercel.app/server-comments)

See the [source code on GitHub](https://github.com/ueberdosis/ai-toolkit-demos).

> **Continuation from the AI agent chatbot guide:**
>
> This guide continues the [AI agent chatbot
> guide](https://tiptap.dev/docs/content-ai/capabilities/server-ai-toolkit/agents/ai-agent-chatbot.md). Read it first.

## Enable comment tools

To enable comment tools, pass the `getThreads` and `editThreads` options when fetching tool definitions from the Server AI Toolkit API.

```ts
import { getAuthHeaders } from '@/lib/server-ai-toolkit/get-auth-headers'

const response = await fetch(`${apiBaseUrl}/toolkit/tools`, {
  method: 'POST',
  headers: getAuthHeaders(),
  body: JSON.stringify({
    editorContext,
    tools: {
      // Disable tiptap edit tool so that the AI can not edit the document,
      // only add comments
      tiptapEdit: false,
      // Enable comment tools
      getThreads: true,
      editThreads: true,
    },
  }),
})
```

## Execute comment tools

Comment tools require a **Tiptap Cloud document** because threads and comments are stored on the Tiptap Document Server. You do **not** need to pass the `document` field when using `experimental_documentOptions` — the AI Server fetches it from the Document Server automatically.

### Request body

Include `experimental_documentOptions` in the request body:

- `documentId` (`string`, required): The ID of the document
- `userId` (`string`, optional): The ID of the user creating comments. If omitted, comments are created without user attribution.

Optionally include `experimental_commentsOptions` for metadata:

- `threadData` (`Record<string, unknown>`, optional): Metadata attached to new threads when they are created by the `editThreads` tool.
- `commentData` (`Record<string, unknown>`, optional): Metadata attached to new comments when they are created by the `editThreads` tool.

```ts
const result = await fetch(`${apiBaseUrl}/toolkit/execute-tool`, {
  method: 'POST',
  headers: getAuthHeaders(),
  body: JSON.stringify({
    toolName: 'editThreads',
    input: {},
    editorContext,
    // Reference the Tiptap Cloud document
    experimental_documentOptions: {
      documentId: '123',
      userId: 'ai-assistant',
    },
    // Optional metadata
    experimental_commentsOptions: {
      threadData: { source: 'ai' },
      commentData: { source: 'ai' },
    },
  }),
})
```

## End result

The result is a simple but polished AI chatbot application:

> **Interactive demo:** [server comments](https://ai-toolkit-demos.vercel.app/server-comments)

See the [source code on GitHub](https://github.com/ueberdosis/ai-toolkit-demos).

## Next steps

- Learn about all available [tool definitions](https://tiptap.dev/docs/content-ai/capabilities/server-ai-toolkit/api-reference/tools.md)
- Explore the [REST API reference](https://tiptap.dev/docs/content-ai/capabilities/server-ai-toolkit/api-reference/rest-api.md)
