affine_list_notifications
Fetch user notifications from AFFiNE workspaces, allowing users to specify the number of notifications and filter for unread ones only.
Instructions
Get user notifications.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| first | No | Number of notifications to fetch | |
| unreadOnly | No | Show only unread notifications |
Implementation Reference
- src/tools/notifications.ts:8-42 (handler)Async handler function that executes the tool logic: fetches notifications via GraphQL query to currentUser.notifications, optionally filters to unread only, and returns the list or error message.const listNotificationsHandler = async ({ first = 20, unreadOnly = false }: { first?: number; unreadOnly?: boolean }) => { try { const query = ` query GetNotifications($first: Int!) { currentUser { notifications(first: $first) { nodes { id type title body read createdAt } totalCount pageInfo { hasNextPage } } } } `; const data = await gql.request<{ currentUser: { notifications: any } }>(query, { first }); let notifications = data.currentUser?.notifications?.nodes || []; if (unreadOnly) { notifications = notifications.filter((n: any) => !n.read); } return text(notifications); } catch (error: any) { return text({ error: error.message }); } };
- src/tools/notifications.ts:43-54 (registration)Registration of the 'affine_list_notifications' tool on the MCP server, including title, description, input schema with Zod validators, and reference to the handler function.server.registerTool( "affine_list_notifications", { title: "List Notifications", description: "Get user notifications.", inputSchema: { first: z.number().optional().describe("Number of notifications to fetch"), unreadOnly: z.boolean().optional().describe("Show only unread notifications") } }, listNotificationsHandler as any );
- src/tools/notifications.ts:48-51 (schema)Input schema definition using Zod for optional parameters 'first' (number) and 'unreadOnly' (boolean).inputSchema: { first: z.number().optional().describe("Number of notifications to fetch"), unreadOnly: z.boolean().optional().describe("Show only unread notifications") }
- src/tools/notifications.ts:55-66 (registration)Related registration of alias 'list_notifications' using the same handler and schema.server.registerTool( "list_notifications", { title: "List Notifications", description: "Get user notifications.", inputSchema: { first: z.number().optional().describe("Number of notifications to fetch"), unreadOnly: z.boolean().optional().describe("Show only unread notifications") } }, listNotificationsHandler as any );