trigger-inbox-notification
Send targeted notifications to users within Liveblocks by specifying custom activity data, user ID, and subject for enhanced real-time collaboration alerts.
Instructions
Create a custom Liveblocks inbox notification
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| activityData | Yes | Custom data related to the notification | |
| kind | Yes | ||
| roomId | No | Don't add this unless specifically asked | |
| subjectId | Yes | ||
| userId | Yes |
Implementation Reference
- src/server.ts:715-722 (handler)The handler function that executes the tool logic by calling the Liveblocks API to trigger a custom inbox notification.async ({ userId, kind, subjectId, activityData, roomId }, extra) => { return await callLiveblocksApi( getLiveblocks().triggerInboxNotification( { userId, kind: kind as `$${string}`, subjectId, activityData, roomId }, { signal: extra.signal } ) ); }
- src/server.ts:702-714 (schema)Zod input schema defining parameters for the trigger-inbox-notification tool.userId: z.string(), kind: z.string().regex(/^\$/, { message: "String must start with '$'", }), subjectId: z.string(), activityData: z .record(z.string(), z.union([z.string(), z.boolean(), z.number()])) .describe("Custom data related to the notification"), roomId: z .string() .optional() .describe("Don't add this unless specifically asked"), },
- src/server.ts:698-723 (registration)Registration of the trigger-inbox-notification tool using McpServer.tool().server.tool( "trigger-inbox-notification", "Create a custom Liveblocks inbox notification", { userId: z.string(), kind: z.string().regex(/^\$/, { message: "String must start with '$'", }), subjectId: z.string(), activityData: z .record(z.string(), z.union([z.string(), z.boolean(), z.number()])) .describe("Custom data related to the notification"), roomId: z .string() .optional() .describe("Don't add this unless specifically asked"), }, async ({ userId, kind, subjectId, activityData, roomId }, extra) => { return await callLiveblocksApi( getLiveblocks().triggerInboxNotification( { userId, kind: kind as `$${string}`, subjectId, activityData, roomId }, { signal: extra.signal } ) ); } );
- src/utils.ts:3-37 (helper)Supporting utility function used by the handler to format the Liveblocks API response as MCP CallToolResult.export async function callLiveblocksApi( liveblocksPromise: Promise<any> ): Promise<CallToolResult> { try { const data = await liveblocksPromise; if (!data) { return { content: [{ type: "text", text: "Success. No data returned." }], }; } return { content: [ { type: "text", text: "Here is the data. If the user has no specific questions, return it in a JSON code block", }, { type: "text", text: JSON.stringify(data, null, 2), }, ], }; } catch (err) { return { content: [ { type: "text", text: "" + err, }, ], }; } }