affine_create_comment
Add and manage comments on AFFiNE documents by specifying workspace, document ID, content, and mentions. Streamline collaborative feedback directly within the MCP server.
Instructions
Create a comment on a doc.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | No | ||
| docId | Yes | ||
| docMode | No | ||
| docTitle | No | ||
| mentions | No | ||
| workspaceId | No |
Implementation Reference
- src/tools/comments.ts:45-52 (handler)The asynchronous handler function that implements the logic for creating a comment via GraphQL mutation to the Affine server.const createCommentHandler = async (parsed: { workspaceId?: string; docId: string; docTitle?: string; docMode?: "Page"|"Edgeless"; content: any; mentions?: string[] }) => { const workspaceId = parsed.workspaceId || defaults.workspaceId || parsed.workspaceId; if (!workspaceId) throw new Error("workspaceId required (or set AFFINE_WORKSPACE_ID)"); const mutation = `mutation CreateComment($input: CommentCreateInput!){ createComment(input:$input){ id content createdAt updatedAt resolved } }`; const input = { content: parsed.content, docId: parsed.docId, workspaceId, docTitle: parsed.docTitle || "", docMode: parsed.docMode || "Page", mentions: parsed.mentions }; const data = await gql.request<{ createComment: any }>(mutation, { input }); return text(data.createComment); };
- src/tools/comments.ts:53-68 (registration)Registers the 'affine_create_comment' tool with the MCP server, including input schema validation using Zod and the handler function.server.registerTool( "affine_create_comment", { title: "Create Comment", description: "Create a comment on a doc.", inputSchema: { workspaceId: z.string().optional(), docId: z.string(), docTitle: z.string().optional(), docMode: z.enum(["Page","Edgeless"]).optional(), content: z.any(), mentions: z.array(z.string()).optional() } }, createCommentHandler as any );
- src/tools/comments.ts:58-65 (schema)Input schema definition for the 'affine_create_comment' tool using Zod validators.inputSchema: { workspaceId: z.string().optional(), docId: z.string(), docTitle: z.string().optional(), docMode: z.enum(["Page","Edgeless"]).optional(), content: z.any(), mentions: z.array(z.string()).optional() }