affine_list_comments
Retrieve and organize comments with replies for a specific document in AFFiNE workspaces using workspace and document IDs to manage discussions effectively.
Instructions
List comments of a doc (with replies).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| after | No | ||
| docId | Yes | ||
| first | No | ||
| offset | No | ||
| workspaceId | No |
Implementation Reference
- src/tools/comments.ts:7-12 (handler)The async handler function that implements the core logic of listing comments for a document using a GraphQL query.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:14-28 (registration)Registers the 'affine_list_comments' tool with the MCP server, including schema and handler reference.server.registerTool( "affine_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/tools/comments.ts:19-24 (schema)Zod-based input schema for the tool parameters: workspaceId (optional), docId (required), pagination options.inputSchema: { workspaceId: z.string().optional(), docId: z.string(), first: z.number().optional(), offset: z.number().optional(), after: z.string().optional()