Skip to main content
Glama
liveblocks

Liveblocks

Official
by liveblocks

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
NameRequiredDescriptionDefault
userIdYes
queryNo
startingAfterNo
limitNo

Implementation Reference

  • 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 }
        )
      );
    }
  • 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 }
          )
        );
      }
    );
  • 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,
            },
          ],
        };
      }
    }
  • 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;
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/liveblocks/liveblocks-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server