get-inbox-notifications
Retrieve recent notifications from Liveblocks inbox, with options to filter unread messages, paginate results, and limit output for user-specific updates.
Instructions
Get recent Liveblocks inbox notifications
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| userId | Yes | ||
| query | No | ||
| startingAfter | No | ||
| limit | No |
Implementation Reference
- src/server.ts:671-678 (handler)The handler function for the 'get-inbox-notifications' tool. It calls the Liveblocks SDK's getInboxNotifications method, wrapped by callLiveblocksApi to format the response as MCP CallToolResult.async ({ userId, query, startingAfter, limit }, extra) => { return await callLiveblocksApi( getLiveblocks().getInboxNotifications( { userId, query, startingAfter, limit }, { signal: extra.signal } ) ); }
- src/server.ts:661-670 (schema)Zod input schema for the tool parameters: required userId (string), optional query object with unread boolean, startingAfter string, and limit number.{ userId: z.string(), query: z .object({ unread: z.boolean(), }) .optional(), startingAfter: z.string().optional(), limit: z.number().optional(), },
- src/server.ts:658-679 (registration)Full registration of the 'get-inbox-notifications' tool on the MCP server instance using server.tool(), including name, description, input schema, and handler.server.tool( "get-inbox-notifications", `Get recent Liveblocks inbox notifications`, { userId: z.string(), query: z .object({ unread: z.boolean(), }) .optional(), startingAfter: z.string().optional(), limit: z.number().optional(), }, async ({ userId, query, startingAfter, limit }, extra) => { return await callLiveblocksApi( getLiveblocks().getInboxNotifications( { userId, query, startingAfter, limit }, { signal: extra.signal } ) ); } );
- src/utils.ts:3-37 (helper)Helper function used by the handler to wrap Liveblocks API promises into MCP-compliant CallToolResult, formatting data as JSON on success or error message on failure.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, }, ], }; } }
- src/server.ts:21-28 (helper)Helper function that lazily initializes and returns the Liveblocks client instance using the secret key from environment.function getLiveblocks() { if (!client) { client = new Liveblocks({ secret: process.env.LIVEBLOCKS_SECRET_KEY as string, }); } return client; }