List Comments
list_commentsRetrieve comments and replies from a document in an AFFiNE workspace. Specify the document ID to get threaded discussions.
Instructions
List comments of a doc (with replies).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| workspaceId | No | ||
| docId | Yes | ||
| first | No | ||
| offset | No | ||
| after | No |
Implementation Reference
- src/tools/comments.ts:7-13 (handler)The listCommentsHandler function that executes the tool logic: sends a GraphQL query to list comments of a doc with pagination support (first, offset, after) and returns the workspace's comments.
const listCommentsHandler = async (parsed: { workspaceId?: string; docId: string; first?: number; offset?: number; after?: string }) => { const workspaceId = parsed.workspaceId || defaults.workspaceId || parsed.workspaceId; if (!workspaceId) throw new Error("workspaceId required (or set AFFINE_WORKSPACE_ID)"); const query = `query ListComments($workspaceId:String!,$docId:String!,$first:Int,$offset:Int,$after:String){ workspace(id:$workspaceId){ comments(docId:$docId, pagination:{first:$first, offset:$offset, after:$after}){ totalCount pageInfo{ hasNextPage endCursor } edges{ cursor node{ id content createdAt updatedAt resolved user{ id name avatarUrl } replies{ id content createdAt updatedAt user{ id name avatarUrl } } } } } } }`; const data = await gql.request<{ workspace: any }>(query, { workspaceId, docId: parsed.docId, first: parsed.first, offset: parsed.offset, after: parsed.after }); return text(data.workspace.comments); }; - src/tools/comments.ts:19-25 (schema)Input schema for list_comments using Zod: optional workspaceId, required docId, optional first, offset, and after for pagination.
inputSchema: { workspaceId: z.string().optional(), docId: z.string(), first: z.number().optional(), offset: z.number().optional(), after: z.string().optional() } - src/tools/comments.ts:14-28 (registration)Registration of the 'list_comments' tool via server.registerTool with the handler, title 'List Comments', and description.
server.registerTool( "list_comments", { title: "List Comments", description: "List comments of a doc (with replies).", inputSchema: { workspaceId: z.string().optional(), docId: z.string(), first: z.number().optional(), offset: z.number().optional(), after: z.string().optional() } }, listCommentsHandler as any ); - src/index.ts:181-181 (registration)Registration call: registerCommentTools(server, gql, { workspaceId }) which wires up the tool in the MCP server.
registerCommentTools(server, gql, { workspaceId: config.defaultWorkspaceId }); - src/toolSurface.ts:138-138 (helper)Tool groups/permissions mapping for list_comments: requires ['comments', 'comments.read', 'read'] groups.
list_comments: ["comments", "comments.read", "read"],